Translating keywords

Lie Lie.1296 at gmail.com
Tue Apr 8 16:52:11 EDT 2008


On Apr 7, 9:54 pm, Steve Holden <st... at holdenweb.com> wrote:
> Ronn Ross wrote:
> > This is my first post and I'm new to Python. How would someone go about
> > adding keywords to Python? It would be great to add support for
> > Esperanto keywords in the language instead of English being the only
> > option.
>
> Unfortunately the resulting language would no longer be Python.
>
> You need to consider software portability: Python has been very
> conservative about declaring words to be "keywords" in the language,
> though clearly words like "def" and "class" must necessarily be part of
> the syntax.
>
> When you start to replace the keywords, though, your programs are no
> longer runnable on all Python installations, and simple transliteration
> fails because sometimes a keyword in one (natural) language will
> conflict with a programmer's choice of name(s) in another.

I think it might be possible to create a translation table, where this
native-language code would be accompanied by an extra file that maps
the replaced keywords with Python keywords. And before the code is
compiled, it's preprocessed to map the native-language keywords to
Python keyword. But I think if such feature is made available, it
would crack the language into lots of sub-languages and that would
make code exchange hard, and it wouldn't be long before people start
being creative and added language support for languages like Klingon
or Pig Latin.

On Apr 8, 12:47 pm, Arnaud Delobelle <arno... at googlemail.com> wrote:
> On Apr 8, 3:47 am, "Gabriel Genellina" <gagsl-... at yahoo.com.ar> wrote:
>
> > Python 3 allows for unicode identifiers, but I don'k know any plans for  
> > using unicode keywords too. Looks funny:
>
> > ∀ x ∈ values:
> >    if x ∉ forbidden ∧ x ≠ y:
> >      print(x, Γ(x), √(x))
> > print(∑(values))
> > near = λ a,b,ε=0.01: a-ε ≤ b ≤ a+ε
>
> It's all in the eye of the beholder: to me it looks readable, but
> that's because I've spent 10 years of my life reading and writing
> stuff like that.  Although I would use ∀ and ∃ as aliases for all()
> and exists() :)
>
> --
> Arnaud

It looks readable to a mathematician, but not to a regular person or
even a regular programmer not specializing in mathematics. And the
single downside why I think using symbols is bad is because you can't
Google with those. And if you don't know Greek (or whatever language
the symbol comes from), you can't even name the symbol to search for
the meaning.



More information about the Python-list mailing list