[issue24338] In argparse adding wrong arguments makes malformed namespace

2021-12-10 Thread Irit Katriel
Irit Katriel added the comment: >From the discussion and "rejected" resolution it looks like the intention was >to close this issue. I will do that soon if nobody objects. -- nosy: +iritkatriel status: open -> pending ___ Python tracker

[issue24338] In argparse adding wrong arguments makes malformed namespace

2019-07-11 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : Removed file: https://bugs.python.org/file48470/126.pdf ___ Python tracker ___ ___ Python-bugs-list

[issue24338] In argparse adding wrong arguments makes malformed namespace

2019-07-11 Thread tomas platz
Change by tomas platz : Added file: https://bugs.python.org/file48470/126.pdf ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue24338] In argparse adding wrong arguments makes malformed namespace

2015-06-03 Thread paul j3
paul j3 added the comment: http://bugs.python.org/issue15125 argparse: positional arguments containing - in name not handled well Discussion on whether positionals 'dest' should translate '-' to '_'. -- ___ Python tracker rep...@bugs.python.org

[issue24338] In argparse adding wrong arguments makes malformed namespace

2015-06-03 Thread py.user
py.user added the comment: paul j3 wrote: It's an attempt to turn such flags into valid variable names. I'm looking at code and see that he wanted to make it handy for use in a resulting Namespace. args = argparse.parse_args(['--a-b-c']) abc = args.a_b_c If he doesn't convert, he cannot get

[issue24338] In argparse adding wrong arguments makes malformed namespace

2015-06-03 Thread paul j3
paul j3 added the comment: Yes, the '_' makes it accessible as an attribute name. But the presence of '-' in the option name has a UNIX history. That is a flag like '--a-b-c' is typical, '--a_b_c' is not. There is less of precedent for a flag like '@@a@b' or '--a@b'. Here's the relevant

[issue24338] In argparse adding wrong arguments makes malformed namespace

2015-06-03 Thread paul j3
paul j3 added the comment: The code that converts '-' to '_' is independent of the code that uses 'prefix_chars'. The '-' conversion handles a long standing UNIX practice of allowing that character in the middle of option flags. It's an attempt to turn such flags into valid variable names.

[issue24338] In argparse adding wrong arguments makes malformed namespace

2015-05-31 Thread Matthias Bussonnier
Matthias Bussonnier added the comment: Minimal changes to the repr seem to work. I can submit a proper patch. class N2(Namespace): def __repr__(self): type_name = type(self).__name__ arg_strings = [] unarg={} for arg in self._get_args():

[issue24338] In argparse adding wrong arguments makes malformed namespace

2015-05-31 Thread Matthias Bussonnier
Matthias Bussonnier added the comment: Maybe the __repr__ of _AttributeHolder should be changed so that invalid args are shown as unpacked dict in the signature ? Something that would : argparse.Namespace(**{'foo bar':1}) argparse.Namespace(**{'foo bar':1}) -- nosy: +mbussonn

[issue24338] In argparse adding wrong arguments makes malformed namespace

2015-05-31 Thread py.user
py.user added the comment: Serhiy Storchaka wrote: for example the use of such popular options as -0 or -@ Ok. What about inconsistent conversion dashes to underscores? import argparse parser = argparse.ArgumentParser(prefix_chars='@') _ = parser.add_argument('--x-one-two-three@') _ =

[issue24338] In argparse adding wrong arguments makes malformed namespace

2015-05-31 Thread py.user
New submission from py.user: import argparse parser = argparse.ArgumentParser() _ = parser.add_argument('foo bar') _ = parser.add_argument('--x --y') args = parser.parse_args(['abc']) args Namespace(foo bar='abc', x __y=None) 'foo bar' in dir(args) True 'x __y' in dir(args) True

[issue24338] In argparse adding wrong arguments makes malformed namespace

2015-05-31 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: They are accessible. getattr(args, 'foo bar') 'abc' The limitation that argument names should be Python identifiers is too strong and adding it will break existing code (for example the use of such popular options as -0 or -@). -- nosy: