On 6/29/2012 6:45 AM Albert-Jan Roskam said...
Hi Steven,
Thanks for helping me. It makes more sense now. Calling append() on the
datatype list returns None but calling __add__ on the datatype int
returns, well, the result.

I don't know that it's consistent across all types, but I've found that mutable types tend to change in place and return None while immutable types tend to return the altered result, which is as you describe below.

Emile




Somehow it makes more sense to me when
writing + as __add__
a[k] = a.get(k, 0).__add__(1)
b[k] = b.get(k, []]).__add__([v])
 >>> x = 1
 >>> y = []
 >>> z = y.append(x)
 >>> z is None
True
Regards,
Albert-Jan



_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to