New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InteractiveConsole does not support -q option #66165
Comments
When invoked with -q option, python3 prints no banner:
However, code.InteractiveConsole does not implement this feature:
|
Here's a patch. |
That was quick! (Well - I knew it would not be hard.) I have two questions:
|
Whether or not other options are emulated, unimplemented ones should probably be rejected. |
I've only now found out about sys.flags. I think we should check for -q both before -m and after, because why not?
As I see it, the module is only concerned with REPL functionality, making these options a bit out of scope. |
In order to implement reasonable rejection behavior, we probably need to add some support for -h. $ python3 -z
Unknown option: -z
usage: python3 [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information. I don't think we should condition acceptance of this patch on extra features. AFAICT, the main use of the code module is in embedded situations and the if __name__ == "__main__" behavior is mostly there for demonstration purposes. On the other hand, something like $ python3 -mcode -z
Unknown option: -z
usage: python3 -mcode [-q] is not hard to implement. |
Here's a patch that checks both sys.flags and sys.argv and uses argparse. |
If we check for sys.flags.quiet, wouldn't it be surprising to have $ python3 -mcode -q
>>> import sys; sys.flags.quiet
0 |
That's not a very likely scenario and I think the distinction between arguments that are passed to the script and interpreter flags is fairly obvious. |
A nitpick: banner=banner in + interact(banner=banner) is redundant. + interact(banner) would work and is just as clear. |
Yeah, my love for keyword arguments is a bit too big sometimes. |
New changeset 7f8843ec34ee by Alexander Belopolsky in branch 'default': |
Committed. Thanks, Anton. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: