Base classes or global functions

Robb Shecter rs at onsitetech.com
Wed Jul 24 19:27:28 EDT 2002


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