mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
Issue #21966: Respect -q command-line option when code module is ran.
Contributed by Anton Barkovsky.
This commit is contained in:
parent
de1fb6660b
commit
007a90317d
2 changed files with 12 additions and 1 deletions
11
Lib/code.py
11
Lib/code.py
|
@ -7,6 +7,7 @@
|
|||
|
||||
import sys
|
||||
import traceback
|
||||
import argparse
|
||||
from codeop import CommandCompiler, compile_command
|
||||
|
||||
__all__ = ["InteractiveInterpreter", "InteractiveConsole", "interact",
|
||||
|
@ -299,4 +300,12 @@ def interact(banner=None, readfunc=None, local=None):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
interact()
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-q', action='store_true',
|
||||
help="don't print version and copyright messages")
|
||||
args = parser.parse_args()
|
||||
if args.q or sys.flags.quiet:
|
||||
banner = ''
|
||||
else:
|
||||
banner = None
|
||||
interact(banner)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue