◐ Shell
clean mode source ↗

Issue 6052: for-loop doesn't work with -c

Issue6052

Created on 2009-05-18 10:28 by exe, last changed 2022-04-11 14:56 by admin. 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
2022-04-11 14:56:49adminsetgithub: 50302
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