Help on object scope?

Jussi Salmela tiedon_jano at hotmail.com
Tue Feb 27 10:54:24 EST 2007


bmaron2 at hotmail.com kirjoitti:
> <snip>

> 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?
> 
> 

See section "6.12 The import statement" in the "Python Reference 
Manual". (Hint the part "as name" is what you want)

HTH,
Jussi



More information about the Python-list mailing list