Would Anonymous Functions Help in Learning Programming/Python?

Cristian super.sgt.pepper at gmail.com
Mon Sep 24 00:07:41 EDT 2007


On Sep 21, 5:21 pm, Bruno Desthuilliers
<bdesth.quelquech... at free.quelquepart.fr> wrote:

> Ok, then what about classes ? They also are objects-like-any-other,
> after all. So should we have this syntax too ?
>
> MyClass = class(ParentClass):
>    __init__ = function (self, name):
>      self.name = name
>
> ?-)

For consistency I would suggest this, but Python already does this!

Foo = type('Foo', (object, ), {'bar': lambda self, bar: bar})

I've created a new class and then binded it to name afterwards. If you
can import modules without special syntax and you can create classes
without special syntax, why should functions be treated any
differently?




More information about the Python-list mailing list