On Sun, Jun 14, 2020 at 9:04 AM Oleg Broytman <[email protected]> wrote:
> On Sun, Jun 14, 2020 at 03:33:16PM -0000, artem6191 < > [email protected]> wrote: > > This attribute will use for convertion classes to other types, i.e. > int(MyClass) will return __convert__ result in MyClass > Define ``__int__`` or ``__index__``. > or __float__ But the problem is that we need a dunder for each type you want to support. I think the idea here is that you could specify, in your own custom class, which type(s) you can convert to, and it could be any type. That being said, to the OP: what are your use cases here? adding a dunder requires compelling use cases, and in this case, why having a dunder would be more helpful that simply writing a convert to this type method on your class. And when would that dunder be called? I'm having trouble figuring that out. -CHB > See > https://docs.python.org/3/reference/datamodel.html#special-method-names > > Oleg. > -- > Oleg Broytman https://phdru.name/ [email protected] > Programmers don't die, they just GOSUB without RETURN. > _______________________________________________ > Python-ideas mailing list -- [email protected] > To unsubscribe send an email to [email protected] > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/[email protected]/message/PTAVFYSXD4KTUYJCBWO7GB7F5QOH6Z5N/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/FNXMKLLJ665DMQCRQCQ6DZERNGQGC43N/ Code of Conduct: http://python.org/psf/codeofconduct/
