I’ve been learning and clearing up some misunderstandings with pythons sys.argv. When I was passing different characters from the command-line in bash I noticed:
script.py
import sys
def test(x):
return x
print test(sys.argv)
>>>python script.py [first, second, third]
Will print:
['script.py', '[first,', 'second,', 'third]']
and
>>>python script.py {first, second, third}
['script.py', '{first,','second,','third}']
But:
>>>python script.py (first,second,third)
bash: syntax error near unexpected token `('
Is this python or bash, maybe both? Any reason for it?
It’s bash; parens run a command chain in a subshell.
You will need to quote the parens if you want to use them in an argument.