[issue35005] argparse should accept json and yaml argument types

2020-12-18 Thread Raymond Hettinger
Change by Raymond Hettinger : -- pull_requests: +22713 pull_request: https://github.com/python/cpython/pull/23849 ___ Python tracker ___

[issue35005] argparse should accept json and yaml argument types

2019-10-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: I am going to decline this feature request on the principle of keeping our modules loosely coupled and orthogonal to one another. As paul.j3 pointed out, the "type" option seems to work best with simple conversions like "int". As pointed-out by

[issue35005] argparse should accept json and yaml argument types

2019-10-06 Thread Mauricio Villegas
Mauricio Villegas added the comment: FYI there is a new python package that extends argparse with the enhancements proposed here and more. https://pypi.org/project/jsonargparse/ -- nosy: +mauvilsa ___ Python tracker

[issue35005] argparse should accept json and yaml argument types

2018-10-18 Thread Braden Groom
Braden Groom added the comment: I agree with Paul. This is probably simple enough for applications to implement. It also doesn't make sense to add either of these if the precedent was set by rejecting DateTime previously. -- ___ Python tracker

[issue35005] argparse should accept json and yaml argument types

2018-10-18 Thread paul j3
paul j3 added the comment: This kind of file read can be done just as easily after parsing. For example using the function in my previous post: In [127]: parser = argparse.ArgumentParser() In [128]: parser.add_argument('-d','--data'); In [129]: args = parser.parse_args(['-d','@foo.json'])

[issue35005] argparse should accept json and yaml argument types

2018-10-18 Thread Bob Ippolito
Bob Ippolito added the comment: I don't think that this has anything in particular to do with the json module, at least it certainly shouldn't need any additional functionality from there. YAML parsing isn't available in the stdlib last I checked, so that is probably not really up for

[issue35005] argparse should accept json and yaml argument types

2018-10-18 Thread paul j3
paul j3 added the comment: Adding a new 'type' function or factor is certainly possible, and probably will be free of backward compatibility issues. But so far no other custom type has been added to argparse. https://bugs.python.org/issue23884 - rejects adding a DateTime class

[issue35005] argparse should accept json and yaml argument types

2018-10-18 Thread Braden Groom
Braden Groom added the comment: I could try adding JSON and YAML argument types if that's what we want to do. -- nosy: +bradengroom ___ Python tracker ___

[issue35005] argparse should accept json and yaml argument types

2018-10-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: Bob, do you prefer the current arrange where the user needs to write their own "type" function to handle JSON and YAML, or would you like to add this as a built-in option? -- assignee: -> bob.ippolito nosy: +bob.ippolito, rhettinger

[issue35005] argparse should accept json and yaml argument types

2018-10-17 Thread paul j3
paul j3 added the comment: If I define a 'type' function like: def readdata(astr): if astr.startswith('@'): with open(astr[1:], 'r') as f: d = json.load(f) return d else: return astr I can use it to load a json file, or use the string directly:

[issue35005] argparse should accept json and yaml argument types

2018-10-17 Thread Robert Benson
Robert Benson added the comment: What I'm talking about is reading a single arg (of a dictionary or collection type) that can be split across multiple lines, rather than a single line containing multiple args My motivation was that reading args from a file should behave in a manner similar

[issue35005] argparse should accept json and yaml argument types

2018-10-17 Thread paul j3
paul j3 added the comment: The results of reading one of these @-prefix files are just spliced into the `argv` list before it is parsed. This is done early in the parsing method, in the _read_args_from_files method. The documentation illustrates how this file reading can be modified to

[issue35005] argparse should accept json and yaml argument types

2018-10-16 Thread Zachary Ware
Change by Zachary Ware : -- nosy: +bethard, paul.j3 versions: +Python 3.8 ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue35005] argparse should accept json and yaml argument types

2018-10-16 Thread Robert Benson
New submission from Robert Benson : Using `argparse`, I wanted to create an argument that was a JSON dictionary. I found that using this in combination with the `fromfile_prefix_args` keyword argument, that the parser assumes that each argument provided in the file must be on a single line.

[issue35005] argparse should accept json and yaml argument types

2018-10-16 Thread Robert Benson
Change by Robert Benson : -- versions: -Python 2.7 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue35005] argparse should accept json and yaml argument types

2018-10-16 Thread Robert Benson
Change by Robert Benson : -- components: Library (Lib) nosy: derelbenkoenig priority: normal severity: normal status: open title: argparse should accept json and yaml argument types type: enhancement ___ Python tracker

[issue35005] argparse should accept json and yaml argument types

2018-10-16 Thread Robert Benson
Change by Robert Benson : -- versions: +Python 2.7 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: