Thread View: pl.comp.lang.python
3 messages
3 total messages
Started by Jax
Tue, 24 Mar 2009 10:19
super - czyli wywoływanie metod przodka
Author: Jax
Date: Tue, 24 Mar 2009 10:19
Date: Tue, 24 Mar 2009 10:19
28 lines
1494 bytes
1494 bytes
Witam
Mam problem z super. Jest taka klasa:
class FiltersFileModel(QtCore.QAbstractTableModel):
...
def flags(self, aIndex):
lDefaultFlags = super(FiltersFileModel, self).flags(aIndex)
...
I to nie działa. Na razie robię coś takiego:
lDefaultFlags = QtCore.QAbstractTableModel.flags(self, aIndex)
Czyli jakby w stylu C++. Ale zależy Mi by zaćwiczyć super by móc pisać w
Pythonie normalnie.
Wie ktoś czemu nie działa
lDefaultFlags = super(FiltersFileModel, self).flags(aIndex)
?
Mi się wydaje to analogiczne z przykładem z dokumentacji Pythona:
class C(B):
def method(self, arg):
super(C, self).method(arg)
Jax
Re: super - czyli wywoływanie metod przodka
Author: Rob Wolfe
Date: Tue, 24 Mar 2009 11:28
Date: Tue, 24 Mar 2009 11:28
33 lines
2031 bytes
2031 bytes
Jax napisał(a): > Witam > > Mam problem z super. Jest taka klasa: > > class FiltersFileModel(QtCore.QAbstractTableModel): > ... > def flags(self, aIndex): > lDefaultFlags = super(FiltersFileModel, self).flags(aIndex) > ... > > I to nie działa. Na razie robię coś takiego: > > lDefaultFlags = QtCore.QAbstractTableModel.flags(self, aIndex) > > Czyli jakby w stylu C++. Ale zależy Mi by zaćwiczyć super by móc pisać w > Pythonie normalnie. > > Wie ktoś czemu nie działa > lDefaultFlags = super(FiltersFileModel, self).flags(aIndex) > ? > > Mi się wydaje to analogiczne z przykładem z dokumentacji Pythona: > class C(B): > def method(self, arg): > super(C, self).method(arg) Pewnie przyczyna lezy tutaj: http://docs.huihoo.com/pyqt/pyqt4.html#super-and-pyqt-classes RW
Re: super - czyli wywoływanie metod przodka
Author: Jax
Date: Tue, 24 Mar 2009 16:43
Date: Tue, 24 Mar 2009 16:43
8 lines
1151 bytes
1151 bytes
> Pewnie przyczyna lezy tutaj: > http://docs.huihoo.com/pyqt/pyqt4.html#super-and-pyqt-classes Dzięki. W między czasie znalazłem coś podobnego: http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/pyqt4ref.html#id42 Jax
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads