Callable modules?
Max M
maxm at mxm.dk
Wed Jul 24 08:21:35 EDT 2002
Alex Martelli wrote:
> A respectable opinion. Mine is just the reverse -- were it not
> for backwards compatibility, I wouldn't mind losing __call__ in
> instances. A bound method can do it, and we could have a
> _convention_ about how a "primary" method (if any) should be
> named, just as we have for the 'self' argument. It's all
> theoretical anyway, __call__'s never going to go away in fact.
I believe you mean something like:
class WithPrimary:
def WithPrimary_primary(self):
# primary method due to naming conventions
pass
Why is this better than having an explicit __call__ method? Is it
because of a dislike of the "__*__" methods in general?
I must admit that I rarely use the __call__ method, but I have found it
very convenient in some cases.
The funny thing though is that I have found it most usefull when I need
to set up a function in somehing like map(), sort(), filter() etc. where
I need additional data passed to the visitor function, which these
functions does not allow.
So a "shortcomming" in Python is worked around by a strength, if you can
say it like that.
regards Max M
More information about the Python-list
mailing list