Any class has a .__module__ attribute giving the name of the module where the class was defined, so you need something like [c for c in globals() if inspect.isclass(c) and c.__module__ == "__main__"] Michele Simionato