[SQL] Right way to set a variable to NULL?

Scott David Daniels Scott.Daniels at Acm.Org
Fri Dec 26 16:16:55 EST 2008


Martin wrote:
> ...
> class MailAddress(object):
>   def __init__(self, address=None):
>     self.address = address
>   def __str__(self):
>     if address:
>       return self.adress
>     return "NULL"

There is an obvious typo above:
 >     if address:
should be:
       if self.address:

Or, you could replace the __str__ function with:
     def __str__(self):
         return self.address or "NULL"

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list