Re: Help on for loop understanding

2015-12-08 Thread Robert
On Monday, December 7, 2015 at 10:24:09 PM UTC-5, Chris Angelico wrote: > On Tue, Dec 8, 2015 at 1:36 PM, Erik wrote: > > So, you can write your class's iterator to do anything that makes sense when > > someone says "for i in myclassinstance:". > > > > If your class is a subclass of a class ("is-a

Re: Help on for loop understanding

2015-12-07 Thread Chris Angelico
On Tue, Dec 8, 2015 at 1:36 PM, Erik wrote: > So, you can write your class's iterator to do anything that makes sense when > someone says "for i in myclassinstance:". > > If your class is a subclass of a class ("is-a") that already has a defined > iterator (such as a list or a dict) and the behavi

Re: Help on for loop understanding

2015-12-07 Thread Erik
On 08/12/15 01:50, Robert wrote: One example, see below please, is in the above mentioned link. I don't see the purpose of the example. OK, so there are two parts to this. The first, is "how do I iterate over something". The answer to that is using "for" or using "iter()" followed by zero or

Re: Help on for loop understanding

2015-12-07 Thread Robert
On Monday, December 7, 2015 at 8:39:48 PM UTC-5, Robert wrote: > On Monday, December 7, 2015 at 8:32:30 PM UTC-5, Robert wrote: > > On Monday, December 7, 2015 at 8:14:46 PM UTC-5, Robin Koch wrote: > > > Am 08.12.2015 um 02:05 schrieb Robert: > > > > Hi, > > > > When I learn for loop with below li

Re: Help on for loop understanding

2015-12-07 Thread Erik
Hi Robert, On 08/12/15 01:39, Robert wrote: I don't find a way to show __next__ yet. Can we explicitly get the iterator for a list? Thanks, Excuse me. I find it as the following: xx.__iter__().next Out[16]: xx.__iter__().next() Out[17]: 1 Robin has told you how things work under the hood

Re: Help on for loop understanding

2015-12-07 Thread Robert
On Monday, December 7, 2015 at 8:32:30 PM UTC-5, Robert wrote: > On Monday, December 7, 2015 at 8:14:46 PM UTC-5, Robin Koch wrote: > > Am 08.12.2015 um 02:05 schrieb Robert: > > > Hi, > > > When I learn for loop with below link: > > > > > > http://www.shutupandship.com/2012/01/understanding-python

Re: Help on for loop understanding

2015-12-07 Thread Robert
On Monday, December 7, 2015 at 8:14:46 PM UTC-5, Robin Koch wrote: > Am 08.12.2015 um 02:05 schrieb Robert: > > Hi, > > When I learn for loop with below link: > > > > http://www.shutupandship.com/2012/01/understanding-python-iterables-and.html > > > > it has such explanation: > > > > \ > >

Re: Help on for loop understanding

2015-12-07 Thread Robin Koch
Am 08.12.2015 um 02:05 schrieb Robert: Hi, When I learn for loop with below link: http://www.shutupandship.com/2012/01/understanding-python-iterables-and.html it has such explanation: \ for loop under the hood First let's look at the for loop under the hood. When Python executes the

Help on for loop understanding

2015-12-07 Thread Robert
Hi, When I learn for loop with below link: http://www.shutupandship.com/2012/01/understanding-python-iterables-and.html it has such explanation: \ for loop under the hood First let's look at the for loop under the hood. When Python executes the for loop, it first invokes the __iter__()