Re: [Tutor] increment a counter inside generator

2013-03-14 Thread David Knupp
On Thu, 14 Mar 2013, Steven D'Aprano wrote: If you have some unknown, arbitrary iterable that doesn't support len(), then you can use the sum() trick: it = some_unknown_iterable() sum(1 for x in it) Yes, of course you are correct. This was my intention, but I chose an especially poorly contri

Re: [Tutor] increment a counter inside generator

2013-03-13 Thread David Knupp
On Wed, 13 Mar 2013, Oscar Benjamin wrote: (it's not actually a generator by the way) As Oscar points out, you're not working with a generator expression. The syntactical difference between a list comprehension and a generator expression is subtle. List comprehensions use square brackets, but

Re: [Tutor] Overriding a method in a class

2011-05-13 Thread David Knupp
I think the problem is this bit about overriding an object's internal method with one that is defined externally. My gut feeilng is that you'd now have to explicitly pass the object (i.e., self) as well as the string, i.e.: B.addstuff(B, "WXYZ") ...which seems clunky. I'm not familiar with t