[Python-ideas] Pseudo methods

Paul Laos paul_laos at outlook.com
Fri Aug 4 03:39:56 EDT 2017

Hi folks
I was thinking about how sometimes, a function sometimes acts on classes, and
behaves very much like a method. Adding new methods to classes existing classes
is currently somewhat difficult, and having pseudo methods would make that

Code example: (The syntax can most likely be improved upon)
    def has_vowels(self: str):
        for vowel in ["a", "e,", "i", "o", "u"]:
            if vowel in self: return True

This allows one to wring `string.has_vowels()` instead of `has_vowels(string)`,
which would make it easier to read, and would make it easier to add
functionality to existing classes, without having to extend them. This would be
useful for builtins or imported libraries, so one can fill in "missing" methods.

* Simple way to extend classes
* Improves readability
* Easy to understand

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170804/f037f0b6/attachment.html>

More information about the Python-ideas mailing list