On 29 April 2013 20:04, Guido van Rossum <gu...@python.org> wrote:
> On Mon, Apr 29, 2013 at 11:34 AM, Larry Hastings <la...@hastings.org> wrote:
>> What's the problem with overriding the isinstance checks?  You mention it
>> but seem to assume it's a bad idea.  That seems to me like it'd adequately
>> solve that problem with an acceptable level of magic.
>
> Depending on whether you are using isinstance() to check if an enum
> value belongs in the set of acceptable enums, or to check it it makes
> sense to call a certain method, you need isinstance() to behave
> differently.

Would it not be better to avoid using isinstance() for this?

I would have expected membership testing to use "Red in Colors" rather
than "isinstance(Red, Color)" like in this stackoverflow question
about an enum class:
http://stackoverflow.com/questions/10445819/overriding-contains-method-for-a-class


Oscar
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to