Using and Implementing iterators with classes such as linked lists
Duncan Booth
duncan at NOSPAMrcp.co.uk
Wed Dec 3 04:11:24 EST 2003
More information about the Python-list mailing list
Wed Dec 3 04:11:24 EST 2003
- Previous message (by thread): Python, xml, databases, ...
- Next message (by thread): Using and Implementing iterators with classes such as linkedlists
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
aahz at pythoncraft.com (Aahz) wrote in news:bqjh7n$of2$1 at panix3.panix.com: > In article <Xns94445A429CFEduncanrcpcouk at 127.0.0.1>, > Duncan Booth <duncan at rcp.co.uk> wrote: >> >>def __iter__(self): >> def iterate(current): >> while current.next is not None: >> next = current.next >> yield current >> current = next >> return iterate(self) > > Huh? Why the extra function and complexity? > > def __iter__(self): > current = self > while current is not None: > yield current > current = current.next Because I was asleep. -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
- Previous message (by thread): Python, xml, databases, ...
- Next message (by thread): Using and Implementing iterators with classes such as linkedlists
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list