When I type help('string') in the python interpreter I get information about the string class. There,upper() is indicated as a function. Yet I can only call it as a method like "hi".upper() instead of upper("hi").
So one could assume that any method will be indicated as a function in the docstrings of the built in modules. Yet when I do help('list') , methods of the list class are indicated as methods in the docstrings!!
Why is this so? Only because the person who wrote the doctrings was inconsistent or that different people wrote it? Or do these methods(the ones called ‘functions’ versus the ones called ‘methods’ in the docstrings) actually have different properties?
When I type help(‘string’) in the python interpreter I get information about the string
Share
When you searched for
help('string'), you were looking for the docstrings of thestringmodule. If you dohelp(str)orhelp('str')you’ll get the docstrings of thestrtype, and hereupperappears as a method!As you can see here, the function
upperfrom thestringmodule is actually a function and not a method: