My code looks something like this in short:
class myClass(cmd.Cmd):
def do_myFunction(self, line):
print line+'!'
if __name__ == '__main__:
myClass().cmdloop()
When I use this on the command line and type a line with whitespace at the end, the cmdloop() readline seems to automatically strip them so instead of printing:
myline !
it prints:
myline!
Does anybody know a way around this? Thanks in advance!
Copying the answer from the comments in order to remove this question from the "Unanswered" filter:
"It looks like overriding the parseline()
method and doing essentially the same thing it does now but removing the calls to .strip()
will fix it without needing to rewrite the entire module..."
~ answer courtesy of Wooble
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With