[Python-ideas] Pseudo methods
Antoine Rozo
antoine.rozo at gmail.com
Fri Aug 4 03:59:42 EDT 2017
Hi,
With this kind of feature, you never know which methods are included in the
class (depending of which modules have been loaded).
I don't think this is a good 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/
>
>
--
Antoine Rozo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170804/35037f99/attachment.html>
More information about the Python-ideas
mailing list