On 25/07/2020 06:35, Random832 wrote:
On Tue, Jul 21, 2020, at 15:54, Terry Reedy wrote:
The transformers should be once-through iterators because they can be
passed once-through interators. I suppose one could make them iterables
and add an attribute 'pristine' set to True in __init__ and
On Fri, Jul 24, 2020, at 14:42, Chris Angelico wrote:
> And then someone will ask why you can't subscript a map object if the
> underlying object could be subscripted, etc, etc, etc. It's not meant
> to be a transparent layer over the object; it's just an iterator -
> basically equivalent to:
>
>
On Thu, Jul 23, 2020, at 05:14, Peter Slížik wrote:
> > Works in what way? You can't use it in a 'for' loop if it doesn't
> > define __iter__.
> >
>
> class Iterable:
> def __iter__(self):
> return Iterator(...)
>
> class Iterator:
> def __next__(self):
> return
>
>
On Sat, Jul 25, 2020 at 4:37 AM Random832 wrote:
>
> On Tue, Jul 21, 2020, at 15:54, Terry Reedy wrote:
> > The transformers should be once-through iterators because they can be
> > passed once-through interators. I suppose one could make them iterables
> > and add an attribute 'pristine' set to
On Tue, Jul 21, 2020, at 15:54, Terry Reedy wrote:
> The transformers should be once-through iterators because they can be
> passed once-through interators. I suppose one could make them iterables
> and add an attribute 'pristine' set to True in __init__ and False in
> __iter__, but why have 2
On 7/23/2020 5:14 AM, Peter Slížik wrote:
Works in what way? You can't use it in a 'for' loop if it doesn't
define __iter__.
class Iterable:
def __iter__(self):
return Iterator(...)
class Iterator:
def __next__(self):
return
# No __iter__ here.
# I've
> Works in what way? You can't use it in a 'for' loop if it doesn't
> define __iter__.
>
class Iterable:
def __iter__(self):
return Iterator(...)
class Iterator:
def __next__(self):
return
# No __iter__ here.
# I've just forgotten to def it.
With this setup,
On Thu, Jul 23, 2020 at 5:55 PM Peter Slížik wrote:
> Moreover, some tutorial authors make it even more difficult with using the
> terms iterator and iterable interchangeably. A notorious example is this
> wiki:
> https://wiki.python.org/moin/Iterator
>
> It says:
>
> *Here is an *iterator* that
On Thu, Jul 23, 2020 at 5:55 PM Peter Slížik wrote:
> > Python's design that iter(iterator) is iterator is extremely handy.
> >
>
> Yes, but it has the unfortunate consequence that an iterator is expected
> to define
>
> def __iter__(self):return self
>
> which I saw people *not* doing,
> The view are iterables. They can be iterated more than once and used in
> other operations.
>
> The transformers should be once-through iterators because they can be
> passed once-through interators.
This is important, thank you for pointing it out.
> Python's design that iter(iterator) is
On 7/21/20 9:32 PM, Peter Slížik wrote:
Hi list, two related questions:
1. Why do functions used to iterate over collections or dict members return
specialized objects like
type(dict.keys()) -> class 'dict_keys'
type(dict.values()) -> class 'dict_values'
type(dict.items()) -> class
On 7/21/2020 5:32 AM, Peter Slížik wrote:
Hi list, two related questions:
1. Why do functions used to iterate over collections or dict members return
specialized objects like
type(dict.keys()) -> class 'dict_keys'
type(dict.values()) -> class 'dict_values'
type(dict.items()) -> class
Hi list, two related questions:
1. Why do functions used to iterate over collections or dict members return
specialized objects like
type(dict.keys()) -> class 'dict_keys'
type(dict.values()) -> class 'dict_values'
type(dict.items()) -> class 'dict_items'
type(filter(..., ...)) -> class 'filter'
13 matches
Mail list logo