It is fun.the result of str.lower(str())

Fredrik Lundh fredrik at pythonware.com
Tue Mar 7 02:57:10 EST 2006


"Sullivan WxPyQtKinter" wrote:

> Guess what would be the result of these functions:
>
> >>>str.lower('ASFA')
> >>>str.join(str(),['1','1','1'])
> >>>str.join('a','b')
>
> If you guess them correctly, please explain.

as I just said, I.method() and C.method(I) are equivalent,
so that's just an odd way to write

    'ASFA'.lower()
    str().join(['1', '1', '1'])
    'a'.join('b')

which, given that str() returns an empty string, and a string
behaves like a sequence of individual characters, is equivalent
to

    'ASFA'.lower() => 'asfa'
    ''.join(['1', '1', '1']) => '111'
    'a'.join(['b']) => 'b'

</F>






More information about the Python-list mailing list