Message383396
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 what I have:
import argparse
import re
class ArgumentParserCustom(argparse.ArgumentParser):
def convert_arg_line_to_args(self, arg_line):
if re.match(r'(\s+)?#', arg_line): # Look for any number of whitespace characters up to a `#` character
return ['']
else:
return [arg_line]
If I return [''], I get:
"error: unrecognized arguments:".
If I return [None], I get:
File "C:\Users\tnabelek\AppData\Local\Programs\Python\Python38-32\lib\argparse.py", line 1771, in parse_args
self.error(msg % ' '.join(argv))
TypeError: sequence item 0: expected str instance, NoneType found
Is there a better solution? |
|
Date |
User |
Action |
Args |
2020-12-19 19:50:55 | nabelekt | set | recipients:
+ nabelekt, rhettinger, eric.smith, paul.j3 |
2020-12-19 19:50:55 | nabelekt | set | messageid: <1608407455.09.0.507401847478.issue42677@roundup.psfhosted.org> |
2020-12-19 19:50:55 | nabelekt | link | issue42677 messages |
2020-12-19 19:50:54 | nabelekt | create | |
|