I have a class whose job is to serve several other objects, this object is in a module 'M1', let's say it writes logs, no matter who calls it, (once it started writing to a file) it must continue writing to the same file, the file pointer could be a class variable here and there is also no need to have object methods, all could be class methods (my understanding of benefits between class and objects is not good, see below). 1. Should I have one object 'O1' that serves all i.e., no class variables, class methods, if so, since this class is in a module ('M1'), and in several other modules this module is imported, should I have in this 'M1' a global variable 'g' (let's call it module variable) that points to the object, thus whoever wants to use the object must import the module and through this module variable get pointer to the object, thus no matter how many times who ever imports there is only one object serving everyone as the object referred through 'g' is in one namespace 'M1'. This doesn't look elegant. 2. Should I have a class which does the job, and the class has a class variable 'cv' which should point to the file pointer and the methods should all be class methods. Now, from resource point of view, how much is the benefit of making a method class method? how about in this case where there are no object variables? Maybe the answers to these questions answers the following question, Is there a case when we would want to have a class with no object variables and all methods class methods.
Thanks, Krishna. -- http://mail.python.org/mailman/listinfo/python-list