If these examples were possible (I wouldn't say they are smart designs) they would lead to recursion errors. Limitations on MRO are good, they force to keep a quite simple structure. Le jeu. 7 avr. 2022 à 17:41, malmiteria <martin.milon@ensc.fr> a écrit :
Antoine Rozo writes:
If the only feature you need from super is the proxy one, why don't you code your own parent-proxy-type?
I did : https://github.com/malmiteria/super-alternative-to-super/blob/master/parent....
This is irrelevant to the discussion we're having i think. Essentially, I'm arguing against today's state of some edge case of MRO + super, and against the UX associated with it. Those are issues with today's python, and the update that i propose would reduce the UX problems with super and MRO, would allow for use case of super more in line with the expectation of the majority, and would open the door to a few cases locked behind MRO errors today. Technically, with my proposal, you could even do circular inheritance, which is definitely unheard of today: ``` class Day: def tell_time(self): print("it's daytime") sleep(10000) super().tell_time()
class Night(Day): def tell_time(self): print("it's night time") sleep(10000) super().tell_time()
Day.__bases__ = (Night, )
Day().tell_time() # infinitely loops over "it's daytime" and "it's night time" ``` That would be an incredibely easy way to articulate process that repeat in a cycle, with no end, cron style. No need to get multiple class too: ``` class CronTask: def task(self): # do something time.sleep(10000) super().task()
CronTask.__bases__ = (CronTask, )
CronTask().task() # runs the task forever with a time sleep in between ```
I'm convinced there's some smart designs that are banned from python because of MRO and super's limitations. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/BKFSLL... Code of Conduct: http://python.org/psf/codeofconduct/
-- Antoine Rozo