diff options
author | Raymond Hettinger <python@rcn.com> | 2016-08-22 03:52:26 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2016-08-22 03:52:26 (GMT) |
commit | dc65c685249758c576f3fd915f7f913cdc0a0d2b (patch) | |
tree | 6f59701c9175ab756613135f502c05a14d88fc59 /Lib/collections | |
parent | c758d51aa8654cb651a783e0d5df9e59ee4e7589 (diff) | |
download | cpython-dc65c685249758c576f3fd915f7f913cdc0a0d2b.zip cpython-dc65c685249758c576f3fd915f7f913cdc0a0d2b.tar.gz cpython-dc65c685249758c576f3fd915f7f913cdc0a0d2b.tar.bz2 |
Remove main section that was only used during testing and development
Diffstat (limited to 'Lib/collections')
-rw-r--r-- | Lib/collections/__main__.py | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/Lib/collections/__main__.py b/Lib/collections/__main__.py deleted file mode 100644 index 763e38e..0000000 --- a/Lib/collections/__main__.py +++ /dev/null @@ -1,38 +0,0 @@ -################################################################################ -### Simple tests -################################################################################ - -# verify that instances can be pickled -from collections import namedtuple -from pickle import loads, dumps -Point = namedtuple('Point', 'x, y', True) -p = Point(x=10, y=20) -assert p == loads(dumps(p)) - -# test and demonstrate ability to override methods -class Point(namedtuple('Point', 'x y')): - __slots__ = () - @property - def hypot(self): - return (self.x ** 2 + self.y ** 2) ** 0.5 - def __str__(self): - return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot) - -for p in Point(3, 4), Point(14, 5/7.): - print (p) - -class Point(namedtuple('Point', 'x y')): - 'Point class with optimized _make() and _replace() without error-checking' - __slots__ = () - _make = classmethod(tuple.__new__) - def _replace(self, _map=map, **kwds): - return self._make(_map(kwds.get, ('x', 'y'), self)) - -print(Point(11, 22)._replace(x=100)) - -Point3D = namedtuple('Point3D', Point._fields + ('z',)) -print(Point3D.__doc__) - -import doctest, collections -TestResults = namedtuple('TestResults', 'failed attempted') -print(TestResults(*doctest.testmod(collections))) |