On 03/04/2016 17:28, Ethan Furman wrote:
On 04/02/2016 11:58 PM, Marko Rauhamaa wrote:
Stephen Hansen :
I'm pretty sure that 99+% of the non-stdlib code out there is also
completely inaccessible (or at least inconveniently accessible) to
Stephen as well.
http://nullege.com/codes/search?cq=r
On 04/02/2016 11:58 PM, Marko Rauhamaa wrote:
Stephen Hansen :
On Sat, Apr 2, 2016, at 02:40 PM, Marko Rauhamaa wrote:
That's why I was looking for counterexamples in the standard library
This entire bent of an argument seems flawed to me.
The standard library has never been a beacon for be
On Sun, Apr 3, 2016 at 4:58 PM, Marko Rauhamaa wrote:
>> That a use exists in the standard library, or that one does not,
>> doesn't really tell you anything meaningful about Python itself or
>> good practices with the language. The standard library is under
>> uniquely conservative constraints th
On Sun, Apr 3, 2016 at 4:43 PM, Stephen Hansen wrote:
> The stdlib exists as a bastion of stability above all else. Its
> standards aren't a reason to make a change (or, not to make a change,
> either). That doesn't mean its not useful to look at the standard
> library, but you should not enshrine
Stephen Hansen :
> On Sat, Apr 2, 2016, at 02:40 PM, Marko Rauhamaa wrote:
>> That's why I was looking for counterexamples in the standard library
>
> This entire bent of an argument seems flawed to me.
>
> The standard library has never been a beacon for best practices or
> idiomatic uses of Pyth
On Sat, Apr 2, 2016, at 02:40 PM, Marko Rauhamaa wrote:
> That's why I was looking for counterexamples in the standard library
This entire bent of an argument seems flawed to me.
The standard library has never been a beacon for best practices or
idiomatic uses of Python. That a use exists in the
On Sun, 3 Apr 2016 02:43 pm, Steven D'Aprano wrote:
> If you personally don't see any advantage in this, so be it, but you might
> not be aware of the history of (x)range:
>
> Guido in 2001: "..."
Correction: these are not direct quotes, but paraphrases. My apologies for
any confusion.
--
Ste
On Sun, Apr 3, 2016, at 00:43, Steven D'Aprano wrote:
> If you personally don't see any advantage in this, so be it, but you
> might
> not be aware of the history of (x)range:
>
> Guido in 2001: "Nobody uses this extra functionality, and its buggy,
> let's
> get rid of it."
>
> https://www.python
On Sun, 3 Apr 2016 06:44 am, Marko Rauhamaa wrote:
> I don't have a problem with a list being a "reiterable." I only was
> surprised about range(), which I had thought to be a plain,
> down-to-earth iterator. There's barely any other practical use for a
> range, I believe.
I can understand that y
On Saturday, April 2, 2016 at 5:40:35 PM UTC-4, Marko Rauhamaa wrote:
> Chris Angelico :
>
> > On Sun, Apr 3, 2016 at 6:44 AM, Marko Rauhamaa wrote:
> >> I don't have a problem with a list being a "reiterable." I only was
> >> surprised about range(), which I had thought to be a plain,
> >> down-
Chris Angelico :
> On Sun, Apr 3, 2016 at 6:44 AM, Marko Rauhamaa wrote:
>> I don't have a problem with a list being a "reiterable." I only was
>> surprised about range(), which I had thought to be a plain,
>> down-to-earth iterator. There's barely any other practical use for a
>> range, I believ
On Sun, Apr 3, 2016 at 6:44 AM, Marko Rauhamaa wrote:
> I don't have a problem with a list being a "reiterable." I only was
> surprised about range(), which I had thought to be a plain,
> down-to-earth iterator. There's barely any other practical use for a
> range, I believe.
That's Blub's Parado
Ned Batchelder :
> This analogy illuminates an important point: a single iterable can have
> a number of active iterators working over it at once, just as a book can
> have a number of bookmarks in it at once.
>
> nums = [1, 2, 3]
> for i in nums:
> for j in nums:
> pri
On Friday, April 1, 2016 at 10:34:50 AM UTC-4, Marko Rauhamaa wrote:
> Chris Angelico :
>
> > *A range object is not an iterator.*
>
> We now have learned as much.
>
> However, doesn't that extra level of indirection seem like an odd
> choice?
I agree that it is surprising (and confusing) at fi
Steven D'Aprano :
> On Sat, 2 Apr 2016 07:14 am, Marko Rauhamaa wrote:
>> (Somehow, the difference between iterables and iterators is analogous
>> with the difference between C's arrays and pointers.)
>
> I don't understand this analogy. Can you explain please?
In numerous contexts,
T a[N]
a
On Sat, 2 Apr 2016 07:14 am, Marko Rauhamaa wrote:
> There's a bit of a cognitive dissonance between iterables and iterators.
> On the one hand, they behave identically in many contexts. On the other
> hand, the distinction is crucial in some special cases.
Iterable just means "something which ca
On 01/04/2016 21:44, Marko Rauhamaa wrote:
Rob Gaddi :
Marko Rauhamaa wrote:
There's a bit of a cognitive dissonance between iterables and iterators.
On the one hand, they behave identically in many contexts. On the other
hand, the distinction is crucial in some special cases.
You're missing
On 4/1/2016 4:14 PM, Marko Rauhamaa wrote:
There's a bit of a cognitive dissonance between iterables and iterators.
On the one hand, they behave identically in many contexts.
Because iterators *are* (a proper subset of) iterables This goes back
to pre-iterator days when for-loops worked on s
Rob Gaddi :
> Marko Rauhamaa wrote:
>> There's a bit of a cognitive dissonance between iterables and iterators.
>> On the one hand, they behave identically in many contexts. On the other
>> hand, the distinction is crucial in some special cases.
>
> You're missing a key point. All (well-behaved)
Marko Rauhamaa wrote:
> Erik :
>
>> On 01/04/16 15:34, Marko Rauhamaa wrote:
>>> Chris Angelico :
>>>
*A range object is not an iterator.*
>>>
>>> We now have learned as much.
>>>
>>> However, doesn't that extra level of indirection seem like an odd
>>> choice?
>>
>> [...]
>>
>> If you write
Erik :
> On 01/04/16 15:34, Marko Rauhamaa wrote:
>> Chris Angelico :
>>
>>> *A range object is not an iterator.*
>>
>> We now have learned as much.
>>
>> However, doesn't that extra level of indirection seem like an odd
>> choice?
>
> [...]
>
> If you write your own class which has an __iter__ me
On 01/04/16 15:34, Marko Rauhamaa wrote:
Chris Angelico :
*A range object is not an iterator.*
We now have learned as much.
However, doesn't that extra level of indirection seem like an odd
choice?
If you write your own class which has an __iter__ method, would you expect:
>>> o = MyCla
Chris Angelico :
> On Sat, Apr 2, 2016 at 1:34 AM, Marko Rauhamaa wrote:
>> However, doesn't that extra level of indirection seem like an odd
>> choice?
>
> No; a range object is an entity in itself. You can test if something's
> within the range:
>
5 in range(2,10)
> True
5 in range(2,
On Fri, Apr 1, 2016 at 8:42 AM, Random832 wrote:
> On Fri, Apr 1, 2016, at 09:24, Chris Angelico wrote:
>> It is an iterable. It is not a factory, as that implies that you call
>> it.
>
> I do have an objection to this statement. It's perfectly reasonable to
> describe the factory pattern as apply
On Sat, Apr 2, 2016 at 1:42 AM, Random832 wrote:
> On Fri, Apr 1, 2016, at 09:24, Chris Angelico wrote:
>> It is an iterable. It is not a factory, as that implies that you call
>> it.
>
> I do have an objection to this statement. It's perfectly reasonable to
> describe the factory pattern as apply
On Sat, Apr 2, 2016 at 1:34 AM, Marko Rauhamaa wrote:
> Chris Angelico :
>
>> *A range object is not an iterator.*
>
> We now have learned as much.
>
> However, doesn't that extra level of indirection seem like an odd
> choice?
No; a range object is an entity in itself. You can test if something'
Marko Rauhamaa writes:
> Chris Angelico wrote:
>
>> *A range object is not an iterator.*
>
> We now have learned as much.
>
> However, doesn't that extra level of indirection seem like an odd
> choice?
I think it's brilliant. The range object behaves like a tuple containing
the numbers in the rang
On Fri, Apr 1, 2016, at 09:24, Chris Angelico wrote:
> It is an iterable. It is not a factory, as that implies that you call
> it.
I do have an objection to this statement. It's perfectly reasonable to
describe the factory pattern as applying to objects on which you call a
method to return the new
On Fri, Apr 1, 2016, at 10:12, Marko Rauhamaa wrote:
> Yes, I realize it now. I had thought it was:
>
> def range(start, end=None, step=1):
> if end is None:
> start, end = 0, start
> i = start
> while step * (end - i) > 0:
> yield i
>
Chris Angelico :
> *A range object is not an iterator.*
We now have learned as much.
However, doesn't that extra level of indirection seem like an odd
choice?
Marko
--
https://mail.python.org/mailman/listinfo/python-list
Fabien :
> On 04/01/2016 03:26 PM, Steven D'Aprano wrote:
>> Incorrect. range is a lazy sequence.
>
> But how does range "know" that it has to start from scratch again?
The "for .. in" statement invokes the __iter__() method of the iterable
object to get an iterator (maybe via the builtin iter()
On Sat, Apr 2, 2016 at 1:16 AM, Fabien wrote:
> On 04/01/2016 03:26 PM, Steven D'Aprano wrote:
>>
>> Incorrect. range is a lazy sequence.
>
>
> But how does range "know" that it has to start from scratch again? As in
> this example:
>
> it = range(10)
> for i in it:
> if i >= 3:
> brea
Fabien writes:
> On 04/01/2016 03:26 PM, Steven D'Aprano wrote:
>> Incorrect. range is a lazy sequence.
>
> But how does range "know" that it has to start from scratch again? As
> in this example:
>
> it = range(10)
> for i in it:
> if i >= 3:
> break
> for i in it:
> # why does it
On 04/01/2016 03:26 PM, Steven D'Aprano wrote:
Incorrect. range is a lazy sequence.
But how does range "know" that it has to start from scratch again? As in
this example:
it = range(10)
for i in it:
if i >= 3:
break
for i in it:
# why does it start from zero again?
print(
Steven D'Aprano :
> On Sat, 2 Apr 2016 12:15 am, Marko Rauhamaa wrote:
>> Note to self: range(10) is an iterator factory, not an iterator.
>
> Incorrect. range is a lazy sequence.
Incorrect. You and I agree.
> You can think of range as equivalent to something close to this:
>
> class Range(objec
On Sat, 2 Apr 2016 12:15 am, Marko Rauhamaa wrote:
>
> This seems sane:
[...]
> This not so much:
>
> >>> it = range(10)
> >>> for i in it:
> ... if i >= 3:
> ... break
> ...
> >>> list(it)
> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>
> Note to self: range(10) is an it
On Sat, Apr 2, 2016 at 12:15 AM, Marko Rauhamaa wrote:
> Note to self: range(10) is an iterator factory, not an iterator.
It is an iterable. It is not a factory, as that implies that you call
it. It is an object which, when you ask it for an iterator, gives you
an iterator. That's called an itera
This seems sane:
>>> it = iter(range(10))
>>> for i in it:
... if i >= 3:
... break
...
>>> list(it)
[4, 5, 6, 7, 8, 9]
As does this:
>>> it = iter(list(range(10)))
>>> for i in it:
... if i >= 3:
... break
...
>>> list(it)
[4,
38 matches
Mail list logo