Prev: Unicode strings
Next: exception in Tkinter on Ubtunu...
From: Jussi Piitulainen on 11 Feb 2010 11:23 Robert Kern writes: > On 2010-02-11 06:31 AM, Shashwat Anand wrote: > > There is a little issue here that '>>> -.1 ** .1' should give you > > error message. That is it. > > No, fractional powers of negative numbers are perfectly valid > mathematically. The result is a complex number. In Python 3 (what > the OP is using), this has been implemented, but not in Python 2.6. Perhaps it should raise a MisleadingSpacingError at compile time. The error message could recommend - .1**.1, or better -(.1 ** .1).
From: Terry Reedy on 11 Feb 2010 17:52 On 2/11/2010 11:23 AM, Jussi Piitulainen wrote: > Robert Kern writes: >> On 2010-02-11 06:31 AM, Shashwat Anand wrote: >>> There is a little issue here that '>>> -.1 ** .1' should give you >>> error message. That is it. >> >> No, fractional powers of negative numbers are perfectly valid >> mathematically. The result is a complex number. In Python 3 (what >> the OP is using), this has been implemented, but not in Python 2.6. > > Perhaps it should raise a MisleadingSpacingError at compile time. You forgot the smiley ;-). > The error message could recommend - .1**.1, or better -(.1 ** .1). The compiler would never see the difference between -.1 ** .1 and the first and probably no difference with the second either.
From: Aahz on 11 Feb 2010 21:44 In article <hl1j4a$j61$2(a)reader2.panix.com>, Grant Edwards <invalid(a)invalid.invalid> wrote: > >Didn't we just do this one last week? Let's do the Time Warp again! -- Aahz (aahz(a)pythoncraft.com) <*> http://www.pythoncraft.com/ "At Resolver we've found it useful to short-circuit any doubt and just refer to comments in code as 'lies'. :-)"
From: Jussi Piitulainen on 12 Feb 2010 04:40 Terry Reedy writes: > On 2/11/2010 11:23 AM, Jussi Piitulainen wrote: > > Robert Kern writes: > >> On 2010-02-11 06:31 AM, Shashwat Anand wrote: > >>> There is a little issue here that '>>> -.1 ** .1' should give you > >>> error message. That is it. > >> > >> No, fractional powers of negative numbers are perfectly valid > >> mathematically. The result is a complex number. In Python 3 (what > >> the OP is using), this has been implemented, but not in Python 2.6. > > > > Perhaps it should raise a MisleadingSpacingError at compile time. > > You forgot the smiley ;-). > > > The error message could recommend - .1**.1, or better -(.1 ** .1). > > The compiler would never see the difference between -.1 ** .1 and the > first and probably no difference with the second either. It could be done the same way that the compiler keeps track of the source line numbers now: early phases annotate their output with any information that later phases may need. This error would be detected during syntactic analysis. :)
From: Terry Reedy on 12 Feb 2010 11:08 On 2/12/2010 4:40 AM, Jussi Piitulainen wrote: > Terry Reedy writes: >> On 2/11/2010 11:23 AM, Jussi Piitulainen wrote: >>> Robert Kern writes: >>>> On 2010-02-11 06:31 AM, Shashwat Anand wrote: >>>>> There is a little issue here that '>>> -.1 ** .1' should give you >>>>> error message. That is it. >>>> >>>> No, fractional powers of negative numbers are perfectly valid >>>> mathematically. The result is a complex number. In Python 3 (what >>>> the OP is using), this has been implemented, but not in Python 2.6. >>> >>> Perhaps it should raise a MisleadingSpacingError at compile time. >> >> You forgot the smiley ;-). >> >> > The error message could recommend - .1**.1, or better -(.1 ** .1). >> >> The compiler would never see the difference between -.1 ** .1 and the >> first and probably no difference with the second either. > > It could be done the same way that the compiler keeps track of the > source line numbers now: early phases annotate their output with any > information that later phases may need. This error would be detected > during syntactic analysis. There is no error to detect. Sorry, read the manual and either learn or lookup precedence rules (there is a table in the end of the Expressions chapter) or use parentheses when not sure.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: Unicode strings Next: exception in Tkinter on Ubtunu... |