[Python-Dev] PEP 292: method names
barry at python.org
Mon Sep 13 16:42:12 CEST 2004
On Sat, 2004-09-11 at 07:54, Erik Heneryd wrote:
> * Too long
> 10/15 character names for something so simple it up until now just
> needed a %? Programs using templates will probably use them
> frequently... I'd prefer sub instead of substitute.
Noted, thanks. In general I'm not a fan of abbreviations in APIs
though. Also note that it is trivial for applications to derive and
override __mod__(), aliasing it to whichever version of substitute()
they want. For example, I plan on multiply inheriting Template and
unicode, and aliasing __mod__() to safe_substitute().
> * Safe?
> safe_substitution doesn't tell you much upon first glance. Safe? In
> what way? You could even argue that the "plain" version really is the
> safer one, as you'll notice typos and thus get a more solid program. I
> think a name hinting that this method uses the var name as a fallback
> would be better, but can't think of (a short) one... defaultsub?
> fallbacksub? loosesub? Guess I could live with safe, but...
Yeah, that's the problem, there are no good alternatives. As for which
version is "safer", when you're using Templates in an i18n environment,
where the actual Template you're going to be interpolating into comes
from 3rd party language translation teams, the safe_substitute() version
is definitely safer to the application.
Thanks for the feedback.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-dev/attachments/20040913/edf62152/attachment.pgp
More information about the Python-Dev