[Tim Peters] > a fundamental use case for Counters is to tally the _number_ of times > duplicate keys appear. > Yes, that's why the default constructor already does just that.
[Tim Peters] > So, e.g., someone will be unpleasantly surprised no matter what Sure, but in Hettinger's own words <https://www.youtube.com/watch?v=HTLu2DFOdTg&t=24m46s> "whenever you have a constructor war, everyone should get their wish". People that want a counting constructor have that, people that want the ability to initialize values don't have that. [Tim Peters] > Counter.fromkeys("aaaaa", 2) > > returned. "It should set key 'a' to 2! that's what I said it should > do!" "No! It should set key 'a' to 10! that's what a Counter _always_ > does - sums the values associated with duplicate keys!" > I'm tempted to indulge in the meta argument which you're obviously striving to avoid, but I will say this: "that's what a Counter _always_ does" makes no sense. It's *almost* tantamount to saying that all constructors have to do exactly the same thing, which makes multiple constructors useless. Technically, there is no constructor for counting by X, but if enough people really wanted that, I suppose a third constructor would be in order.
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/