Movatterモバイル変換
[0]ホーム
Syntax error [was: Installed modules list?]
Steven D. Majewskisdm7g at Virginia.EDU
Fri Apr 20 11:58:19 EDT 2001
On Tue, 17 Apr 2001, John J. Lee wrote:> I was going to suggest a find command, if you're on unix, but then I> discovered I didn't understand python syntax:>> $ echo `python -c 'for d in [1,2]: print d'`>> works, while>> $ echo `python -c 'import sys; for d in [1,2]: print d'`>> doesn't -- it's a SyntaxError.>> Why?>Interesting.Also:>>> print 1; print 2; if [1]: print 3 File "<stdin>", line 1 print 1; print 2; if [1]: print 3 ^SyntaxError: invalid syntaxI haven't looked at the actual grammar in quite a while, but I'mguessing that there is a bit of an overgeneralization in the rulesto prevent compound statements like: >>> for x in [1,0,2]: if x : print x File "<stdin>", line 1 for x in [1,0,2]: if x : print x ^SyntaxError: invalid syntaxwhich are definitely disallowed. -- Steve Majewski
More information about the Python-listmailing list
[8]ページ先頭