Help on object scope?

bmaron2 at hotmail.com bmaron2 at hotmail.com
Tue Feb 27 06:45:24 EST 2007


On Feb 26, 1:16 pm, Dennis Lee Bieber <wlfr... at ix.netcom.com> wrote:
> On Mon, 26 Feb 2007 07:54:12 +0200, "Hendrik van Rooyen"
> <m... at microcorp.co.za> declaimed the following in comp.lang.python:
>
>
>
> > from param import *
>
>         "from <> import *" (or any "from <> import ..." variant) is NOT the
> best thing to use.
>
>         Any rebinding to an imported name breaks the linkage to the import
> module.
>
> --
>         Wulfraed        Dennis Lee Bieber               KD6MOG
>         wlfr... at ix.netcom.com             wulfr... at bestiaria.com
>                 HTTP://wlfraed.home.netcom.com/
>         (Bestiaria Support Staff:               web-a... at bestiaria.com)
>                 HTTP://www.bestiaria.com/

Thank you all for the advice.

The suggestion Dennis made about using a 3rd, "common" module to hold
global names seemed to be the best idea. The only problem is now I
have to type common.r.t instead of just r.t. If I put common in the /
lib directory, it is even worse and I have to type lib.common.r.t. I
like that it is explicit and perhaps this is the Python way, but it is
annoying and produces ugly code to see all those fully-qualified names
when all I'd really like to use is r.t throughout the program.

Is there a way to import lib.common but then re-bind its attributes to
the local space without breaking the linkage?





More information about the Python-list mailing list