- #1
user366312
Gold Member
- 88
- 3
- TL;DR Summary
- Is there any difference between these three listings?
listing1.py:
class MyClass:
def set(self, x, y):
self.x = x
self.y = y
obj = MyClass()
obj.set(10, "Integer")
print(obj.x)
print(obj.y)
listing2.py:
class MyClass:
pass
obj = MyClass()
obj.x = 10
obj.y = "Integer"
print(obj.x)
print(obj.y)
listing3.py:
class MyClass:
x = 0;
y = ""
def set(self, x, y):
self.x = x
self.y = y
obj = MyClass()
obj.set(10, "Integer")
print(obj.x)
print(obj.y)
Is there any **practical** difference between these three listings?
What is the **theoretical** difference between these three listings?