[Tutor] classes and names

Kevin McCormick kev@sat.net
Sat, 22 Dec 2001 23:59:34 -0600

Greetings all!  I am writing a module of spreadsheet type date functions 
and I would like to do some things with the function names.   Some of 
the functions are written really for supporting the actually useful 
functions and I don't quite understand the __function__(arg), 
__function(arg), and _function(arg) conventions. Also, it would be 
useful to set the main date function as a class object, since my design 
copies the time module and puts date information into a tuple.  I want 
all this in the same file too, so I am asking for a lot. Lastly, an 
exceptions class would be really useful.  I have read all the basic 
tutorial stuff on classes, but what would be really cool is a simple 
class that has this tuple and a way of being identified by my module 
level functions.

What I think I want would be something like:

class datefuncExceptions:
     # whatever goes into one of these type classes
     # like invalid argument, function x choked on arg y, etc

class dateObject(date, arg2):
     # call module functions to interpret date argument

     # attributes are tuple (y, m, d, serial, day)

def function(arg):
     # val = __evaluate(arg)
     # perform function tasks with val
     # errors are datefuncExceptions

def __evaluate(arg):
     # if arg is dateObject:
           pass it back
     # else:
           decipher arg and resolve into dateObject
     # return val

The idea is to understand many date formats as arguments and provide 
functions like yearfrac, days360, workdays, daysbetween, weeksbetween, 
eomonth, etc. at the module level so the class objects are small and two 
  can easily be used as function arguments.

Thanks for any comments.