MCPcopy Create free account
hub / github.com/ActiveState/code / _size

Method _size

recipes/Python/578611_Bag_class/recipe-578611.py:387–394  ·  view source on GitHub ↗

Returns total number of items in bag. >>> b = Bag.fromkeys("abacab") >>> b.size 6

(self)

Source from the content-addressed store, hash-verified

385 __slots__ = []
386
387 def _size(self):
388 """Returns total number of items in bag.
389
390 >>> b = Bag.fromkeys("abacab")
391 >>> b.size
392 6
393 """
394 return sum(self.values())
395
396 size = property(_size, None, None, "Sum of all bag values.")
397

Callers

nothing calls this directly

Calls 2

sumFunction · 0.50
valuesMethod · 0.45

Tested by

no test coverage detected