TelenkovDmitry hace 6 meses
padre
commit
bfda40a419
Se han modificado 1 ficheros con 23 adiciones y 0 borrados
  1. 23 0
      courses/python_oop/inheritance/slots.py

+ 23 - 0
courses/python_oop/inheritance/slots.py

@@ -0,0 +1,23 @@
+
+class Point:
+
+    def __init__(self, x, y):
+        self.x = x
+        self.y = y
+
+
+class PointSlots:
+
+    # Теперь __dict__ не будет и нельзя будет создавать новые атрибуты.
+    __slots__ = {'x', 'y'}
+
+    def __init__(self, x, y):
+        self.x = x
+        self.y = y
+
+
+def main():
+    pass
+    
+if __name__ == '__main__':
+    main()