Код: Выделить всё
>>> for a in [1]: pass
...
>>> a
1
Код: Выделить всё
>>> class Obj(object): pass
...
>>> obj = Obj()
>>> for obj.b in [1]: pass
...
>>> obj.b
1
Код: Выделить всё
>>> for Obj().c in [1]: pass
...
Код: Выделить всё
>>> for (True and obj.d) in [1]: pass
...
File "", line 1
SyntaxError: can't assign to operator
Код: Выделить всё
>>> for (True and obj).e in [1]: pass
...
>>> obj.e
1
Код: Выделить всё
>>> for {}['f'] in [1]: pass
...
Подробнее здесь: https://stackoverflow.com/questions/395 ... ions-legal
Мобильная версия