Base classes or global functions
Eric Texier
erict at millfilm.co.uk
Thu Jul 25 05:09:34 EDT 2002
In case of scenari #3, I like personnally the use of staticmethod
class utilHelper:
''' some initialization code and variable can happen here when the module
is loaded
'''
def somefunction(params):
....
somefunction = staticmethod(somefunction)
Robb Shecter wrote:
> Stephen Boulet wrote:
> > I have two classes, Class1 and Class2. Class1 contains a list of Class2
> > objects, but no inheritance is involved
> >
> > Both classes use some functions I wrote. What's the best way of making the
> > functions available to the classes?
> >
>
> Good questions. To answer it, we'd have to know what the functions do -
> what information they manipulate. Depending on your answer, any of the
> following scenarios are possible:
>
> 1. The functions become methods of Class1.
> 2. The functions become methods of Class2.
> 3. The functions become methods of a new, as yet unwritten class.
> 3a. This new class would be used by Class1 and Class2
> 3b. This new class would be subclassed by either Class1 or Class2.
>
> Robb
More information about the Python-list
mailing list