I am completely stuck at mixing Python with Bash and it is really tough on me.
I know that using double vs single quotes in Bash depends on your intention to use variables, escapes and special characters.
I also know, that using double vs single quotes in Python is matter of taste mostly and PEP8 also confirms this.
But what if I want to use Python snippet inside Bash like this? It works either way.
#!/bin/bash
arg3="something special"
python << END
import functions;
print functions.do_smth('$arg', '$arg2')
print len("$arg3");
END
Does Python or Bash rules apply for the quotes in the above snippet?
Is it different from such allocation of Python code?
python -c "import functions; print functions.do_smth('$arg', '$arg2'); print len("$arg3");"
Does it matter for quoting when I use 1st or 2nd variant? Does it matter if I pass variable to function or simply use it?
python -c "print 'great program eh'"
python -c "import special; do_smth_special_with('great program eh')"
A have completely no idea of the differences between all these use-cases!
Especially many problems I face when I should pass JSON output as variable (which also has goddamn quotes and escapes!) from Bash to Python function.
Really need thorough explanation here.