On Thu, Jul 5, 2012 at 11:09 AM, Billy Earney <billy.ear...@gmail.com> wrote: > C Anthony, > > What's wrong with using isinstance?
well, that would work for differentiating between a primitive dict and a primitive list, but 90% or more of all objects i write [ever] support iteration and string indexing ... and they certainly are not derived from list or dict. such objects can be substituted in *any* code operating on a list or dict, *except* when said code needlessly enforces a specific type. "easier to ask forgiveness than permission" ... just start operating on the data with the assumption it will behave like a dict, if that fails, assume its a list. if that fails, then you can complain to the user :-) keep the fast path fast by trying the 90% first, then the 9%, then the 1%. -- C Anthony