Would Anonymous Functions Help in Learning Programming/Python?

Kay Schluehr kay.schluehr at gmx.net
Mon Sep 24 06:23:22 EDT 2007


On Sep 24, 9:09 am, Marc 'BlackJack' Rintsch <bj_... at gmx.net> wrote:

> Python:
>
> class B(object):
>     def __init__(self):
>         self.things = list()
>
>     def add(self, thing):
>         self.things.append(thing)
>
> And Io:
>
> B := Object clone do(
>     init := method(
>         self things := list()
>         self
>     )
>
>     add := method(thing,
>         self things append(thing)
>     )
> )
>
> The `init` is called by the default `clone` method automatically just like
> `__init__()` in Python.  It is really much like the class/instance
> relationship in Python with just the line between class and instance
> blurred.

[...]

> Ciao,
>         Marc 'BlackJack' Rintsch

O.K. Marc, I'm convinced by the examples you presented. So init is
also special in Io and is called at the clone event to fill object
slots with data.

Now I have to track back in the discussion thread to remember why we
started to talk about Io...




More information about the Python-list mailing list