Python Forum
option -c and semicolon not working as expected
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
option -c and semicolon not working as expected
#1
it was my understanding that a ";" character could be used to separate lines in the string given to the -c option of the python command. but i am finding that in many cases it does not work. a newline byte seems to work as encoded by bash in the 2nd example in this output.
Output:
lt1a/forums/3 /home/forums 4> /usr/bin/python3.8 -c 'for x in range(4):; print(x)' File "<string>", line 1 for x in range(4):; print(x) ^ SyntaxError: invalid syntax lt1a/forums/3 /home/forums 5> /usr/bin/python3.8 -c $'for x in range(4):\n print(x)' 0 1 2 3 lt1a/forums/3 /home/forums 6>
can someone tell me what i should be using for this case that the 1st example shows?
Tradition is peer pressure from dead people

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


Messages In This Thread
option -c and semicolon not working as expected - by Skaperen - Aug-11-2022, 10:04 PM

Forum Jump:

User Panel Messages

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