Data Tree urgent help!!!!!!

Chris Angelico rosuav at gmail.com
Wed Feb 20 12:16:35 CET 2013


On Wed, Feb 20, 2013 at 10:01 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> Leo Breebaart wrote:
>
>> Peter Otten <__peter__ at web.de> writes:
>>
>>> >>> class Name(str):
>>> ...     def __repr__(self):
>>> ...             return self
>>> ...
>>> >>> apple, pear, dog, cat, fork, spoon = map(Name, "apple pear dog cat
>>> >>> fork spoon".split())
>>
>> Is there any reason why you introduced the Name class? In Python
>> 2.7 this works equally well if I just do:
>>
>>>>> apple, pear, dog, cat, fork, spoon = map(str, "apple pear dog cat fork
>>>>> spoon".split())
>>
>> So I was wondering why you used Name.
>
> I'm wondering why you used map.
>
>
> apple, pear, dog, cat, fork, spoon = "apple pear dog cat fork spoon".split()

Why, in case someone monkeypatched split() to return something other
than strings, of course!

Sorry, I've been learning Ruby this week, and I fear it may be
damaging to my mind...

ChrisA



More information about the Python-list mailing list