ich bin über eine Sache gestolpert, von der ich nicht weiß, warum sich Python so verhält:
Code: Alles auswählen
>>> z=lambda x: x>0 and x or 0.; sum([z(i) for i in [-100,0,100,200]])
300.0
>>> eval("z=lambda x: x>0 and x or 0.; sum([z(i) for i in [-100,0,100,200]])")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1
z=lambda x: x>0 and x or 0.; sum([z(i) for i in [-100,0,100,200]])
^
SyntaxError: invalid syntax
al