Relative-importing *

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Wed Jul 25 21:19:08 CEST 2007


Paul Rubin a écrit :
> Steven D'Aprano <steve at REMOVE.THIS.cybersource.com.au> writes:
> 
>>I read "from module import *" as explicitly saying "clobber the current
>>namespace with whatever names module exports". That's what from does: it
>>imports names into the current namespace. It isn't some sort of easy to
>>miss side-effect. If a name already existed, it gets clobbered, just like
>>any other import:
> 
> 
> Seems to me that there should be a compiler warning when this happens.

if some_runtime_condition:
   from foo import *

Paul, I do know why you think compile-time checks are a good thing, but 
you do have to understand that Python is *highly* dynamic. Except for 
syntax errors, don't expect much help from the Python's compiler.



More information about the Python-list mailing list