RE: import structures
- From: "Hamilton, William " <whamil1@xxxxxxxxxxx>
- Date: Mon, 30 Apr 2007 10:41:40 -0500
-----Original Message-----[mailto:python-
From: python-list-bounces+whamil1=entergy.com@xxxxxxxxxx
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:
SomeThing
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
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
.
- References:
- Re: import structures
- From: spohle
- Re: import structures
- Prev by Date: Re: regexp match string with word1 and not word2
- Next by Date: Can python find HW/SW installed on my PC - like Belarc?
- Previous by thread: Re: import structures
- Next by thread: Re: import structures
- Index(es):