Python Forum
python command (2 and 3) ignores extra -c arguments
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python command (2 and 3) ignores extra -c arguments
#1
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.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
Output:
(C:\Users\Craig\Anaconda2) C:\Users\Craig\Documents\t_games>python -c "print 'foo'; print 'bar'" foo bar
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
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.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
Geez; if you're putting \n's in the string to handle nesting, just make a dummy file and run it.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#5
what if i'm using -c because there is no writable file system available? can python(3) read a script from a pipe?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  f-string in command line arguments Skaperen 0 1,547 May-05-2020, 11:49 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020