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 <rep...@bugs.python.org>
<http://bugs.python.org/issue30166>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to