Message289640
Raymond wrote:
> The idea is that the method would return a new counter instance
> and leave the existing instance untouched.
Your own first example suggested:
c /= sum(c.values())
That would suggest an inplace modification. But even if it's not that, but creating a new object, that doesn't make much difference to the end user who has rebound the name `c`.
Likewise, I think users would be somewhat tempted by:
c = c.scale_by(1.0/c.total) # My property/attribute suggestion
This would present the same attractive nuisance. If the interface was the slightly less friendly:
freqs = {k:v/c.total for k, v in c.items()}
I think there would be far less temptation to rebind the same name unintentionally. |
|
Date |
User |
Action |
Args |
2017-03-15 04:39:11 | DavidMertz | set | recipients:
+ DavidMertz, rhettinger, mark.dickinson, pitrou, wolma, josh.r, veky |
2017-03-15 04:39:11 | DavidMertz | set | messageid: <1489552751.94.0.48858539885.issue25478@psf.upfronthosting.co.za> |
2017-03-15 04:39:11 | DavidMertz | link | issue25478 messages |
2017-03-15 04:39:11 | DavidMertz | create | |
|