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 = argparse.ArgumentParser()
argParser.add_argument('--foo+', action='store_true')
arguments = argParser.parse_args()
print 'getattr foo+: %s' % getattr(arguments, 'foo+') # ok
print arguments.foo+ # syntax error
The patch replaces every non alnum character with an underscore.
----------
components: None
files: argparse.patch
keywords: patch
messages: 170361
nosy: brmzkw
priority: normal
severity: normal
status: open
title: argparse non alphanum characters replacement
type: behavior
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file27178/argparse.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue15929>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com