This is not a "symbol" (in the sense you mean, @ or $ in Perl and
Ruby), it is a function called (or aliased) "_".
I know its not a symbol in the language sense, but it sure looks like
one to the untrained eye (which was my point, that you apparently
missed).
The GNU gettext tools,
on which Python gettext and TG i18n tools are based, look for this
function call to extract text strings for translation. It is not
"magic
mapping", it is aliasing a function and adding that alias to the
__builtins__ dictionary for convenience.
If you don't think that shoving arbitrary things into __builtins__ is
magic, then you are nuts. Its magic. Its not easy to trace, and the
untrained eye may have no idea where it came from.
If that is bad then one should
also remove other "magic" functions like divmod and list and dict. We
should then go back to coding C and having #include <stdio.h>
before we
can do basic input and output.
<sarcasm>
Yes, thats exactly what I am saying. Lets go back to C. A C-based
TurboGears would be amazing.
</sarcasm>
A project like TurboGears will attract lots of newbies to Python,
potentially coming from PHP, or other such tools. I am almost
certain that the majority of these people will be confused by the
"_", what it means, and where it came from. I just was trying to
avoid this.
Kevin wrote:
I'm not, in general, in favor of magic imports and implicit behavior.
But, i18n is something that likely touches every string in every file,
so a couple of shortcuts make life more pleasant.
Understandable, as long as things don't start down a slippery slope!
Ramming things into __builtins__ for the purposes of a shortcut just
seems like a scary precedent to set. But, its your decision to make,
and you seem to agree that magic is generally bad, so I won't
complain anymore :)
--
Jonathan LaCour
http://cleverdevil.org