MCPcopy Index your code
hub / github.com/RustPython/RustPython / __init__

Method __init__

Lib/collections/__init__.py:603–615  ·  view source on GitHub ↗

Create a new, empty Counter object. And if given, count elements from an input iterable. Or, initialize the count from another mapping of elements to their counts. >>> c = Counter() # a new, empty counter >>> c = Counter('gallahad')

(self, iterable=None, /, **kwds)

Source from the content-addressed store, hash-verified

601 # Knuth, TAOCP Vol. II section 4.6.3
602
603 def __init__(self, iterable=None, /, **kwds):
604 '''Create a new, empty Counter object. And if given, count elements
605 from an input iterable. Or, initialize the count from another mapping
606 of elements to their counts.
607
608 >>> c = Counter() # a new, empty counter
609 >>> c = Counter('gallahad') # a new counter from an iterable
610 >>> c = Counter({'a': 4, 'b': 2}) # a new counter from a mapping
611 >>> c = Counter(a=4, b=2) # a new counter from keyword args
612
613 '''
614 super().__init__()
615 self.update(iterable, **kwds)
616
617 def __missing__(self, key):
618 'The count of elements not in the Counter is zero.'

Callers

nothing calls this directly

Calls 2

updateMethod · 0.95
superClass · 0.85

Tested by

no test coverage detected