enhancing module objects (was Re: 2001 Enchancement Wishlist)

Alex Martelli aleaxit at yahoo.com
Sat Jan 6 04:18:24 EST 2001


> > Recognizing (e.g.) a "def __setattr__" at module-level as providing
> > a similar function to a similarly-named method in a class instance
> > would (in my opinion) not 'complicate' the Python language: it would
> > just extend an already-existing concept
>
> For the record, I'm heavily +1 on the concept. Sadly it's sure
> not to make it to 2.1, as the PEP deadline is due. But you can
> write a PEP which will be considered for 2.2.

OK, but, as I kept on musing in the other post, I'm not sure adding this
(recognition of a __setattr__ function in a module object) is the best
way to provide the related functionality -- as opposed to similar work
on dictionary objects themselves (so that modules, and anything else
using a dictionary, can equally benefit) OR just accepting any suitable
mapping object where currently only real builtin dictionaries can go, an
often-mooted concept.

I think the latter approach would be 'simplest' _from a Python user's
viewpoint_ -- in fact, I think most budding Pythonistas are _surprised_
to learn that in certain roles they cannot use (e.g.) an instance of a
UserDict-derived class of their own, but only a real bona fide builtin
dict object will do.  One gets so used to the convenience and power
of "anything implementing such-and-such interface goes here".  And I
gather an existing PEP raises just this restriction in a different context
(I forget whether it was exec, eval, or both).

I guess I'm still not fully clear on the PEP concept: is it appropriate when
a range of possible approaches to providing a certain functionality are
still under consideration, or only when one single approach is being
proposed?  The lack of a formal arrangement for specifically discussing
a given PEP sort of suggests the latter -- in which case discussing it a
bit more here might be a better preliminary...?


Alex



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com





More information about the Python-list mailing list