Statespressions? (Re: Draft Pep (was: Re: Let's Talk About Lambda Functions!))

Greg Ewing see_reply_address at something.invalid
Wed Aug 7 05:47:00 CEST 2002

Jonathan Hogg wrote:

> On 6/8/2002 5:11, in article K%H39.4832$7n5.2407 at sccrnsc01, "Emile van
> Sebille" <emile at> wrote:
>>Except for the dict and implied indent level, isn't this a module?
>>import callbacks
>>callbacks = callbacks.__dict__
>>callbacks['case a']
> I thought it was a class... ;-)

It occurred to me while I was writing it that using a class
would be almost as good. But not quite, for various reasons.
First, you don't actually want a class, you want an instance
of a class; either that or wrap all the functions in
classmethod, which would be rather tedious and ugly.

Using a module avoids that problem, but you still have
to import it from somewhere instead of writing it in-line.

In both cases, you either have to access it with getattr,
or do a little dance to get a dict out of it.

All these things add up to a bit more obscurity and a
bit less economy of expression. In my suggestion I was
aiming for maximum possible clarity and lack of crud.

Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand

More information about the Python-list mailing list