[New-bugs-announce] [issue30166] Import command-line parsing modules only when needed
Serhiy Storchaka
report at bugs.python.org
Wed Apr 26 04:34:19 EDT 2017
New submission from Serhiy Storchaka:
Berker suggested to move this part from issue30152 to its own PR.
When the file can be imported as a module and run as a script it is worth to make command-line parsing modules (getopt, optparse, argparse) be imported only when they are used, i.e. when the file is ran as a script. Most of the stdlib modules already do this.
Proposed patch moves imports of command-line parsing modules and some other modules used only when the module is ran to the main() function or to the branch executed only if __name__ == "__main__". It doesn't change scripts and files that are purposed to be used only for running (__main__.py, main.py).
----------
components: Library (Lib)
messages: 292319
nosy: serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Import command-line parsing modules only when needed
type: enhancement
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30166>
_______________________________________
More information about the New-bugs-announce
mailing list