2010/7/4 CHEN Guang <dr...@126.com>: > Why Python forbids multiple instances of one module? > If only Python allows multiple instances of one module, module will > be enough to replace class in most cases. > After all, it is much easier to write a module than a class, at least we do > not have to write self everywhere.
If you really want to do that, it should be possible by deleting the entry from sys.modules and re-importing it. You save yourself having to explicitly write self everywhere, but instead you have to declare all your "instance" variables as globals in each "method" that uses them, which isn't much less of a chore. You also lose inheritance, properties (and descriptors in general), magic method support, metaclasses, and pretty much all the other nice features that new-style classes have to offer. -- http://mail.python.org/mailman/listinfo/python-list