python -c strangeness

M

Miki Tebeka

Hello All,

Can you explain why:
[09:06] - adp86: python -c 'import sys; print 1'
1
[09:10] - adp86: python -c 'for i in range(3): print i'
0
1
2
[09:10] - adp86: python -c 'import sys; for i in range(3): print i'
File "<string>", line 1
import sys; for i in range(3): print i
^
SyntaxError: invalid syntax


Thanks.
Miki
 
B

Brian Gough

Miki Tebeka said:
[09:10] - adp86: python -c 'import sys; for i in range(3): print i'
File "<string>", line 1
import sys; for i in range(3): print i
^
SyntaxError: invalid syntax

Simple statements can be separated with a semicolon, but a compound
statement (e.g "for") must begin on a new line. See the language
reference manual for the full grammar of Python.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,197
Messages
2,571,040
Members
47,634
Latest member
RonnyBoelk

Latest Threads

Top