Supporting list()

Skip Montanaro skip at pobox.com
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:
    pass

  f = Foo()
  print list(f)

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

Thx,

Skip






More information about the Python-list mailing list