Author DavidMertz
Recipients DavidMertz, josh.r, mark.dickinson, pitrou, rhettinger, veky, wolma
Date 2017-03-15.04:39:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1489552751.94.0.48858539885.issue25478@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-03-15 04:39:11DavidMertzsetrecipients: + DavidMertz, rhettinger, mark.dickinson, pitrou, wolma, josh.r, veky
2017-03-15 04:39:11DavidMertzsetmessageid: <1489552751.94.0.48858539885.issue25478@psf.upfronthosting.co.za>
2017-03-15 04:39:11DavidMertzlinkissue25478 messages
2017-03-15 04:39:11DavidMertzcreate