intX.__str__() ??

Steven D'Aprano steve+comp.lang.python at
Sun Feb 24 19:23:17 CET 2013

On Sun, 24 Feb 2013 13:09:56 -0500, Mitya Sirenef wrote:

> On 02/24/2013 12:29 PM, Michael Torrie wrote:

>  > Another way to explain the double underscore methods is that they are
>  > how things like operator overloading is performed. Want to make a
>  > class that you can use the [index] notation on instances? Define the
>  > __get_attr__() method. And to define a class that you can then use
> small correction: it should be __getattr__()

Correct correction: it should be __getitem__ to override instance[item] 
access. __getattr__ is for overriding instance.attribute.


More information about the Python-list mailing list