A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2008-June/080368.html below:

[Python-Dev] Advice on numbers.py implementation of binary mixins.

[Python-Dev] Advice on numbers.py implementation of binary mixins.Nick Coghlan ncoghlan at gmail.com
Sat Jun 14 03:23:19 CEST 2008
Raymond Hettinger wrote:
> The question for the group is what to put on the XXX line.
> 
> 1. Limit it to type(self).  This approach claims the least knowledge 
> about other types and uses their __rand__ methods().
> 
> 2. Use type(self), int, and long.  This approach says that we know that 
> ints and longs can be reasonably converted to an int; however, it means 
> that any int/long subtype cannot use __rand__ to override the mixin's 
> __and__.
> 
> 3. Emulate the PEP as closely as possible and accomodate subclassing 
> without changing behaviors.  This approach is a bit complex:
> 
>        knowntypes = (set(type(self).__mro__)
>                               & set(type(other.__mro__))
>                               - set(type(Integral.__mro__))
>                               | set([int, long]))
>        if isinstance(other, tuple(knowntypes)):

4. As 2, but skip int/long subclasses:

   if type(other) in (int, long) or isinstance(other, type(self)):

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4