medmond919 icon

Untitled

medmond919 | PRO | 05/13/19 05:55:30 PM UTC | 0 ⭐ | 282 👁️ | Never ⏰ | []
Python |

260 B

|

None

|

0 👍

/

0 👎

class Foo():
    a = 1
    b = 2
    c = 42
    d = ['hello', 'world']
 
    def __iter__(self):
        yield self.a
        yield self.b
        yield self.c
        yield from self.d
 
 
f = Foo()
for x in f:
    print(x)
 
# Should print the following:
# 1
# 2
# 42
# 'hello'
# 'world'

Comments