When should I use "parent=None" in __ini__ and "parent" in super()
Randy Johnson
dandyrandy223 at gmail.com
Thu Sep 1 22:02:39 EDT 2022
Those are contradictory for what you are trying to accomplish unless it is a Parent - Child relationship (MainWindow - Window):
When you super() an object, it enherits all the properties from its parent object.
Source:
https://www.w3schools.com/python/python_inheritance.asp
If what you want is 2 windows, you can define 2 instances of both Classes and run both at the end.
```
class User1(object):
def __init__(self, fname, age, parent=None):
self.fname = fname
self.age = int(age)
# Calling the return function that prints the details
self.return_user()
def return_user(self):
print(self.fname)
print(self.age)
class User2(object):
def __init__(self, lname, height, parent=None):
self.lname = lname
self.height = float(height)
self.return_user()
def return_user(self):
print(self.lname)
print(self.height, "CM")
print((self.height / 2.54), "IN")
User1("Hugh", 21)
User2("Janus", 175.26)
```
More information about the Python-list
mailing list