question about class methods

Darren Dale dd55 at cornell.edu
Wed Mar 14 17:04:00 EDT 2007


I've run across some code in a class method that I don't understand:

    def example(self, val=0)
        if val and not self:
            if self._exp < 0 and self._exp >= -6:

I am unfamiliar with some concepts here:

1) Under what circumstances would "if not self" be True?

2) If "not self" is True, how can self have attributes?

(This is slightly simplified code from the decimal.Decimal.__str__ method,
line 826 in python-2.4.4)

Thanks,
Darren



More information about the Python-list mailing list