Overloading __getitem__

Andreas Matthias amat at kabsi.at
Thu May 22 19:38:39 EDT 2008


inhahe at gmail.com wrote:

> actually i ddin't think about the fact that you're overloading dict, which 
> can already take multiple values in getitem

Oh, I didn't know that. I totally misinterpreted the error message.


> so how about
> 
> class crazy: pass
> 
> and then in your dict class:
> 
> def __getitem__(*args):

Apparently, args already is a tuple, so this should be:

  def __getitem__(self, args):

Is this documented somewhere? I couldn't find it anywhere.

Thanks.


Ciao
Andreas



More information about the Python-list mailing list