On Thu, Jan 23, 2014 at 7:43 PM, Steven D'Aprano wrote:
> Generators are a kind of function, which are special. You can't inherit
> from them:
I clarified my sloppy language in a reply. `__iter__` should be a
generator function, not a generator. A generator function uses `yield`
and `yield from`
On Thu, Jan 23, 2014 at 02:24:20PM -0500, Keith Winston wrote:
> On Thu, Jan 23, 2014 at 7:05 AM, eryksun wrote:
> > Generally you'll make `__iter__` a generator, so you don't have to
> > worry about implementing `__next__`. Also, the built-in function
> > `next` was added in 2.6, so you don't hav
On Thu, Jan 23, 2014 at 02:18:33PM -0500, Keith Winston wrote:
> On Thu, Jan 23, 2014 at 1:36 PM, Devin Jeanpierre
> wrote:
>
> > Again, nothing was incorrect about the example. Every iterator has
> > this "problem".
>
> Hmmm. Well, here's what he actually said about that example, since I
> don'
On Thu, Jan 23, 2014 at 2:24 PM, Keith Winston wrote:
> On Thu, Jan 23, 2014 at 7:05 AM, eryksun wrote:
>> Generally you'll make `__iter__` a generator, so you don't have to
>> worry about implementing `__next__`. Also, the built-in function
>> `next` was added in 2.6, so you don't have to worry
On Thu, Jan 23, 2014 at 7:05 AM, eryksun wrote:
> Generally you'll make `__iter__` a generator, so you don't have to
> worry about implementing `__next__`. Also, the built-in function
> `next` was added in 2.6, so you don't have to worry about the method
> name difference between 2.x and 3.x, eith
On Thu, Jan 23, 2014 at 1:36 PM, Devin Jeanpierre
wrote:
> Again, nothing was incorrect about the example. Every iterator has
> this "problem".
Hmmm. Well, here's what he actually said about that example, since I
don't think I've explained correctly:
*
With iterators, one thing to watch out
On Thu, Jan 23, 2014 at 7:50 AM, Keith Winston wrote:
> Yes, the exercise was about implementing an iter incorrectly, to see
> the difference. But I don't really understand your second point: when
> I changed the method name, it worked...?
Again, nothing was incorrect about the example. Every ite
On Thu, Jan 23, 2014 at 10:50 AM, Keith Winston wrote:
> On Thu, Jan 23, 2014 at 7:05 AM, eryksun wrote:
>> Generally you'll make `__iter__` a generator, so you don't have to
>> worry about implementing `__next__`. Also, the built-in function
>> `next` was added in 2.6, so you don't have to worry
On Thu, Jan 23, 2014 at 7:05 AM, eryksun wrote:
> Generally you'll make `__iter__` a generator, so you don't have to
> worry about implementing `__next__`. Also, the built-in function
> `next` was added in 2.6, so you don't have to worry about the method
> name difference between 2.x and 3.x, eith
On Thu, Jan 23, 2014 at 3:09 AM, Peter Otten <__pete...@web.de> wrote:
> But why not install Python 2.7 on your machine, too? That would allow you
> run the examples as is.
Y'know, it's funny, but I have 2.7 installed. But since I was almost
certain it was a 2to3 kind of problem, I wanted to figur
On Thu, Jan 23, 2014 at 5:56 AM, spir wrote:
> Yes, but that way others learn as well :-) And many people prefere learning
> via human interaction then dealing with arid texts
Well, you caught me. I do run out of steam just plowing through
lessons & such: it really helps to have actual humans to
On Thu, Jan 23, 2014 at 12:53 AM, Keith Winston wrote:
>> in Python 3, it should be __next__, not next.
>
> Ah! That's it! Thanks!!!
Generally you'll make `__iter__` a generator, so you don't have to
worry about implementing `__next__`. Also, the built-in function
`next` was added in 2.6, so you
On 01/23/2014 06:53 AM, Keith Winston wrote:
I suppose I should practice running my questions
on old code through 2to3 before I pester the Tutor list, since that's
probably also a good way to learn the differences.
Yes, but that way others learn as well :-) And many people prefere learning via
Keith Winston wrote:
> On Thu, Jan 23, 2014 at 12:21 AM, Devin Jeanpierre
> wrote:
>> in Python 3, it should be __next__, not next.
>
> Ah! That's it! Thanks!!!
>
>> I'd suggest staying away from any old blog posts and articles, unless
>> you'd care to learn Python 2.x instead of 3.x. ;)
>
> Y
On Thu, Jan 23, 2014 at 12:21 AM, Devin Jeanpierre
wrote:
> in Python 3, it should be __next__, not next.
Ah! That's it! Thanks!!!
> I'd suggest staying away from any old blog posts and articles, unless
> you'd care to learn Python 2.x instead of 3.x. ;)
Yeah, but this is a REALLY GOOD resource
On Wed, Jan 22, 2014 at 8:57 PM, Keith Winston wrote:
> I'm working my way through some of the examples in
>
> http://ivory.idyll.org/articles/advanced-swc/#list-comprehensions
>
> And tried this one:
>
class MyTrickyIter:
> ... def __init__(self, thelist):
> ... self.thelist = thelist
I'm working my way through some of the examples in
http://ivory.idyll.org/articles/advanced-swc/#list-comprehensions
And tried this one:
>>> class MyTrickyIter:
... def __init__(self, thelist):
... self.thelist = thelist
... self.index = -1
...
... def __iter__(self):
... retu
17 matches
Mail list logo