ahhh - klar! danke
Die Suche ergab 2 Treffer
- Sonntag 30. September 2012, 18:45
- Forum: Allgemeine Fragen
- Thema: eval und lambda
- Antworten: 2
- Zugriffe: 774
- Sonntag 30. September 2012, 18:26
- Forum: Allgemeine Fragen
- Thema: eval und lambda
- Antworten: 2
- Zugriffe: 774
eval und lambda
Hallo,
ich bin über eine Sache gestolpert, von der ich nicht weiß, warum sich Python so verhält:
>>> 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 ...
ich bin über eine Sache gestolpert, von der ich nicht weiß, warum sich Python so verhält:
>>> 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 ...
