[issue42677] Support comments in argparse fromfile_prefix_chars files

2020-12-19 Thread Thomas Nabelek
Thomas Nabelek added the comment: For anyone else, here is my implementation. I decided not to do anything to support comments on the same lines as arguments. import argparse import re # Override argparse's convert_arg_line_to_args method to allow for comments and empty lines class Argume

[issue42677] Support comments in argparse fromfile_prefix_chars files

2020-12-19 Thread Thomas Nabelek
Thomas Nabelek added the comment: Oh, yes, returning [] does work. Thanks guys. -- ___ Python tracker ___ ___ Python-bugs-list mail

[issue42677] Support comments in argparse fromfile_prefix_chars files

2020-12-19 Thread Eric V. Smith
Eric V. Smith added the comment: Have you tried returning an empty list? -- ___ Python tracker ___ ___ Python-bugs-list mailing lis

[issue42677] Support comments in argparse fromfile_prefix_chars files

2020-12-19 Thread Thomas Nabelek
Thomas Nabelek added the comment: While overloading convert_arg_line_to_args may work, I think that @file reading is kind of the odd ball out in not recognizing '#' as the beginning of a comment. Besides, I'm not sure that overloading just convert_arg_line_to_args is sufficient. Here is wha

[issue42677] Support comments in argparse fromfile_prefix_chars files

2020-12-18 Thread paul j3
paul j3 added the comment: https://docs.python.org/3/library/argparse.html#customizing-file-parsing in the docs describes how to customize the @file reading. This particular extension handles several strings on a line, but that's not the limit of what you could do. You can also read a file

[issue42677] Support comments in argparse fromfile_prefix_chars files

2020-12-18 Thread Eric V. Smith
Eric V. Smith added the comment: I think you could achieve this by overriding convert_arg_line_to_args. If this were baked in to argparse, there would need to be an argument to argparse.ArgumentParser to turn on this behavior, with the default being to not support comments. That's because en

[issue42677] Support comments in argparse fromfile_prefix_chars files

2020-12-18 Thread Thomas Nabelek
New submission from Thomas Nabelek : For input argument files, specified with the fromfile_prefix_chars argument to argparse.ArgumentParser, argparse should ignore lines beginning with '#' so that comments can be used in those files. -- components: Library (Lib) messages: 383321 nosy: