1

I have a Python script that needs to accept the "greater than" character > as a command-line argument.

python myscript.py -f "VALUE>100"

However, even if I wrap that argument in double-quotes, python is still parsing that character as a redirect operator. I checked it through the Python debugger in VS Code and it shows that the > character and succeeding characters are not included in argv.

argv in VSCode python debugger

Is there a workaround for this? My OS is Windows and I'm using cmd.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
donfiguerres
  • 83
  • 1
  • 1
  • 5
  • Which shell are you using? – mkrieger1 Apr 08 '21 at 08:58
  • cmd. I'm in Windows – donfiguerres Apr 08 '21 at 09:01
  • This is a question about `cmd`, not a question about Python, then. I found [this](https://stackoverflow.com/questions/251557/escape-angle-brackets-in-a-windows-command-prompt) by putting `windows cmd escape greater-than` [into a search engine](https://duckduckgo.com/?q=windows+cmd+escape+greater-than), as the second result. Did you try anything similar? – Karl Knechtel Apr 08 '21 at 09:03
  • The ^ escape character worked! Thanks! The weird thing though is that wrapping it in double-quotes works for my other command-line tools but not with Python. – donfiguerres Apr 08 '21 at 09:09

0 Answers0