Finding the type of indexing supported by an object?
Fredrik Lundh
fredrik at pythonware.com
Wed Aug 23 06:03:35 EDT 2006
Derek Peschel wrote:
> I've thought about looking for keys(), looking for the special method names
> that allow you to override indexing behavior, and looking at the class or
> type of the object. I could be wrong, but I don't think any of those
> strategies will work with all arguments.
the behaviour of obj[arg] is determined by the __getitem__ method, and
that method can do whatever it wants.
</F>
More information about the Python-list
mailing list