[Tutor] P2PU Python Challenges

2011-02-05 Thread Corey Richardson
In my journeys across the face of the Internet, I found this: http://p2pu.org/general/python-challenges Not sure what it's really going to be, but any new programmers/people looking for something to do might be interested. I'm not quite sure how a class can be organised around a web riddle, but it

Re: [Tutor] making object iterable

2011-02-05 Thread Alex Hall
On 2/5/11, bob gailer wrote: > On 2/5/2011 2:46 PM, Alex Hall wrote: >> Hi all, >> I have a class which has a list as an attribute, meaning you must say >> something like: >> for result in obj.results: ... >> I want to make life a bit easier and let users just say: >> for result in obj: ... >> Her

Re: [Tutor] making object iterable

2011-02-05 Thread bob gailer
On 2/5/2011 2:46 PM, Alex Hall wrote: Hi all, I have a class which has a list as an attribute, meaning you must say something like: for result in obj.results: ... I want to make life a bit easier and let users just say: for result in obj: ... Here is what I have tried to make my class into an ite

Re: [Tutor] Roulette Unit Test Questions

2011-02-05 Thread Steven D'Aprano
Ben Ganzfried wrote: Hey, I'm having a lot of confusion getting the unit test working for one of my classes for the Roulette bot I'm working on and would greatly appreciate any advice or help. [...] Here is my Bin class: from Outcome import * class Bin: def __init__(self, *outcomes):

[Tutor] Roulette Unit Test Questions

2011-02-05 Thread Ben Ganzfried
Hey, I'm having a lot of confusion getting the unit test working for one of my classes for the Roulette bot I'm working on and would greatly appreciate any advice or help. Here is the description of what I am trying to do: http://homepage.mac.com/s_lott/books/oodesign/build-python/html/roulette/b

Re: [Tutor] making object iterable

2011-02-05 Thread Alex Hall
On 2/5/11, Siim Märtmaa wrote: > 2011/2/5 Alex Hall : >> Yes, I get the same thing. However, when you try to index, as in a[0], >> you have problems. Here are two lines from my program: >> for i in res: print i >> This works as expected, printing every object in res.results, just as I >> wanted. >

Re: [Tutor] making object iterable

2011-02-05 Thread Siim Märtmaa
2011/2/5 Alex Hall : > Yes, I get the same thing. However, when you try to index, as in a[0], > you have problems. Here are two lines from my program: > for i in res: print i > This works as expected, printing every object in res.results, just as I > wanted. > > for i in range(len(res)): print str

Re: [Tutor] making object iterable

2011-02-05 Thread Alex Hall
On 2/5/11, Peter Otten <__pete...@web.de> wrote: > Alex Hall wrote: > >> Hi all, >> I have a class which has a list as an attribute, meaning you must say >> something like: >> for result in obj.results: ... >> I want to make life a bit easier and let users just say: >> for result in obj: ... >> Her

Re: [Tutor] making object iterable

2011-02-05 Thread James Reynolds
You should probably read this section in the python tutorial: http://docs.python.org/tutorial/classes.html#iterators If you have any questions after that, I would suggest posting back here but that should cover it. On Sat, Feb 5, 2011 at 2:46 PM, Alex Hall wrote: > Hi all, > I have a class whi

Re: [Tutor] making object iterable

2011-02-05 Thread Peter Otten
Alex Hall wrote: > Hi all, > I have a class which has a list as an attribute, meaning you must say > something like: > for result in obj.results: ... > I want to make life a bit easier and let users just say: > for result in obj: ... > Here is what I have tried to make my class into an iterable on

[Tutor] making object iterable

2011-02-05 Thread Alex Hall
Hi all, I have a class which has a list as an attribute, meaning you must say something like: for result in obj.results: ... I want to make life a bit easier and let users just say: for result in obj: ... Here is what I have tried to make my class into an iterable one, yet I get an error saying tha