update from atlas
This commit is contained in:
1 parent
8fb691d3c7
commit
290079ec9a
16 files changed
+803
-2
No files matched your search
@@ -0,0 +1,25 @@
|
||||
"""
|
||||
A class equivalent to the class statement below would be generated by this code:
|
||||
|
||||
>>> import collections
|
||||
>>> Point = collections.plainclass('Point', 'x y')
|
||||
"""
|
||||
|
||||
class Point(object):
|
||||
__slots__ = ['x', 'y'] # save memory in the likely event there are many instances
|
||||
|
||||
def __init__(self, x, y):
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
def __repr__(self):
|
||||
return 'Point({!r}, {!r})'.format(self.x, self.y)
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, Point):
|
||||
return NotImplemented
|
||||
return self.x == other.x and self.y == other.y
|
||||
|
||||
def __iter__(self, other): # support unpacking
|
||||
yield self.x
|
||||
yield self.y
|
||||
Reference in new issue
Block a user