Reputation: 5759
How would I go about writing python functions that can be append to strings (or other object)?
for example:
"FOO".lower()
How do they receive input? Are they generators?
I will happily read up on it, but I don't really know what I am looking for.
Upvotes: 2
Views: 2980
Reputation: 318628
Strings are objects and thus have methods. lower()
is one of them.
You cannot add a custom method to str
, unicode
or any other builtin (written in C) classes - see Implementing a custom string method and Extending builtin classes in python
Upvotes: 7