On Mon, 11 Apr 2022 at 15:25, Stephen J. Turnbull
<[email protected]> wrote:
> [1] They don't have to be big problems or proprietary code; computing
> Fibonacci sequences will do, if you can find a way to make MI relevant
> to that task.
>
Okay, I'll bite. Unfortunately for the OP, super() works perfectly here.
class Fibo0:
def get(self): return 0
def make_fibo(n):
if n <= 0: return Fibo0
if n <= 2:
class Fibo(Fibo0):
def get(self): return super().get() + 1
return Fibo
class Fibo(make_fibo(n - 1), make_fibo(n - 2)):
pass
return Fibo
for i in range(17):
print(i, make_fibo(i)().get())
We shall now hold a funeral for the brain cells lost by everyone who
just read that code.
ChrisA
PS. If you're surprised by the range(17) there, try range(18) and
you'll see how horrific this code is.
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/HTMMGRXEZAVLRDPYNSFOMFTNIMZUJ7WG/
Code of Conduct: http://python.org/psf/codeofconduct/