SPAM-LOW: Re: Function/method returning list of chars in string?

Robert Kern robert.kern at
Tue Jun 9 18:17:14 EDT 2009

On 2009-06-09 17:06, Carl Banks wrote:
> On Jun 9, 12:42 pm, Terry Reedy<tjre... at>  wrote:
>> Hendrik van Rooyen wrote:
>>> I should have known - you use a string method to get a list of words,
>>> but you have to go to the list to get a list of characters from a string.
>> That is symmetry.
>>> There is no string method to do it, which is what I am complaining
>>> about.
>> That would be asymmetry.
>>> Is there a reason for this, or is the lack of symmetry just an historical
>>> artefact?
>> A lack of perception to see the symmetry that is there.
>> Classes create instances of the class when called.
>> Sometimes alternate constructors are needed when there is more than one
>> possible way to create an instance from a given input.  In the case of
>> str(iterable), one could want either a string representing the iterable
>> itself, just as with non-iterables, or a string representing the
>> concatenated contents of the iterable.  Str.join implements the second
>> choice, with an added string parameter to allow a constant string to be
>> interpolated between the joined items.
> But then how do you rationalize str.split(), which is a method of str
> but a constructor of list?

There is a difference between a "constructor of a type" and just "a method that 
returns a particular type". str.join() and str.split() are really examples of 
the latter.

> Perhaps instead of worrying about symmetry all the time we should just
> accept the inevitability that things will always be asymmetric and
> impure from someone's perspective.  Terry's symmetry is Hendrik's
> asymmetry and vice versa.

There is much wisdom in this.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

More information about the Python-list mailing list