Re: Better use a class decorator or a metaclass?(was: super not behaving as I expected)

2020-04-04 Thread Souvik Dutta
I think this should help https://stackoverflow.com/questions/1779372/python-metaclasses-vs-class-decorators On Sat, 4 Apr, 2020, 6:12 pm Antoon Pardon, wrote: > Op 29/03/20 om 16:49 schreef Peter Otten: > > Antoon Pardon wrote: > > > >> > >> I have the following program > >> > >> class slt: > >>

Better use a class decorator or a metaclass?(was: super not behaving as I expected)

2020-04-04 Thread Antoon Pardon
Op 29/03/20 om 16:49 schreef Peter Otten: > Antoon Pardon wrote: > >> >> I have the following program >> >> class slt: >> __slots__ = () >> ... >> >> class slt1 (slt): >> __slots__ = 'fld1', 'fld2' >> ... >> >> class slt2(slt1): >> __slots__ = 'fld3', >> > Anyway, here's my attempt to

Re: super not behaving as I expected

2020-03-29 Thread Peter Otten
Antoon Pardon wrote: > > I have the following program > > class slt: > __slots__ = () > > def getslots(self): > print("### slots =", self.__slots__) > if self.__slots__ == (): > return [] > else: > ls = super().getslots() > ls.extend(self.__slots__) > return ls > > def __str__(self): > ls = []

super not behaving as I expected

2020-03-29 Thread Antoon Pardon
I have the following program class slt: __slots__ = () def getslots(self): print("### slots =", self.__slots__) if self.__slots__ == (): return [] else: ls = super().getslots()