>     Proposal:  Add a __module__ keyword which refers to the module
>     currently being defined (executed).  (But see open issues.)
> 
>         if __module__ is sys.main: ...   # assuming PEP 3020, Cannon
>

-1 on __module__

I understand PEP 3020 correctly then sys.main will contain the dotted 
name of the module as *string*.

Also __module__ is already used in objects like classes.

 >>> class C: pass
...
 >>> C.__module__
'__main__'
 >>> type(C.__module__)
<type 'str'>

I don't like the fact that __module__ is going to be a string in some 
cases and a module object in other cases. It's too confusing.

class C:
     def egg(self):
         # string from class C or an object from module?
         # confused ...
         nonlocal __module__

It might work with __this_module__ but I don't see the point in getting 
the local module. I'v used it about 5 times in my many years as Python 
developer when I had to deal with a legacy product. The module and 
package names were badly chosen (Foo/Foo.py: import Foo).

Christian

_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to