In sorted(list(mydict.keys())), sorted and list doesn't need an object prefix someobject., but keys() needed dict1.. When, or for what functions, is the prefix necessary?
2 Answers
Methods need to be called on a specific object. Functions don't.
The functions that are available at any time are the built-in ones, such as sorted and list, plus any functions that are in modules that you've imported or that you've defined yourself. The methods that are available on a particular object are the ones that are defined on that object's type.
2 Comments
qazwsx
Do the built-in functions have their "implicit" objects?
Taymon
No, actually, it's the other way around. All methods are really functions, and the object which the method is called on is implicitly passed as the first parameter.
mydict.keys() is syntactic sugar for dict.keys(mydict).
.something()to call their methods.