Robert Roy <rjroy at takingcontrol.com> wrote in comp.lang.python: > On Thu, 19 Apr 2001 10:46:53 -0500, "Jake Baker" <jbaker at ummelec.com> > wrote: > > >Gosh. I've been using Python since 96 and I don't know this! Wow! > > > >Say I have a class heirarchy that looks like A, B <- A, C <- A, etc.... > > > >I have a list of objects (which I know arbitrarily are all A or sublasses = > >of A) and want to filter them based on which subclass they are. > > > >How do I go about doing this? You help is greatly appreciated! > > > >Thanks, > > - Jake Baker > > I think that instanceof will do the trick. See the Python Library > Reference under Built-in Functions (Doc\lib\built-in-funcs.html) Just a slight correction, the function is called 'isinstance'. He could also look directly at the objects' __class__ member, or even __bases__. -- Remco Gerlich
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4