Smalltalk blocks in Python

Bijan Parsia bparsia at email.unc.edu
Thu Jan 27 09:32:16 EST 2000


Thierry Thelliez <thierry at acm.org> wrote:

> I come from the Smalltalk world and I am trying to understand Python.
> 
> Is there a Smalltalk blocks equivalent in Python ?
> Java has a pale imitation with Inner classes.
> 

There are lambdas (which are a bit funky). But more importantly, you can
pass functions around (and functions don't need to be defined in a class
context). While there no general syntax (other than lambdas, which have
limitations) for specifying literal anonymous code blocks, you can
certainly use compile, exec, apply, eval, and friends (exec and eval
take code blocks as well as strings).

Now, the thing that *will* trip you up, IMHO, is the lack of class side
*methods* (though there are class attributes).

Cheers,
Bijan Parsia



More information about the Python-list mailing list