New submission from Paolo Elvati <elv...@umich.edu>: Hi, when a default is specified for a file argument that is open with writing permission (FileType('w')), the default file is always created even if the argument is specified in the command line. For example he code:
import argparse parser = argparse.ArgumentParser() parser.add_argument( "-o", default = 'fake', dest = 'OutputFile', type = argparse.FileType('w') ) args = parser.parse_args() will create the empty file "fake" even if the -o option is given. The value inside the code of args.Outputfile is not affected. Paolo ---------- components: Library (Lib) messages: 133598 nosy: Paolo.Elvati, bethard priority: normal severity: normal status: open title: argparse: unexpected behavior of default for FileType('w') type: behavior versions: Python 3.2 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11839> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com