Re: [Tutor] __iter__: one obvious way to do it

2010-03-07 Thread Hugo Arts
On Sun, Mar 7, 2010 at 5:37 PM, Steven D'Aprano wrote: >> "There should be one-- and preferably only one --obvious way to do >> it" http://www.python.org/dev/peps/pep-0020/ > > This doesn't mean that there should be *only* one way to do something. > It means that the should be one OBVIOUS way to d

Re: [Tutor] __iter__: one obvious way to do it

2010-03-07 Thread Steven D'Aprano
On Mon, 8 Mar 2010 02:07:41 am spir wrote: > [sorry, forgot the code] > > Hello, > > Below 6 working way to implement __iter__ for a container here > simulated with a plain inner list. Sure, the example is a bit > artificial ;-) > 1. __iter__ returns a generator _expression_ > def __iter__(sel

[Tutor] __iter__: one obvious way to do it

2010-03-07 Thread spir
[sorry, forgot the code] Hello, Below 6 working way to implement __iter__ for a container here simulated with a plain inner list. Sure, the example is a bit artificial ;-) 1. __iter__ returns a generator _expression_ 2. __iter__ *is* a generator 3. __iter__ returns a generator (this one is a

[Tutor] __iter__: one obvious way to do it

2010-03-07 Thread spir
Hello, Below 6 working way to implement __iter__ for a container here simulated with a plain inner list. Sure, the example is a bit artificial ;-) 1. __iter__ returns a generator _expression_ 2. __iter__ *is* a generator 3. __iter__ returns a generator (this one is a bit weird, i guess) 4. __