14 Feb
2013
14 Feb
'13
5:34 a.m.
On 14/02/2013 12:57am, Jan Kaliszewski wrote:
and maybe also:
class Color(Enum): # 0 1 2 3 RED, GREEN, BLUE, YELLOW, *end = seq()
class Color(Enum): # 3 4 5 6 RED, GREEN, BLUE, YELLOW, *end = seq(3)
class Flag(Enum): # 1 2 4 8 16 FOO, BAR, BAZ, BOO, SPAM, *end = flags()
(yes, it *is* possible to implement it without playing with stack frames...)
Are seq and flags infinite generators/iterators? If so then this won't work because end will be a *list* containing the contents of the tail of the iterator.
def gen(): ... i = 0 ... while True: ... yield i ... i += 1 ... a, b, *end = gen()
-- Richard