Supporting list()

Skip Montanaro skip at
Mon Dec 17 15:33:25 CET 2012

What method(s) does a class have to support to properly emulate a container
which supports turning it into a list?  For example:

  class Foo:

  f = Foo()
  print list(f)

Is it just __iter__() and next()?  (I'm still using 2.4 and 2.7.)



More information about the Python-list mailing list