RE: import structures



-----Original Message-----
From: python-list-bounces+whamil1=entergy.com@xxxxxxxxxx
[mailto:python-
list-bounces+whamil1=entergy.com@xxxxxxxxxx] On Behalf Of spohle
Sent: Monday, April 30, 2007 10:25 AM
To: python-list@xxxxxxxxxx
Subject: Re: import structures

On Apr 30, 8:16 am, "Hamilton, William " <wham...@xxxxxxxxxxx> wrote:


If you've got modules a, b, and c, you can create a wrapper module d
that imports from each of those.

from a import *
from b import *
from c import *

Then, import d and use it as the module name. So if a had a
SomeThing
class, you could do this:

import d
x = d.SomeThing()

---
-Bill Hamilton


that doesn't seem to work for me. the from a import * will only give
me a not d.a



"from blah import *" puts everything in blah into the current module's
namespace (or so I understand it). This is different from "import
blah": with the latter, you have to use "x = blah.SomeThing()". With
the former, you can simply say "x = SomeThing()".

So, if a has a class SomeThing, and you import it into d using "from a
import *", in d you can use SomeThing's methods directly. If you then
use "import d" in your main script, you can create a SomeThing instance
with
"x = d.SomeThing()".

---
-Bill Hamilton
.