@@ -346,89 +346,98 @@ def fromkeys(cls, iterable, value=None):
346346
347347class Tally (_TallyMixin , collections .UserDict ):
348348 '''
349- blocktododoc
350- An immutable tally.
351-
352- A tally that (a) can't be changed and (b) has only positive integer values.
353- This is like `collections.Counter`, except:
354-
355- - Because it's immutable, it's also hashable, and thus it can be used as a
356- key in dicts and sets.
357-
358- - Unlike `collections.Counter`, we don't think of it as a "dict who
359- happens to count objects" but as an object that is absolutely intended
360- for counting objects. This means we do not allow arbitrary values for
361- counts like `collections.Counter` and we don't have to deal with a
362- class that has an identity crisis and doesn't know whether it's a
363- counter or a dict .
364-
349+ A tally that counts items.
350+
351+ This is a mapping between items and their count:
352+
353+ >>> Tally('aaabcbc')
354+ Tally({'a': 3, 'b': 2, 'c': 2})
355+
356+ It can be created from either an iterable like above, or from a `dict`.
357+
358+ This is similar to Python's builtin `collections.Counter`, except unlike
359+ `collections.Counter`, we don't think of it as a "dict that happens to
360+ count objects" but as an object that is absolutely intended for counting
361+ objects. This means we do not allow arbitrary values for counts like
362+ `collections.Counter` and we don't have to deal with all the complications
363+ that follow. Only positive integers are allowed as counts .
364+
365365 '''
366366 _dict = property (lambda self : self .data )
367367
368368
369369class OrderedTally (_OrderedTallyMixin , _TallyMixin , _OrderedDictDelegator ):
370370 '''
371- blocktododoc
372- An immutable, ordered tally.
373-
374- A tally that (a) can't be changed and (b) has only positive integer values.
375- This is like `collections.Counter`, except:
376-
377- - Because it's immutable, it's also hashable, and thus it can be used as a
378- key in dicts and sets.
379-
380- - Unlike `collections.Counter`, we don't think of it as a "dict who
381- happens to count objects" but as an object that is absolutely intended
382- for counting objects. This means we do not allow arbitrary values for
383- counts like `collections.Counter` and we don't have to deal with a
384- class that has an identity crisis and doesn't know whether it's a
385- counter or a dict.
386-
387- - It has an order to its elements, like `collections.OrderedDict`.
388-
371+ An ordered tally that counts items.
372+
373+ This is a ordered mapping between items and their count:
374+
375+ >>> OrderedTally('aaabcbc')
376+ OrderedTally((('a', 3), ('b', 2), ('c', 2)))
377+
378+ It can be created from either an iterable like above, or from a `dict`.
379+
380+ This is similar to Python's builtin `collections.Counter`, except unlike
381+ `collections.Counter`, we don't think of it as a "dict that happens to
382+ count objects" but as an object that is absolutely intended for counting
383+ objects. This means we do not allow arbitrary values for counts like
384+ `collections.Counter` and we don't have to deal with all the complications
385+ that follow. Only positive integers are allowed as counts.
386+
387+ Also, unlike `collections.Counter`, items have an order. (Simliarly to
388+ `collections.OrderedDict`.)
389+
389390 '''
390391 _dict = property (lambda self : self .data )
391392
392393
393394class FrozenTally (_BaseTallyMixin , FrozenDict ):
394395 '''
395- An immutable tally.
396-
397- A tally that (a) can't be changed and (b) has only positive integer values.
398- This is like `collections.Counter`, except:
399-
400- - Because it's immutable, it's also hashable, and thus it can be used as a
401- key in dicts and sets.
402-
403- - Unlike `collections.Counter`, we don't think of it as a "dict who
404- happens to count objects" but as an object that is absolutely intended
405- for counting objects. This means we do not allow arbitrary values for
406- counts like `collections.Counter` and we don't have to deal with a
407- class that has an identity crisis and doesn't know whether it's a
408- counter or a dict.
409-
396+ An immutable tally that counts items.
397+
398+ This is an immutable mapping between items and their count:
399+
400+ >>> FrozenTally('aaabcbc')
401+ FrozenTally({'a': 3, 'b': 2, 'c': 2})
402+
403+ It can be created from either an iterable like above, or from a `dict`.
404+
405+ This is similar to Python's builtin `collections.Counter`, except unlike
406+ `collections.Counter`, we don't think of it as a "dict that happens to
407+ count objects" but as an object that is absolutely intended for counting
408+ objects. This means we do not allow arbitrary values for counts like
409+ `collections.Counter` and we don't have to deal with all the complications
410+ that follow. Only positive integers are allowed as counts.
411+
412+ Also, unlike `collections.Counter`, it's immutable, therefore it's also
413+ hashable, and thus it can be used as a key in dicts and sets.
414+
410415 '''
411416
412417class FrozenOrderedTally (_OrderedTallyMixin , _BaseTallyMixin ,
413418 FrozenOrderedDict ):
414419 '''
415- An immutable, ordered tally.
416-
417- A tally that (a) can't be changed and (b) has only positive integer values.
418- This is like `collections.Counter`, except:
419-
420- - Because it's immutable, it's also hashable, and thus it can be used as a
421- key in dicts and sets.
422-
423- - Unlike `collections.Counter`, we don't think of it as a "dict who
424- happens to count objects" but as an object that is absolutely intended
425- for counting objects. This means we do not allow arbitrary values for
426- counts like `collections.Counter` and we don't have to deal with a
427- class that has an identity crisis and doesn't know whether it's a
428- counter or a dict.
420+ An immutable, ordered tally that counts items.
421+
422+ This is an ordered mapping between items and their count:
423+
424+ >>> FrozenOrderedTally('aaabcbc')
425+ FrozenOrderedTally((('a', 3), ('b', 2), ('c', 2)))
426+
427+ It can be created from either an iterable like above, or from a `dict`.
428+
429+ This is similar to Python's builtin `collections.Counter`, except unlike
430+ `collections.Counter`, we don't think of it as a "dict that happens to
431+ count objects" but as an object that is absolutely intended for counting
432+ objects. This means we do not allow arbitrary values for counts like
433+ `collections.Counter` and we don't have to deal with all the complications
434+ that follow. Only positive integers are allowed as counts.
435+
436+ Also, unlike `collections.Counter`:
437+ - Items have an order. (Simliarly to `collections.OrderedDict`.)
438+ - It's immutable, therefore it's also hashable, and thus it can be used as
439+ a key in dicts and sets.
429440
430- - It has an order to its elements, like `collections.OrderedDict`.
431-
432441 '''
433442 def __repr__ (self ):
434443 if not self :
0 commit comments