String length ... len(str)

Erik Max Francis max at alcyone.com
Wed Dec 3 23:41:16 EST 2003


Jeff Wagner wrote:

> Thanks for the info, it clears up a lot of confusion for me.
> 
> I was under the impression that:
> str1 = "here" + "we" + "are"      was the same as
> str2 = "here" , "we" , "are"         ...
> 
> the only difference being that the str2 was separated by a space.  But
> str1 is a string, str2 is a
> tuple.

Right.  What probably confused you is that print acts like this:

>>> print "one", "two", "three"
one two three

But this is only because print is a statement, and uses this as a
special form.

> Cool ... who ever came up with the word tuple? That's a weird name.

It's derived from mathematics.  A pair of items is a double, three items
is a triple, four is a quadruple, and n is an n-tuple.

-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ 
\__/ Can I be your friend / 'Till the end
    -- India Arie




More information about the Python-list mailing list