I still haven't seen any examples that aren't already spelled 'map(fun, it)'

On Sat, Feb 2, 2019, 3:17 PM Jeff Allen <ja...@farowl.co.uk wrote:

> On 02/02/2019 18:44, MRAB wrote:
>
> On 2019-02-02 17:31, Adrien Ricocotam wrote:
> > I personally would the first option to be the case. But then vectors
> shouldn't be list-like but more generator like.
> >
> OK, here's another one: if you use 'list(...)' on a vector, does it apply
> to the vector itself or its members?
>
> >>> list(my_strings)
>
> You might be wanting to convert a vector into a list:
>
> ['one', 'two', 'three']
>
> or convert each of its members onto lists:
>
> Vector([['one'], ['two'], ['three']])
>
> More likely you mean:
>
> >>> [list(i) for i in ['one', 'two', 'three']]
> [['o', 'n', 'e'], ['t', 'w', 'o'], ['t', 'h', 'r', 'e', 'e']]
>
> The problem, of course, is that list() now has to understand Vector
> specially, and so does any function you think of applying to it. Operators
> are easier (even those like [1:]) because Vector can make its own
> definition of each through (a finite set of) dunder methods. To make a
> Vector accept an arbitrarily-named method call like my_strings.upper() to
> mean:
>
> >>> [i.upper() for i in ['one', 'two', 'three']]
> ['ONE', 'TWO', 'THREE']
>
> is perhaps just about possible by manipulating __getattribute__ to resolve
> names matching methods on the underlying type to a callable that loops over
> the content.
>
> Jeff
> _______________________________________________
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to