Trouble when overloading operator[ ]
david_ullrich at my-deja.com
david_ullrich at my-deja.com
Fri Jul 21 11:33:12 EDT 2000
In article <LBGd5.1837$6E.377728 at ptah.visi.com>,
ge at nowhere.none (Grant Edwards) wrote:
> In article <8l76hm$pm9$1 at nnrp1.deja.com>, david_ullrich at my-deja.com
wrote:
>
> > You can use the notation [2,3] to accomplish the same
> >thing: it appears that if you use multiple indices they
> >get passed as a tuple to __getitem__:
>
> You're not using multiple indices.
>
> You're using a single index whose value is the expression 2,3.
> The expression 2,3 evaluates to a tuple, which is passed to
> _getitem__, just as would the value of any other expression
> used as an index.
Ok, then I should revise what I said: You can use the
notation [2,3] to accomplish the same thing.
No doubt you're exactly right. But evidently there's a
difference between [] indices and function parameters here:
def hmm(x):
return x
print hmm(2,3)
gives an error (hence my suspicion that someone might
expect whatever[2,3] to give an error without trying it...)
Why is "2,3" a single expression in whatever[2,3]
but not in hmm(2,3)?
> --
> Grant Edwards grante Yow! My Aunt
MAUREEN was
> at a military advisor
to IKE &
> visi.com TINA TURNER!!
>
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list