internal circular class references

Ethan Furman ethan at
Thu Dec 11 00:26:47 CET 2008

Greetings List!

I'm writing a wrapper to the module to support having no 
date.  Its intended use is to hold a date value from a dbf file, which 
can be empty.

The class is functional at this point, but there is one thing I would 
like to change -- and are class 
attributes of, and hold values.  At this 
point I have to have two lines outside the actual class definition to do 
the same thing, e.g.:

<trimmed down class code>
   class NullDate(object):
       "adds null capable DateTime.Date constructs"
       __slots__ = ['_date']
       def __new__(cls, date='', month=0, day=0):
           nulldate = object.__new__(cls)
           nulldate._date = ""
   	  return nulldate
       def __getattr__(self, name):
           if self:
               attribute = self._date.__getattribute__(name)
               return attribute
               if callable([name]):
                   return int
                   return 0
       def __nonzero__(self):
           if self._date:
               return True
           return False
       def fromordinal(cls, number):
           if number:
               return cls(
               return cls()
   NullDate.max = NullDate(
   NullDate.min = NullDate(
</trimmed down class code>

How can I move those last two lines into the class definition so that:
   1) they are class attributes (not instance), and
   2) they are NullDate type objects?


More information about the Python-list mailing list