classification
Title: for-loop doesn't work with -c
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.0, Python 3.1, Python 3.2, Python 2.7, Python 2.6, Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: exe, r.david.murray
Priority: normal Keywords:

Created on 2009-05-18 10:28 by exe, last changed 2009-05-18 16:40 by r.david.murray. This issue is now closed.

Messages (2)
msg88024 - (view) Author: Kandalintsev Alexandre (exe) Date: 2009-05-18 10:28
Hello!

I found this problem:

$ python3 -c 'import sys; for line in sys.stdout: pass'
  File "<string>", line 1
    import sys; for line in sys.stdout: pass
                  ^
SyntaxError: invalid syntax

Without import-statement this work great. Also code 'import sys; pass' 
works too.
msg88035 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-05-18 16:40
The error message is correct: your example is invalid python code.  Try
it in a file and you will get the same error message.  Check the
documentation of the '-c' option to learn how to correctly code your
example.
History
Date User Action Args
2009-05-18 16:40:41r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg88035

resolution: not a bug
stage: resolved
2009-05-18 10:28:59execreate