It is fun.the result of str.lower(str())
bruno at modulix
onurb at xiludom.gro
Tue Mar 7 10:23:59 CET 2006
Sullivan WxPyQtKinter wrote:
> Guess what would be the result of these functions:
=> 'ASFA'.lower() => 'asfa'
=> ''.join(['1','1','1']) => '111'
=> 'a'.join('b') => 'b'
> If you guess them correctly,
No need to guess, there's this thing named the python interactive shell,
you know... And it even has an integrated help system.
> please explain.
Explain what ? It's all in the fine manual.
* Klass() is a call to Klass's constructor and returns an instance of Klass.
* Klass.method(klass_instance) is the same as klass_instance.method()
* str is the builtin string class.
* without any args, the str constructor returns an empty string
* str.join() takes a sequence of strings and join'em with the target str
instance as separator
Now would you be kind enough to explain what's funny about all this ?
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"
More information about the Python-list