Seite 1 von 1

warum syntax error?

Verfasst: Sonntag 25. Februar 2007, 02:40
von Costi
bin irgendwie etwas werwirrt:

Code: Alles auswählen

>>> eval("""
...             
... def helo (arg):
...      print "helo world"
...            
... """)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<string>", line 3
    def helo (arg):
      ^
SyntaxError: invalid syntax
>>> 
wie soll ich das verstehen? *fassungslos*

Verfasst: Sonntag 25. Februar 2007, 02:45
von mq
eval ist nur dazu da, einzelne Ausdruecke auszuwerten. Wenn du "richtigen" Code ausfuehren willst, nimm exec. Damit funktioniert dein Code dann auch.

Verfasst: Sonntag 25. Februar 2007, 02:47
von Mr_Snede
Ohne Leerzeichen zwischen "helo" und "(arg):"
Und helo mit 2 "l" --> hello

Verfasst: Sonntag 25. Februar 2007, 02:55
von Costi
@lunar: stimmt, das ist glaub ich heute schon das 3. mal das du mich rettest :lol: :lol:

Verfasst: Sonntag 25. Februar 2007, 03:55
von Leonidas
Costi hat geschrieben:@lunar: stimmt, das ist glaub ich heute schon das 3. mal das du mich rettest :lol: :lol:
Ist zwar lumax, aber da es spät ist, sehen wir mal drüber hinweg ;)

Verfasst: Sonntag 25. Februar 2007, 09:29
von lunar
Costi hat geschrieben:@lunar: stimmt, das ist glaub ich heute schon das 3. mal das du mich rettest :lol: :lol:
komisch, das war mir gar nicht bewusst ;)

Edit: @Leonidas, Costi: Schlaft ihr eigentlich auch mal?

Verfasst: Sonntag 25. Februar 2007, 09:32
von birkenfeld
lunar hat geschrieben:Edit: @Leonidas, Costi: Schlaft ihr eigentlich auch mal?
Nur abwechselnd.