X-Received: by 2002:a37:9b16:: with SMTP id d22mr6116326qke.22.1633752799378; Fri, 08 Oct 2021 21:13:19 -0700 (PDT) X-Received: by 2002:a05:6808:1292:: with SMTP id a18mr10436410oiw.42.1633752799131; Fri, 08 Oct 2021 21:13:19 -0700 (PDT) Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: de.comp.lang.python Date: Fri, 8 Oct 2021 21:13:18 -0700 (PDT) In-Reply-To: <10908767.Al5bunHUc5@xrated> Injection-Info: google-groups.googlegroups.com; posting-host=2001:1711:fa54:36a0:c459:2919:2bd:5bd; posting-account=BtTavwoAAACMi3AFrA3U-JBERbxGUGhD NNTP-Posting-Host: 2001:1711:fa54:36a0:c459:2919:2bd:5bd References: <10908767.Al5bunHUc5@xrated> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: [Python-de] Re: When should I use "parent=None" in __ini__ and From: Mohsen Owzar Injection-Date: Sat, 09 Oct 2021 04:13:19 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Lines: 69 Xref: csiph.com de.comp.lang.python:5745 Hans-Peter Jansen schrieb am Freitag, 8. Oktober 2021 um 18:11:14 UTC+2: > Mohsen,=20 >=20 > in deutschen Usergruppen solltest du dir die Arbeit machenm, auch deutsch= zu=20 > schreiben.=20 >=20 > Die Antwort auf diese Frage habe ich dir schon in der vorherigen Mail geg= eben.=20 >=20 > Cheers,=20 > Pete > Am Freitag, 8. Oktober 2021, 12:17:15 CEST schrieb Mohsen Owzar:=20 > > When should I use "parent=3DNone" in __ini__ and "parent" in super()=20 > > Hi Guys=20 > > I've sent this question to other Python community but didn't get any an= swer.=20 > > I hope that here I can get an explanation of how to use parent in the= =20 > > Python OOP.=20 > >=20 > > I'm writing since almost one-year codes in Python, using TKinter and Py= Qt5.=20 > > I'm somehow able to writes GUIs in both of them.=20 > >=20 > > But since I'm using more Pyqt5 and using classes with initialization an= d=20 > > super() constructs, and also I saw lots of videos and examples of codin= g=20 > > them, I still don=E2=80=99t know exactly how and when should I use the = parent in=20 > > __init()__ and super() construct.=20 > >=20 > > For example, the following lines use "parent=3DNone" in the __init__ co= nstruct=20 > > and "parent" in the super() construct. And sometimes I do not see any o= f=20 > > them in these two constructs.=20 > >=20 > > class MyClass1(QWidget):=20 > > def __init__(self, name, parent=3DNone):=20 > > super(MyClass1, self).__init__(parent)=20 > > print(self.parent().test)=20 > >=20 > > And sometimes without "parent" like the following:=20 > >=20 > > class MyClass2(QWidget):=20 > > def __init__(self, name):=20 > > super(MyClass2, self).__init__()=20 > > print(self.parent().test)=20 > >=20 > > Could anyone explain this to me when and for which action I have to use= the=20 > > first one "MyClass1" and when the second one "MyClass2"?=20 > >=20 > > Mohsen > > _______________________________________________=20 > > python-de Mailingliste -- pyth...@python.org=20 > > Zur Abmeldung von dieser Mailingliste senden Sie eine Nachricht an=20 > > python-...@python.org=20 > > https://mail.python.org/mailman3/lists/python-de.python.org/=20 > > Mitgliedsadresse: h...@urpla.net Danke Hans-Peter Ich habe gerade in der anderen Frage alles auf Deutsch vertieft erkl=C3=A4r= t und meine Frage noch einmal am Ende auf Deutsch gebracht. Gruss Mohsen