This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients serhiy.storchaka
Date 2017-04-26.08:34:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1493195659.65.0.461959154112.issue30166@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2017-04-26 08:34:19serhiy.storchakasetrecipients: + serhiy.storchaka
2017-04-26 08:34:19serhiy.storchakasetmessageid: <1493195659.65.0.461959154112.issue30166@psf.upfronthosting.co.za>
2017-04-26 08:34:19serhiy.storchakalinkissue30166 messages
2017-04-26 08:34:19serhiy.storchakacreate