Perl is worse! (was: Python is Wierd!)
Ben Wolfson
rumjuggler at cryptarchy.org
Fri Jul 28 04:58:56 EDT 2000
On Fri, 28 Jul 2000 07:57:12 GMT, grey at despair.rpglink.com (Steve Lamb)
wrote:
>
>>No, it took a sequence containing a single element and turned it into a list
>>containing a single element. list() only works on sequences. 'a' is a
>>sequence of length 1.
>
> That is what I said. It took a single element and made it a list with a
>single element.
No.
The single element is the string "a". It took the *sequence* "a" and made
it a list.
>>> string = "a"
>>> result = []
>>> for character in string:
result.append(character)
>>> result
['a']
That works because "a" is a single-element sequence. Ditto ['a'] and
('a',).
If list() really took a single element and returned a list with that
element, as I've said previously, the result of list( ('a',) ) would be
[('a',)].
--
Barnabas T. Rumjuggler
Further-more, I have long since put the finishing touches on my own
official obituary, a 350-page tale of heart-rending loss which details,
among other things: my meteoric rise from Onion stringer to editor to
publisher; my assassination at the hands of lady-actress Ethel Barrymore's
jealous suitors; the thousand days of mourning which followed my death,
during which a cold rain fell constantly, no bird sang, and children were
born antlered and hooved; ...
-- T. Herman Zweibel
More information about the Python-list
mailing list