[Python-3000] PEP to change how the main module is delineated (original) (raw)
Christian Heimes lists at cheimes.de
Mon Apr 23 04:20:08 CEST 2007
- Previous message: [Python-3000] PEP to change how the main module is delineated
- Next message: [Python-3000] PEP to change how the main module is delineated
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Brett Cannon wrote:
Implementation ==============
When the
-m
option is used,sys.main
will be set to the argument passed in.sys.argv
will be adjusted as it is currently. Then the equivalent of_import_(self.main)
will occur. This differs from current semantics as therunpy
module fetches the code object for the file specified by the module name in order to explicitly set_name_
and other attributes. This is no longer needed as import can perform its normal operation in this situation.
import(self.main)? I guess you wanted to write import(sys.main) :)
The newly proposed solution does introduce an added line of boilerplate which is a module import. But as the solution does not introduce a new built-in or module attribute (as discussed in
Rejected Ideas
_) it has been deemed worth the extra line.
Someone on python-idea brought up the idea to add the sys module to builtins. The feature would remove the requirement for an extra line and the costs should be minimal or even zero since sys is a special builtin module.
Some people including me like to resurrect the PEP 299 main() function idea. http://www.python.org/dev/peps/pep-0299/
Christian
- Previous message: [Python-3000] PEP to change how the main module is delineated
- Next message: [Python-3000] PEP to change how the main module is delineated
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]