Richard Querin wrote: > > > On 4/11/06, *Kent Johnson* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> > wrote: > > > There is no need to pass the class object in to the function, you can > create it in the function and return it. A class might be nice because > it gives names to the various values. A dict can also be used for this. > Do what feels right :-) > > > To be more specific, I'm going to have probably 6 functions that do > similar things. They all take slightly different arguments, they all do > slightly different calculations, but the results of all the functions > are the same format. So I guess it makes sense to use a class. Now, when
Yes, that's a good argument for a class. > you say 'create it in the function', you mean create the class instance > inside the function and return that instance? The class itself is > defined somewhere else in the module containing the functions so that > all the functions have access to it. (Total newb to python and classes > so sorry if that's a stupid question). Right, create the class instance in the function. class ReturnedValue(object): def __init__(self, value): self.value = value def myFunction(x, y, z, w): return ReturnedValue(x+y+z+w) Season to taste ;) Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor