Finding the type of indexing supported by an object?

Derek Peschel dpeschel at eskimo.com
Sat Aug 26 03:32:54 EDT 2006


In article <ech9he$as$02$1 at news.t-online.com>, Peter Otten wrote:

>Instead of the (unreliable) introspection approach you could let the client
>code decide:

See my reply to Alex Martelli's post, where I explain my original desire
for one function that works with a wide variety of present and future
object types.  Your solution accomplishes that, but only by forcing the
caller to convert the argument to a list of pairs.  If the caller knows the
type it's going to pass down, that's easy.  If the caller doesn't know,
your approach doesn't seem any easier than mine.

In practice, with my needs of inverting dicts and lists, your solution might
not be a bad one.

-- Derek



More information about the Python-list mailing list