[Tutor] Re: Why lambda could be considered evil

Emile van Sebille emile@fenx.com
Fri, 30 Aug 2002 18:34:32 -0700


Erik
> Can someone explain why the code imports both from * and from "__all__"
> ?  I've never seen the import __all__ before.  (It looks like this:
>
> if engine == "sre":
>      # New unicode-aware engine
>      from sre import *
>      from sre import __all__
>

It's because import * doesn't import labels that start with an underscore.
Try the following:

Python 2.1.3 (#35, Apr  8 2002, 17:47:50) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> dir()
['__builtins__', '__doc__', '__name__']
>>> import os
>>> os.__file__
'C:\\Zope\\v2.5\\bin\\lib\\os.pyc'
>>> from os import *
>>> __file__
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name '__file__' is not defined
>>>


HTH,

Emile van Sebille
emile@fenx.com