MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / ImmutablePoint

Class ImmutablePoint

example_code/item_056.py:79–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77
78print("Example 5")
79class ImmutablePoint:
80 def __init__(self, name, x, y):
81 self.__dict__.update(name=name, x=x, y=y)
82
83 def __setattr__(self, key, value):
84 raise AttributeError("Immutable object: set not allowed")
85
86 def __delattr__(self, key):
87 raise AttributeError("Immutable object: del not allowed")
88
89
90# Verify del is also prevented

Callers 2

item_056.pyFile · 0.70
translate_copyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected