Public imports
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Mon Dec 8 16:18:56 EST 2008
Márcio Faustino a écrit :
> So, no chance of doing this:
>
> # "A.py"
> from __future__ import division, with_statement
>
> # "B.py"
> from A import *
> print 1 / 2
>
> ...and printing 0.5, right?
Nope, but for totally unrelated reasons (cf Skip's anwer).
OTHO, this is valid:
# foo.py
def bar():
return "bar"
# A.py
from foo import bar
# B.py
from A import bar
print bar()
FWIW, this is often used in packages __init__.py to hide the package's
internal organization (or when a module starts to grow too big and has
to be refactored as a package without breaking client code).
HTH
More information about the Python-list
mailing list