Skip to content

Instantly share code, notes, and snippets.

@RyanKor
Created September 6, 2021 12:27
Show Gist options
  • Save RyanKor/a4ffcfc2d9af07d76b7d3e8e66db0bc1 to your computer and use it in GitHub Desktop.
Save RyanKor/a4ffcfc2d9af07d76b7d3e8e66db0bc1 to your computer and use it in GitHub Desktop.
class Gizmo:
def __init__(self):
print("Gizmo id: %d" % id(self))
x = Gizmo()
# Gizmo id : 4301489152
y = Gizmo() * 10
# Gizmo id : 4301489432
'''
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for *: 'Gizmo' and 'int'
>>> dir()
['Gizmo', ..., 'x']
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment