[Python-ideas] Pseudo methods

Victor Stinner victor.stinner at gmail.com
Mon Aug 7 04:48:45 EDT 2017

Ruby provides this feature. A friend who is a long term user of Rails
complained that Rails abuses this and it's a mess in practice. So I
dislike this idea.


2017-08-04 9:39 GMT+02:00 Paul Laos <paul_laos at outlook.com>:
> 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
> easier.
> 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
> ~Paul
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/

More information about the Python-ideas mailing list