intX.__str__() ??

Mitya Sirenef msirenef at lightbird.net
Sun Feb 24 13:44:20 EST 2013


On 02/24/2013 01:23 PM, Steven D'Aprano wrote:
> 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.
 >
 >


Oh, yes.. I guess it pays to read more than a single sentence
when making corrections! -m


-- 
Lark's Tongue Guide to Python: http://lightbird.net/larks/

Each religion, by the help of more or less myth, which it takes more or
less seriously, proposes some method of fortifying the human soul and
enabling it to make its peace with its destiny.  George Santayana




More information about the Python-list mailing list