python-fire
python-fire copied to clipboard
Everything after the `#` character gets stripped down from string argument
This is pretty self-explanatory:
> python -c 'import fire; fire.Fire(lambda x: print(repr(x)))' 'qgm#123'
'qgm'
Isn't this the shell interpreting it as a comment? Have you tried breaking out the comment symbol? qgm\#123
doesn't help much:
> python -c 'import fire; fire.Fire(lambda x: print(repr(x)))' 'qgm\#123'
'qgm\\#123'
> python -c 'import fire; fire.Fire(lambda x: print(repr(x)))' "qgm\#123"
'qgm\\#123'
It seems intentional currently. It's because the ast library is used to interpret the argument as a literal instead of a string. Can you try wrapping your argument in double and single quotes like the first test case here?
https://github.com/google/python-fire/blob/master/fire/parser_test.py lines 120-123:
def testDefaultParseValueComments(self):
self.assertEqual(parser.DefaultParseValue('"0#comments"'), '0#comments')
# Comments are stripped. This behavior may change in the future.
self.assertEqual(parser.DefaultParseValue('0#comments'), 0)