[issue15929] argparse non alphanum characters replacement

2012-09-12 Thread Julien Castets
New submission from Julien Castets: argparse.add_argument replaces dashes with underscores. If an argument contains another non alphanum character, accessing to it will result to a syntax error. #! /usr/bin/env python import argparse if __name__ == '__main__': argParser =

[issue15929] argparse non alphanum characters replacement

2012-09-12 Thread R. David Murray
R. David Murray added the comment: It would probably be better to have the namespace object support subscripting in order to satisfy this use case. You can use getattr to do it now. (Note that the namespace object should probably use a real dict and a __getattr__ method, since I don't think

[issue15929] argparse non alphanum characters replacement

2012-09-12 Thread Steven Bethard
Steven Bethard added the comment: If you need to get things that aren't valid Python identifiers, use vars() to get the dictionary: http://docs.python.org/dev/library/argparse.html#the-namespace-object Changing all non-alphanumeric characters to underscores would be a backwards incompatible

[issue15929] argparse non alphanum characters replacement

2012-09-12 Thread R. David Murray
R. David Murray added the comment: Oh, it wasn't CPython that that comment was directed at. But I think you are right: because CPython supports it, I think other implementations will as well, whatever the language spec says or doesn't say (I didn't double check, I'm going on a fuzzy memory

[issue15929] argparse non alphanum characters replacement

2012-09-12 Thread Steven Bethard
Steven Bethard added the comment: I haven't been following python-dev recently, but the only discussion I remember was for non-strings in __dict__, not non-identifiers. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15929