Unexpected return value from __add__

Marc Christiansen tolot at solar-system.dynodns.net
Fri Sep 7 13:23:06 CEST 2001


Magnus Lycka <magnus at thinkware.se> wrote:
>     def __str__(self):
>         res = []
>         while self.addr:
>             self.addr, digit = divmod(self.addr,256)
>             res.append(str(digit))
>         res.reverse()
>         return ".".join(res)

After calling __str__, self.addr is 0L. Insert 'addr = self.addr' at the 
beginning and use 'addr'.

HTH
  Marc



More information about the Python-list mailing list