Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #94106
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] |
| Date | 2015-07-19 04:26 -0400 |
| References | (1 earlier) <moeqtn$mh0$1@ger.gmane.org> <moeurf$a6f$1@ger.gmane.org> <mailman.695.1437273248.3674.python-list@python.org> <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.705.1437294417.3674.python-list@python.org> (permalink) |
On 7/19/2015 12:45 AM, Steven D'Aprano wrote:
> On Sun, 19 Jul 2015 01:52 pm, Rustom Mody wrote:
>> JFTR: My kids (um... students) have just managed to add devanagari
>> numerals to python.
>> ie we can now do
>>
>>>>> १ + २
>> 3
>
> That is actually quite awesome, and I would support a new feature that set
> the numeric characters to a particular script, e.g. Latin, Arabic,
> Devanagari, whatever, and printed them in that same script. It seems
> unfortunate that १ + २ prints as 3 rather than ३.
>
> Python already, and has for many years, supported non-ASCII digits in string
> conversions. This is in Python 2.4:
>
> py> int(u'१२')
> 12
> py> float(u'.१२')
> 0.12
>
>
> so the feature goes back a long time.
>
> I think that Python should allow int and float literals using any sequences
> of digits from the same language, e.g. 12 or १२ but not १2.
This could be done easily by adding 10 modified productions from
https://docs.python.org/3/reference/lexical_analysis.html#integer-literals
for each language. The problem of doing the above in the grammar,
including the no mixing rule, is that is *would* take a separate set of
productions for each language supported.
> One might have
> an interpreter hook which displayed ints and floats using non-ASCII digits,
> or one might even build that function into the intepreter, e.g. have a
> global setting which tells ints and floats what digits to use, e.g.:
>
> sys.setdigits('Devanagari')
>
> I would support this, or something like this, as a language feature. If we
> can write Python using Hindi identifiers, why not Hindi numerals?
As I remember, when non-ascii-digit inputs to int were last discussed
(python-ideas?, pydev?), the possibility of expanding literals was
mentioned. As I remember, to idea was rejected or deferred on the basis
that nearly all numbers used in production programs are read from files
as numbers or converted by int or float. The few numeric literals in
programs could just as well be converted first, or the int expression
could be used.
These true observations do not cover the shell, as in the examples
above. At some time, Guido has expresses the opinion that interactive
console python should remain plain and basic and the fancier interaction
features are the domain of replacement shells.
That brings me, anyway, to Idle. It currently imitates console python
in sending keystrokes as is to compile() and output streams as are to
the tk display. There are a couple of tracker issues claiming that this
means that Idle does not imitate console python because a tk display
does not treat backspace and return the same way simulated terminal
consoles usually do.
While the bug claims have been rejected, I have been thinking that the
Idle extension interface could and maybe should be extended so that
extensions could filter and either transform or act on the input/output
streams.
With a general mechanism in place, it would be trivial to use
str.maketrans and str.translate in the input/output streams. This would
not disable ascii digit input, including mixtures in a single literal,
but output has to all be in one digit set. Selecting a language is a
somewhat solved problem because last summer we added a extension
configuration dialog that dynamically generates a dialog tab for each
extension present.
--
Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Should non-security 2.7 bugs be fixed? Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-07-18 19:33 -0700
Re: Should non-security 2.7 bugs be fixed? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-07-18 19:49 -0700
Re: Should non-security 2.7 bugs be fixed? Rustom Mody <rustompmody@gmail.com> - 2015-07-18 20:52 -0700
Re: Should non-security 2.7 bugs be fixed? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-07-18 21:18 -0700
Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Steven D'Aprano <steve@pearwood.info> - 2015-07-19 14:45 +1000
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Chris Angelico <rosuav@gmail.com> - 2015-07-19 15:06 +1000
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-07-19 10:16 +0300
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-19 00:32 -0700
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-07-19 10:44 +0300
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Terry Reedy <tjreedy@udel.edu> - 2015-07-19 19:13 -0400
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-19 19:02 -0700
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Anuradha Laxminarayan <lanuradha@gmail.com> - 2015-07-18 23:25 -0700
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Terry Reedy <tjreedy@udel.edu> - 2015-07-19 04:26 -0400
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Tim Chase <python.list@tim.thechases.com> - 2015-07-19 07:56 -0500
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Chris Angelico <rosuav@gmail.com> - 2015-07-20 04:07 +1000
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Tim Chase <python.list@tim.thechases.com> - 2015-07-19 14:55 -0500
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Chris Angelico <rosuav@gmail.com> - 2015-07-20 07:16 +1000
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] wxjmfauth@gmail.com - 2015-07-20 00:43 -0700
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] MRAB <python@mrabarnett.plus.com> - 2015-07-19 23:13 +0100
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-20 20:30 -0700
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Chris Angelico <rosuav@gmail.com> - 2015-07-21 13:43 +1000
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-20 23:11 -0700
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Laura Creighton <lac@openend.se> - 2015-07-21 10:10 +0200
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-07-21 12:10 +0300
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Chris Angelico <rosuav@gmail.com> - 2015-07-21 19:18 +1000
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-07-21 13:13 +0300
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-21 11:34 +0100
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-07-21 20:39 +1000
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-07-21 13:54 +0300
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-08-09 00:27 +0300
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-08-09 09:29 -0700
Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-22 06:34 -0700
OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Steven D'Aprano <steve@pearwood.info> - 2015-07-23 02:58 +1000
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Laura Creighton <lac@openend.se> - 2015-07-22 19:17 +0200
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-22 10:49 -0700
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Laura Creighton <lac@openend.se> - 2015-07-22 20:14 +0200
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-22 21:59 +0100
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Steven D'Aprano <steve@pearwood.info> - 2015-07-23 03:21 +1000
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-07-22 21:44 -0400
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Chris Angelico <rosuav@gmail.com> - 2015-07-23 12:00 +1000
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Paul Rubin <no.email@nospam.invalid> - 2015-07-22 10:48 -0700
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-22 10:51 -0700
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-07-23 15:14 +1000
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-22 11:09 -0700
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-07-23 15:41 +1000
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-07-23 23:59 +0300
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Chris Angelico <rosuav@gmail.com> - 2015-07-24 07:03 +1000
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-07-24 00:29 +0300
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-23 22:50 +0100
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Laura Creighton <lac@openend.se> - 2015-07-23 23:52 +0200
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-07-24 00:59 +0300
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Chris Angelico <rosuav@gmail.com> - 2015-07-24 08:02 +1000
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Chris Angelico <rosuav@gmail.com> - 2015-07-24 08:00 +1000
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] MRAB <python@mrabarnett.plus.com> - 2015-07-23 23:01 +0100
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Laura Creighton <lac@openend.se> - 2015-07-24 00:19 +0200
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-23 23:56 +0100
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Grant Edwards <invalid@invalid.invalid> - 2015-07-24 00:07 +0000
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rick Johnson <rantingrickjohnson@gmail.com> - 2015-07-23 18:40 -0700
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Paul Rubin <no.email@nospam.invalid> - 2015-07-23 19:03 -0700
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rick Johnson <rantingrickjohnson@gmail.com> - 2015-07-23 20:16 -0700
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Grant Edwards <invalid@invalid.invalid> - 2015-07-24 14:13 +0000
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Paul Rubin <no.email@nospam.invalid> - 2015-07-24 08:45 -0700
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-24 16:58 +0100
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-23 22:15 -0700
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-07-23 18:57 +1200
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-23 02:12 -0700
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-23 05:52 -0700
Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-07-23 11:24 +0300
Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-07-21 18:57 +1000
Re: Should non-security 2.7 bugs be fixed? Terry Reedy <tjreedy@udel.edu> - 2015-07-19 02:44 -0400
Re: Should non-security 2.7 bugs be fixed? Terry Reedy <tjreedy@udel.edu> - 2015-07-19 05:11 -0400
Re: Should non-security 2.7 bugs be fixed? Rustom Mody <rustompmody@gmail.com> - 2015-07-19 07:30 -0700
Re: Should non-security 2.7 bugs be fixed? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-19 15:00 +0100
Re: Should non-security 2.7 bugs be fixed? Steven D'Aprano <steve@pearwood.info> - 2015-07-19 14:45 +1000
Re: Should non-security 2.7 bugs be fixed? Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-07-19 18:20 -0700
Re: Should non-security 2.7 bugs be fixed? Steven D'Aprano <steve@pearwood.info> - 2015-07-20 13:05 +1000
Re: Should non-security 2.7 bugs be fixed? Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-07-19 20:41 -0700
Re: Should non-security 2.7 bugs be fixed? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-20 02:46 +0100
Re: Should non-security 2.7 bugs be fixed? Rustom Mody <rustompmody@gmail.com> - 2015-07-19 19:16 -0700
Re: Should non-security 2.7 bugs be fixed? Chris Angelico <rosuav@gmail.com> - 2015-07-20 12:59 +1000
Re: Should non-security 2.7 bugs be fixed? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-20 11:59 +0100
Re: Should non-security 2.7 bugs be fixed? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-07-20 20:04 -0700
Re: Should non-security 2.7 bugs be fixed? Rustom Mody <rustompmody@gmail.com> - 2015-07-20 20:15 -0700
Re: Should non-security 2.7 bugs be fixed? Chris Angelico <rosuav@gmail.com> - 2015-07-21 13:33 +1000
Re: Should non-security 2.7 bugs be fixed? Terry Reedy <tjreedy@udel.edu> - 2015-07-21 00:45 -0400
Re: Should non-security 2.7 bugs be fixed? breamoreboy@gmail.com - 2015-07-21 14:22 -0700
Re: Should non-security 2.7 bugs be fixed? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-07-21 19:07 -0700
Re: Should non-security 2.7 bugs be fixed? Terry Reedy <tjreedy@udel.edu> - 2015-07-22 02:51 -0400
Re: Should non-security 2.7 bugs be fixed? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-07-22 16:37 -0700
Re: Should non-security 2.7 bugs be fixed? Terry Reedy <tjreedy@udel.edu> - 2015-07-20 02:25 -0400
Re: Should non-security 2.7 bugs be fixed? dieter <dieter@handshake.de> - 2015-07-20 08:58 +0200
Re: Should non-security 2.7 bugs be fixed? Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-07-20 00:13 -0700
csiph-web