Ian Bicking: the old part of his blog

Re: Rerubyandpythoncomparedcomment000

That's to find all subclasses, not all instances. I remembered about the gc module, though, and this kind of works:

def all_instances(a_class):
    return [obj for obj in gc.get_objects() if isinstance(obj, a_class)]

People use things like this to do reloading in Python. Once someone says "yes, I do reloading, and it works like a dream and never fails" then I'll be all over that. But it seems like there's some other tricks to do it right.

Comment on Rerubyandpythoncomparedcomment000
by Ian Bicking


Whups, yeah.

A similar principle would work, though.

# Jon Rosebaugh