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
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
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.
>
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
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
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
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
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