On Sep 1, 5:31 pm, Philipp Hagemeister <phi...@phihag.de> wrote:
> Mark Dickinson wrote:
> > (...) If you want to be
> > able to interpret instances of X as integers in the various Python
> > contexts that expect integers (e.g., hex(), but also things like list
> > indexing), you should implement the __index__ method:
>
> Thanks. Somehow forgot this magic method and deleted it by accident.

I wonder whether it would make sense for the Python 2.x hex
function to fall back to __index__ when __hex__ isn't defined.
With the current setup, it's not clear how to write 2.x code
that will also run (post 2to3 translation) properly on 3.x.

--
Mark
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to