[issue13922] argparse handling multiple "--" in args improperly
New submission from Warren Turkal : I have a program that runs something like the following: $ hack run -- :target --arg1 --arg2 arg3 arg4 This basically runs a program identified by :target with the args. However, I cannot pass "--" to the program. For example, if I type: $ hack run -- :hack run -- :target clean --help the second "--" is swallowed by the parser, and I get an the help for "hack run" instead of instead of "hack clean". The run subcommand just does the following: all_args = [target.bin_path] + args.args os.execv(target.bin_path, all_args) However, the first hack run has the following list for args: args = Namespace(args=['run', ':hack', 'clean', '--help'], func=, target=':hack') Where is the second "--"? I would have expected the args list to be: args=['run', '--', ':hack', 'clean', '--help'] About the python version, I am using python 2.6. However, I am using the latest release of argparse from [1] and am assuming that it's very similar code. [1]http://code.google.com/p/argparse/downloads/list -- messages: 152443 nosy: Warren.Turkal priority: normal severity: normal status: open title: argparse handling multiple "--" in args improperly type: behavior versions: Python 2.7, Python 3.2 ___ Python tracker <http://bugs.python.org/issue13922> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13923] new formatter for argparse
New submission from Warren Turkal : It would be really nice to have a formatter for argparse that would respect explicit new lines while still wrapping lines otherwise. This would allow the description and epilog to have be a little more structured while still getting the advantage of line wrapping. -- messages: 152444 nosy: Warren.Turkal priority: normal severity: normal status: open title: new formatter for argparse type: enhancement ___ Python tracker <http://bugs.python.org/issue13923> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13923] new formatter for argparse
Warren Turkal added the comment: [1] sounds somewhere related and more complicated than what I was asking for. I would think that it would need to wrap bulleted lists in a sane way in addition to what I asked for here. Also, [1] seems to apply to the option help text, where this request applies to the prolog and epilog. Although, it really makes sense to me for the formatter to format all the text bits similarly. [1]http://bugs.python.org/issue12806 -- ___ Python tracker <http://bugs.python.org/issue13923> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13922] argparse handling multiple "--" in args improperly
Warren Turkal added the comment: I wanted to include a minimal example script, so here it is. If you run this like so: $ ./test.py -- blah -- blah2 you will get the the following output: Namespace(args=['blah2'], target=['blah']) I would have expected the following instead: Namespace(args=['--', 'blah2'], target=['blah']) -- ___ Python tracker <http://bugs.python.org/issue13922> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13922] argparse handling multiple "--" in args improperly
Warren Turkal added the comment: It doesn't look like that file got included last time, so here's a second try. -- Added file: http://bugs.python.org/file24424/test.py ___ Python tracker <http://bugs.python.org/issue13922> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13922] argparse handling multiple "--" in args improperly
Changes by Warren Turkal : -- versions: +Python 3.3, Python 3.4 ___ Python tracker <http://bugs.python.org/issue13922> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13922] argparse handling multiple "--" in args improperly
Warren Turkal added the comment: Using argparse.REMAINDER will not help for my problem in my real program as the first arg needs to be handled by my program and mapped into the real binary name. If I recall correctly from memory, the following is what happened when I tried using argparse.REMAINDER. If call my program like so: $ hack run :target --help The subcommand will be "run" in this case. Because :target is handled by argparse, the "--help" will not be seen as part of the remainder of the arguments, and I will get the help for the "hack run" subcommand instead of the target binary getting the --help argument. I have pushed most of the program to [1] if you want to take a look. Specifically, see cli/commands/run.py:do_run for that bit of code that handles the run subcommand. [1]https://github.com/wt/repo-digg-dev-hackbuilder -- ___ Python tracker <http://bugs.python.org/issue13922> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13922] argparse handling multiple "--" in args improperly
Warren Turkal added the comment: Thanks for fixing this issue. You guys are great! wt On Sat, Jul 21, 2012 at 8:00 PM, R. David Murray wrote: > > R. David Murray added the comment: > > Committed. Thanks, Jeff. By the way, although this patch isn't big > enough to require it, it would be great if you would submit a contributor > agreement: http://www.python.org/psf/contrib. > > -- > resolution: -> fixed > stage: -> committed/rejected > status: open -> closed > > ___ > Python tracker > <http://bugs.python.org/issue13922> > ___ > -- ___ Python tracker <http://bugs.python.org/issue13922> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20860] ipaddress network subnets() method should return object with __getitem__
New submission from Warren Turkal: It would be very useful to be able to not only iterate through subnets, but also index a subnet. For example, I would really like to be able to do the following: >>> import ipaddress as ipa >>> net = ipa.ip_network('10.0.0.0/8') >>> print(net.subnets(prefixlen_diff=2)[2]) "10.128.0.0/10" As it stands now, I have to write something like the following to get the same result: >>> import ipaddress as ipa >>> net = ipa.ip_network('10.0.0.0/8') >>> subnets = net.subnets(prefixlen_diff=2) >>> for _ in xrange(0, 3): ... subnet = subnets.next() ... >>> print(subnet) "10.128.0.0/10" The simplest way I can come up with to add this feature is by wrapping the current body of that method in a nested generator function, creating an instance of that generator, adding a appropriate __getitem__ method to that object, and returning that object instead of the bare generator. What do you all think of that? Also, it'd be nice to see this added to the ipaddress module on pypi for python 2.x also. :) -- components: Library (Lib) messages: 212836 nosy: Warren.Turkal priority: normal severity: normal status: open title: ipaddress network subnets() method should return object with __getitem__ type: enhancement versions: Python 3.5 ___ Python tracker <http://bugs.python.org/issue20860> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20860] ipaddress network subnets() method should return object with __getitem__
Warren Turkal added the comment: Won't that instantiate an object for each item in the list though? For example: >>> list(net.subnets(prefixlen_diff=16))[499] This take a long time. I was trying to think of a way to lazily instantiate. For example, I don't want to create 65536 network objects (like above) if I am looking for the 500th /24 subnet of 10.0.0.0/8. The following executes much more quickly: >>> ipa.ip_network((10 << 24) + (499 << 8)) That essentially what the __getattr__ method should do. Of course, it might also be nice to have a __len__ on that object. -- ___ Python tracker <http://bugs.python.org/issue20860> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com