[Python-Dev] Re: Alternative Implementation for PEP 292: Simple
pf_moore at yahoo.co.uk
Sun Aug 29 15:48:19 CEST 2004
"Raymond Hettinger" <python at rcn.com> writes:
> I'm not sure what to do next. Aside from Aahz, no one on python-dev
> seems to be interested and Barry appears to have been off-line for a few
> days. Ideally, I would like to get this in a few days ahead of the
> alpha release.
I'm not too worried either way, as I don't think that this will be
something I use a lot (I may be wrong, though..)
Having said that, I do feel that your points should be addressed. I
haven't looked at either implementation, but I'd assume that the key
benefit of a class-based implementation would be the ability to
subclass to modify behaviour. If that isn't happening in practice,
then I agree that a function is probably a better option.
As a test case, how would I implement the case that has come up here
recently, of supporting $obj.attr substitutions, in each of the two
implementations? It would be interesting to see the relative
simplicity. I'm assuming that the function-based case would require
effectively a cut & paste reimplementation.
[FX: Dives into source code...]
The Template class is pretty trivial, but it doesn't seem to be
designed for extension. Thus, the above test case would *still* need
pretty much a rewrite. However, if the Template class was rewritten
with overriding in mind, it probably could make things easier:
1. Split the match pattern into pieces, such that adding new syntax
like $obj.attr is just a case of adding a new pattern to a list.
2. Make the __mod__ code more case-like, having separate actions
based on group name. Then overriding code could just add actions
for the groups it added, and call the base class for the rest.
This isn't fully thought through, and may well not be worth it in
practice, but it gives the sort of benefits I'd expect from a
Home computers are being called upon to perform many new functions,
including the consumption of homework formerly eaten by the dog --
More information about the Python-Dev