My double dot was a typo on my tablet, not borrowing Julia syntax, in this
case.

On Sat, Feb 2, 2019, 6:43 PM David Mertz <me...@gnosis.cx wrote:

> On Sat, Feb 2, 2019, 6:23 PM Christopher Barker
>
>> a_list_of_strings.strip().lower().title()
>>
>> is a lot nicer than:
>>
>> [s.title() for s in (s.lower() for s in [s.strip(s) for s in
>> a_list_of_strings])]
>>
>> or
>>
>> list(map(str.title, (map(str.lower, (map(str.strip, a_list_of_strings))))
>> # untested
>>
>
> I'm warming up some. But is this imagined as vectors of strings, or as
> generically homogeneous objects? And what is homogeneity exactly in the
> face of duck typing?
>
> Absent the vector wrapping, I think I might write this for your example:
>
> map(lambda s: s..strip().lower().title(), a_list_of_strings)
>
> That's slightly longer, but just by the length of the word lambda.
>
> One could write a wrapper to vectorize pretty easily. So maybe:
>
> Vector(a_list_of_strings).strip().lower().title()
>
> This would just pass along the methods to the individual items, and
> wouldn't need to think about typing per se. Maybe other objects happen to
> have those three methods, so are string-like in a duck way.
>
>
>
_______________________________________________
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