Re: Proposal: Decimal literals in Python.

2009-07-14 Thread MRAB
Scott David Daniels wrote: Tim Roberts wrote: My favorite notation for this comes from Ada, which allows arbitrary bases from 2 to 16, and allows for underscores within numeric literals: x23_bin : constant := 2#0001_0111#; x23_oct : constant := 8#27#; x23_dec : constant := 10#23#; x2

Re: Proposal: Decimal literals in Python.

2009-07-14 Thread Scott David Daniels
Tim Roberts wrote: My favorite notation for this comes from Ada, which allows arbitrary bases from 2 to 16, and allows for underscores within numeric literals: x23_bin : constant := 2#0001_0111#; x23_oct : constant := 8#27#; x23_dec : constant := 10#23#; x23_hex : constant := 16#17#;

[OT] Re: Proposal: Decimal literals in Python.

2007-10-28 Thread Gabriel Genellina
En Fri, 26 Oct 2007 23:28:31 -0300, Carl Banks <[EMAIL PROTECTED]> escribi�: > FYI: The $ sign is used to denote currency in many countries; as a > rule of thumb countties that call their currency "dollars" or "pesos" > use the $. So Mexico, Canada, Australia, much of Latin America, much > of t

Re: Proposal: Decimal literals in Python.

2007-10-28 Thread Tim Roberts
"Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: >"Paul Hankin" wrote: > >> Even clearer is not to allow octal literals :) Is there *any* use for >> them? > >I tend to agree with this point of view - but I fear it will set up a howl >of protest amongst the Brits who cut their teeth on 24 bit ICT/IC

Re: Proposal: Decimal literals in Python.

2007-10-28 Thread Tim Roberts
MRAB <[EMAIL PROTECTED]> wrote: >On Oct 27, 12:12 am, Ben Finney <[EMAIL PROTECTED]> >wrote: >> Matimus <[EMAIL PROTECTED]> writes: >> > The trailing L [for 'long' literals] is going away in Python 3.0. >> >> Yes. On the other hand, we are gaining '0b' for binary literals, >> to go along with

Re: Proposal: Decimal literals in Python.

2007-10-28 Thread Hendrik van Rooyen
"Paul Hankin" wrote: > Even clearer is not to allow octal literals :) Is there *any* use for > them? I tend to agree with this point of view - but I fear it will set up a howl of protest amongst the Brits who cut their teeth on 24 bit ICT/ICL equipment... - Hendrik -- http://mail.python.org

Re: Proposal: Decimal literals in Python.

2007-10-27 Thread Neil Cerutti
On 2007-10-27, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Sat, 27 Oct 2007 13:28:02 -0500, Tim Chase wrote: > Even clearer is not to allow octal literals :) Is there *any* use for them? >>> >>> The mode argument to os.chmod. >> >> You mean instead of >> >> import this >

Re: Proposal: Decimal literals in Python.

2007-10-27 Thread J. Cliff Dyer
Marc 'BlackJack' Rintsch wrote: > On Sat, 27 Oct 2007 13:28:02 -0500, Tim Chase wrote: > > Even clearer is not to allow octal literals :) Is there *any* use for them? >>> The mode argument to os.chmod. >>> >> You mean instead of >> >> import this >> os.chmod(fi

Re: Proposal: Decimal literals in Python.

2007-10-27 Thread Marc 'BlackJack' Rintsch
On Sat, 27 Oct 2007 13:28:02 -0500, Tim Chase wrote: >>> Even clearer is not to allow octal literals :) Is there *any* use for >>> them? >> >> The mode argument to os.chmod. > > You mean instead of > > import this > os.chmod(filename, os.R_OK | os.W_OK | os.X_OK) > > which explicitly (rath

Re: Proposal: Decimal literals in Python.

2007-10-27 Thread Tim Chase
>> Even clearer is not to allow octal literals :) Is there *any* use for >> them? > > The mode argument to os.chmod. You mean instead of import this os.chmod(filename, os.R_OK | os.W_OK | os.X_OK) which explicitly (rather than implicitly) spells it out? -tkc -- http://mail.python.org/m

Re: Proposal: Decimal literals in Python.

2007-10-27 Thread Dan Bishop
On Oct 27, 10:27 am, Paul Hankin <[EMAIL PROTECTED]> wrote: > On Oct 27, 3:09 pm, MRAB <[EMAIL PROTECTED]> wrote: > > > > > On Oct 27, 12:12 am, Ben Finney <[EMAIL PROTECTED]> > > wrote:> Matimus <[EMAIL PROTECTED]> writes: > > > > The trailing L [for 'long' literals] is going away in Python 3.0. >

Re: Proposal: Decimal literals in Python.

2007-10-27 Thread Tim Chase
> Even clearer is not to allow octal literals :) Is there *any* use for > them? +1 I find that anything I have even the remotest inkling of using octal for can be done just as easily with hex. -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: Proposal: Decimal literals in Python.

2007-10-27 Thread Paul Hankin
On Oct 27, 3:09 pm, MRAB <[EMAIL PROTECTED]> wrote: > On Oct 27, 12:12 am, Ben Finney <[EMAIL PROTECTED]> > wrote:> Matimus <[EMAIL PROTECTED]> writes: > > > The trailing L [for 'long' literals] is going away in Python 3.0. > > > Yes. On the other hand, we are gaining '0b' for binary literals,

Re: Proposal: Decimal literals in Python.

2007-10-27 Thread MRAB
On Oct 27, 12:12 am, Ben Finney <[EMAIL PROTECTED]> wrote: > Matimus <[EMAIL PROTECTED]> writes: > > The trailing L [for 'long' literals] is going away in Python 3.0. > > Yes. On the other hand, we are gaining '0b' for binary literals, > to go along with '0o' for octal and '0x' for hexa

Re: Proposal: Decimal literals in Python.

2007-10-27 Thread Raymond Hettinger
On Oct 26, 1:54 am, Lennart Benschop <[EMAIL PROTECTED]> wrote: > My proposal: > - Any decimal constant suffixed with the letter "D" or "d" will be > interpreted as a literal of the Decimal type. This also goes for > decimal constants with exponential notation. There's nothing new here that ha

Re: Proposal: Decimal literals in Python.

2007-10-26 Thread Paul Rubin
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> writes: > assert 0b1 is 0x1 > That this doesn't raise `AssertionError` is an implementation detail. > It's not guaranteed the two objects are really the same. I think Ben is getting at 0b1 and 0x1 being the same type, while the proposed 0d1 is a d

Re: Proposal: Decimal literals in Python.

2007-10-26 Thread Marc 'BlackJack' Rintsch
On Fri, 26 Oct 2007 19:29:47 -0400, J. Cliff Dyer wrote: > Ben Finney wrote: >> So, the original poster might get further by proposing an '0dNNN.NNN' >> syntax for 'decimal.Decimal' literals. > It would rather be remarkably inconsistent and confusing. > > Python 3.0a1 (py3k:57844, Aug 31 2007,

Re: Proposal: Decimal literals in Python.

2007-10-26 Thread Terry Reedy
"Shane Geiger" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] a buggy hack (copying your top post style) >>> D(123456789.123456789) Decimal("123456789.123") Or what there an unwritten :-)? | D = lambda x: decimal.Decimal(str(x)) | | >> D(3.2) | Decimal("3.2") -- http://mail.

Re: Proposal: Decimal literals in Python.

2007-10-26 Thread Carl Banks
On Oct 26, 7:17 pm, "J. Cliff Dyer" <[EMAIL PROTECTED]> wrote: > Matimus wrote: > >> - Traling characters at the end of a literal are already used (the L > >> for long). > > > The trailing L is going away in Python 3.0. For your consideration may > > I suggest a '$' prefix. Though, I'm not sure I

Re: Proposal: Decimal literals in Python.

2007-10-26 Thread J. Cliff Dyer
Ben Finney wrote: > Matimus <[EMAIL PROTECTED]> writes: > > >> The trailing L [for 'long' literals] is going away in Python 3.0. >> > > Yes. On the other hand, we are gaining '0b' for binary literals, > to go along with '0o' for octal and '0x' for hexadecimal. > > So, the origin

Re: Proposal: Decimal literals in Python.

2007-10-26 Thread J. Cliff Dyer
Matimus wrote: >> - Traling characters at the end of a literal are already used (the L >> for long). >> > > The trailing L is going away in Python 3.0. For your consideration may > I suggest a '$' prefix. Though, I'm not sure I even support the idea > of a decimal literal, and I'm not even s

Re: Proposal: Decimal literals in Python.

2007-10-26 Thread Ben Finney
Matimus <[EMAIL PROTECTED]> writes: > The trailing L [for 'long' literals] is going away in Python 3.0. Yes. On the other hand, we are gaining '0b' for binary literals, to go along with '0o' for octal and '0x' for hexadecimal. So, the original poster might get further by proposing an

Re: Proposal: Decimal literals in Python.

2007-10-26 Thread Matimus
> - Traling characters at the end of a literal are already used (the L > for long). The trailing L is going away in Python 3.0. For your consideration may I suggest a '$' prefix. Though, I'm not sure I even support the idea of a decimal literal, and I'm not even sure if I support the idea of usi

Re: Proposal: Decimal literals in Python.

2007-10-26 Thread Shane Geiger
D = lambda x: decimal.Decimal(str(x)) >> D(3.2) Decimal("3.2") Steven D'Aprano wrote: > On Fri, 26 Oct 2007 19:19:46 +1000, Ben Finney wrote: > > >>> Of course we can intruduce a single character function name as an alias >>> for the Decimal type constructor, but even then we have to use bo

Re: Proposal: Decimal literals in Python.

2007-10-26 Thread Ben Finney
Steven D'Aprano <[EMAIL PROTECTED]> writes: > On Fri, 26 Oct 2007 19:19:46 +1000, Ben Finney wrote: > > Nor should we. A function or type name should be short but > > explicit, and 'Decimal' is about as short as I'd want. > > You don't like str, int, float, list, set, dict, or bool? They'd all m

Re: Proposal: Decimal literals in Python.

2007-10-26 Thread Steven D'Aprano
On Fri, 26 Oct 2007 19:19:46 +1000, Ben Finney wrote: >> Of course we can intruduce a single character function name as an alias >> for the Decimal type constructor, but even then we have to use both >> parentheses and quotes for each and every decimal constant. We cannot >> make it shorter than D

Re: Proposal: Decimal literals in Python.

2007-10-26 Thread Ben Finney
Lennart Benschop <[EMAIL PROTECTED]> writes: > Python has had the Decimal data type for some time now. Since version 2.4 http://www.python.org/dev/peps/pep-0327>. > Unfortunately it is not very easy to access the Decimal data > type. To obtain the decimal number 12.34 one has to do something > l

Proposal: Decimal literals in Python.

2007-10-26 Thread Lennart Benschop
Python has had the Decimal data type for some time now. The Decimal data type is ideal for financial calculations. Using this data type would be more intuitive to computer novices than float as its rounding behaviour matches more closely what humans expect. More to the point: 0.1 and 0.01 are exact