2 ms·
I stand corrected. However, I do think that in order to use this like I want ... map(str.capitalize, ['a', 'b', 'c']) ... you have to understand far too much
by djacobs 16y ago
I stand corrected. However, I do think that in order to use this like I want ...
map(str.capitalize, ['a', 'b', 'c'])
... you have to understand far too much of Python's implementation (for example, that str is not a function, but a class that kindof acts like a function) to program. I still think that methods + functions = a pain point in Python.
- viraptor 16y agoWell... to make it easier you can think of classes as normal functions returning instances. For almost any practical purpose, that's true. Also, str.capitalize is (for any practical purpose again :) ) a one-argument function that takes a string and returns a capitalised string.
- j_baker 16y agoIn Python, str is a class. And all classes act as function. If there is ever any doubt, you can tell like this: >>> type(str) <type 'type'> You can tell that str is a class because it inherits from type type.