user366312
Gold Member
- 88
- 3
- TL;DR Summary
- Is there any difference between these three listings?
[CODE lang="python" title="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)
[/CODE]
[CODE lang="python" title="listing2.py"]
class MyClass:
pass
obj = MyClass()
obj.x = 10
obj.y = "Integer"
print(obj.x)
print(obj.y)
[/CODE]
[CODE lang="python" title="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)
[/CODE] Is there any **practical** difference between these three listings?
What is the **theoretical** difference between these three listings?
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)
[/CODE]
[CODE lang="python" title="listing2.py"]
class MyClass:
pass
obj = MyClass()
obj.x = 10
obj.y = "Integer"
print(obj.x)
print(obj.y)
[/CODE]
[CODE lang="python" title="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)
[/CODE] Is there any **practical** difference between these three listings?
What is the **theoretical** difference between these three listings?