This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author derelbenkoenig
Recipients bethard, derelbenkoenig, paul.j3
Date 2018-10-17.13:54:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1539784497.67.0.788709270274.issue35005@psf.upfronthosting.co.za>
In-reply-to
Content
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 to other command-line utilities, such as the `-d` option for `curl` and the `-e` option for `ansible`. These take the entire file you give it and store it as one dictionary or object, not by merging it with the rest of the namespace but by taking the dictionary as the value of just that arg. So:

argument_parser.add_argument("-d", "--data", type=argparse.JsonType)  # just for example

if I call the program with `--data @foo.json`
I want argument_parser.parse_args().data to be the dict that is in foo.json, whether foo.json is pretty-printed or not.

I haven't done an exhaustive search of StackOverflow, but seeing a couple top answers indicated that this was not readily available without the user at least having to call `json.loads` on a string argument themselves, when it seems logical that it would be built into the library to parse the json into a dictionary
History
Date User Action Args
2018-10-17 13:54:57derelbenkoenigsetrecipients: + derelbenkoenig, bethard, paul.j3
2018-10-17 13:54:57derelbenkoenigsetmessageid: <1539784497.67.0.788709270274.issue35005@psf.upfronthosting.co.za>
2018-10-17 13:54:57derelbenkoeniglinkissue35005 messages
2018-10-17 13:54:57derelbenkoenigcreate