Re: Translating keywords
On Apr 7, 9:54 pm, Steve Holden <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> wrote: > On Apr 8, 3:47 am, "Gabriel Genellina" <[EMAIL PROTECTED]> 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. -- http://mail.python.org/mailman/listinfo/python-list
Re: Translating keywords
En Tue, 08 Apr 2008 03:28:54 -0300, Arnaud Delobelle <[EMAIL PROTECTED]> escribió: > On Apr 8, 6:47 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > [...] >> Although I would use ∀ and ∃ as aliases for all() >> and exists() :) > > I mean all() and any() of course Yes, I thought about that usage too, but I were looking for *keywords* to replace, and ∀ x ∈ A: f(x) instead of `for x in A: f(x)` was a winner because it uses two of them. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Translating keywords
En Tue, 08 Apr 2008 03:03:13 -0300, Torsten Bronger <[EMAIL PROTECTED]> escribió: > Gabriel Genellina writes: >> >> 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+ε > > As far as I've understood it, only letters are allowed in > identifiers rather than arbitrary Unicode code points. Yes, this was of course a futuristic exercise of imagination, even replacing keywords with some symbols. Anyway the only non-alphabetic identifier is √; Σ could replace ∑, and all others are allowed letters in Python 3. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Translating keywords
On Apr 8, 6:47 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: [...] > Although I would use ∀ and ∃ as aliases for all() > and exists() :) I mean all() and any() of course -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: Translating keywords
Hallöchen! Gabriel Genellina writes: > [...] > > 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+ε As far as I've understood it, only letters are allowed in identifiers rather than arbitrary Unicode code points. Tschö, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: [EMAIL PROTECTED] (See http://ime.webhop.org for further contact info.) -- http://mail.python.org/mailman/listinfo/python-list
Re: Translating keywords
On Apr 8, 3:47 am, "Gabriel Genellina" <[EMAIL PROTECTED]> 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Translating keywords
"Gabriel Genellina" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | En Mon, 07 Apr 2008 14:59:08 -0300, Terry Reedy <[EMAIL PROTECTED]> | escribió: | > If you want other-language keywords, you should either use a translator | > processor or an editor that will do keyword substitution. I do not know | > of | > such but I would not be surprised if there is one. I suspect this sort | > of | > thing will more likely happen with Python 3, which will allow unicode | > keywords. | | Python 3 allows for unicode identifiers, but I don'k know any plans for | using unicode keywords too. Looks funny: There are no official (PSF) plans and I expect there will be not be any for a long time if ever. My 'suspicion' was with respect to very unofficial 3rd party efforts, perhaps not even announced here in English/ascii land. My reasoning: If one is writing in ascii only, then ascii keywords and even English keywords are not so much a burden. But if one is writing comments and strings and identifiers in a different alphabet, then ascii begin to look odd and native character keywords more inviting. -- http://mail.python.org/mailman/listinfo/python-list
Re: Translating keywords
En Mon, 07 Apr 2008 14:59:08 -0300, Terry Reedy <[EMAIL PROTECTED]> escribió: > "Ronn Ross" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > | 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. > > If you want other-language keywords, you should either use a translator > processor or an editor that will do keyword substitution. I do not know > of > such but I would not be surprised if there is one. I suspect this sort > of > thing will more likely happen with Python 3, which will allow unicode > keywords. 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+ε for x in values: if x not in forbidden and x!=y: print(x, gamma(x), math.sqrt(x)) print(sum(values)) near = lambda a,b,eps=0.01: a-eps <= b <= a+eps -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list