[issue40265] argparse.Namespace __repr__ does not handle reserved keywords

2020-04-13 Thread Raymond Hettinger
Raymond Hettinger added the comment: Saiyang, thank you for the suggestion, but I'm going to decline. The other referenced issue had to do with readability of otherwise incomprehensible output and that's what made it worthwhile. In this issue, you're prioritizing round-tripping at the expe

[issue40265] argparse.Namespace __repr__ does not handle reserved keywords

2020-04-12 Thread Saiyang Gou
Saiyang Gou added the comment: > The primary function of the Namespace class is to hold valid attributes and > to allow the dot operator to access those attributes. I acknowledge this. Invalid attribute names are not useful in production. However, some crazy people like me would define argum

[issue40265] argparse.Namespace __repr__ does not handle reserved keywords

2020-04-12 Thread Raymond Hettinger
Raymond Hettinger added the comment: ISTM this a purely theoretical problem since "ns.return" is already a syntax error. The primary function of the Namespace class is to hold valid attributes and to allow the dot operator to access those attributes. Handling invalid attribute names is bey

[issue40265] argparse.Namespace __repr__ does not handle reserved keywords

2020-04-12 Thread Saiyang Gou
New submission from Saiyang Gou : It is generally a convention to design the repr string such that `eval(repr(obj))` can reproduce the object. Issue 24360 handles the special situation when arg name passed to `argparse.Namespace` is not a valid identifier: >>> from argparse import Namespace