On 29 December 2010 14:46, Michael Foord fuzzyman@voidspace.org.uk wrote:
That would be great. I did worry that changing the output would be backwards incompatible with code that shells out to Python using "-c", so a different command line option would be great. So long as it works with multiple statements (semi-colon separated) like the current "-c" behaviour.
I use this trick for finding the source code of Python modules:
$ python -c "import os;print os.__file__[:-1]" /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/os.py
I'd suggest allowing multiple -c and -e options, interspersed as needed, with each being treated as a separate line, so you could do
$ python -c "import os" -e "os.__file__[:-1]"
(Actually, I'd find "python -c stmt1 -c stmt2" mildly more readable than "python -c "stmt1; stmt2"" so that's another (equally small) benefit to me...)
Paul.
PS I take Antoine's point that it's a small benefit, but like you, I find myself needing it quite a lot in practice :-)