On Tue, Nov 30, 2021 at 4:39 AM Christopher Barker wrote:
>
>
>
> On Mon, Nov 29, 2021 at 2:12 AM Steven D'Aprano wrote:
>
>> Since most iterators don't have many methods, it's not clear to me that
>> iterators are even a little bit relevant.
>
>
> I think you just answered your own question.
>
>
On Mon, Nov 29, 2021 at 2:12 AM Steven D'Aprano wrote:
Since most iterators don't have many methods, it's not clear to me that
> iterators are even a little bit relevant.
I think you just answered your own question.
Since iterators in general don’t have methods, they can not be chained. I
beli
Andrew Barnert via Python-ideas writes:
...
Is there any commonly used or even imaginable useful type that uses
them in weirder ways than set and float (which are both partially
ordered) or np? array (where they aren’t even Boolean-values)?
I've had occasion (a class for outcomes in two-player ga
On Mon, Nov 29, 2021 at 08:44:00AM -0500, David Mertz, Ph.D. wrote:
> On Mon, Nov 29, 2021 at 5:15 AM Steven D'Aprano wrote:
>
> > - the method modifies the object in place, and returns self;
> > - versus the method returns a new, modified, copy of the object.
> > Pandas uses the first style (I t
On Mon, Nov 29, 2021 at 5:15 AM Steven D'Aprano wrote:
> - the method modifies the object in place, and returns self;
> - versus the method returns a new, modified, copy of the object.
> Pandas uses the first style (I think; corrections welcome). Strings use
> the second, because they have no cho
Steven D'Aprano writes:
> And yet it is indisputable that chained methods are useful even for
> methods which modify the object they work on. Look at pandas:
Guido disputed that it was useful *enough*. My point was advice to
the proponent to get his proposal adopted (despite the fact that I
p
Steven D'Aprano wrote:
> Does anyone know what builtin or stdlib objects iterators fail to
> implement `__iter__`? I haven't been able to find any -- all the obvious
> examples do (map, filter, reversed, zip, generators, list iterators,
> set iterators, etc).
Could it possibly be... the async it
On Sat, Nov 27, 2021 at 08:50:37PM +0900, Stephen J. Turnbull wrote:
> The thing is, the reason such a module is needed at all is that Guido
> decided ages ago that mutating methods should return None, and in
> particular they don't return self.
>
> I'm not sure why he did that, you'd have to ask
On Sun, Nov 28, 2021 at 05:28:58PM +, Evpok Padding wrote:
> Hi,
>
> All apologies if it has been clarified earlier, but if you dislike nested
> method calls what is wrong with operating on generators as in
>
> ```pycon
> >>> itr = (i**2 for i in range(8))
> >>> itr = (i-1 for i in itr if i >
On Sun, Nov 28, 2021 at 10:35:34PM -0800, Christopher Barker wrote:
> Of course, Python being Python, if in a given use case, you don’t need
> __iter__, you don’t have to have it.
[cynicism=on]
If you think your iterator doesn't need `__iter__`, just wait, and you
will find that it does.
[cynic
On Sun, Nov 28, 2021 at 09:33:17PM -0800, Paul Bryan wrote:
> 1. Noted: Python's for statement will happily iterate over an object
> that only implements __next__.
That is not correct.
>>> class C(object):
... def __next__(self):
... return 1
...
>>> for i in C():
... print(i
On Mon, Nov 29, 2021 at 12:11:43AM -0500, David Mertz, Ph.D. wrote:
> On Sun, Nov 28, 2021, 11:43 PM Paul Bryan wrote:
>
> > According to https://docs.python.org/3/glossary.html#term-iterator and
> > https://docs.python.org/3/library/stdtypes.html#typeiter, iterators must
> > implement the __iter
12 matches
Mail list logo