Confused by Method(function) of a module and method of aclass/instance

Sullivan WxPyQtKinter sullivanz.pku at gmail.com
Tue Mar 7 08:18:09 CET 2006


Yes, I checked out that I have already run "from string import *". So
the lower() means string.lower() function.

However, something else came out just now:
>>>instr='a'
>>>instr.join('b')
'b'
>>>instr.lower()
'A'
>>>instr
'a'
Both as the method of the type str, join never use the instr instance
object as method parameters while lower do. Compared with the .lower()
method, the instr.join() looks like an independent function, which use
the parameters in the parenthesis and return a value without instr
being changed. So why should it be programmed into the str type?

More confusing things came out to me:
>>>str().lower()
''                                                  #well, this is
understandable.
>>>str.lower(str(),'A')
'a'

How do you explain this result?


Sincerely, thank you so much for help.




More information about the Python-list mailing list