Is classless worth consideration

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Wed Apr 28 23:57:16 EDT 2004


Michael wrote:

> Is there any way to to call a class method without making an instance
> of that class? To me that would be useful because you could mimic
> modules without having to create a sepperate file. Or is there
> already a way to do that?

You are explicitly allowed to put anything you want into sys.modules.
This was specifically permitted so people could add class *instances* as
modules (they were already doing it), but putting a class there would
work too. Of course, you'll want to add things like __file__ and
__name__ to your class.

Tim Delaney




More information about the Python-list mailing list