Python Forum

Full Version: python command (2 and 3) ignores extra -c arguments
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
both the python3 and python2 commands (at least in Ubuntu 18.04) takes (or ignores) an extra -c argument and only executes the first one. it should give an error message about the extras if it is wrong to use them.
Output:
lt2a/forums /home/forums 13> python3 -c "print('foo')" -c "print('bar')" foo lt2a/forums /home/forums 14> python2 -c "print('foo')" -c "print('bar')" foo lt2a/forums /home/forums 15>
i was hoping it would be an easy way to give it another "line" of code to run.
Output:
(C:\Users\Craig\Anaconda2) C:\Users\Craig\Documents\t_games>python -c "print 'foo'; print 'bar'" foo bar
i tried it with ; but it would not work with just any code. nested stuff was not working. it works when the string -c gets has real \n.
Geez; if you're putting \n's in the string to handle nesting, just make a dummy file and run it.
what if i'm using -c because there is no writable file system available? can python(3) read a script from a pipe?