homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Interactive Shell vs Executed code
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.3
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Marcelo.Delgado, ezio.melotti, mark.dickinson, mrabarnett
Priority: normal Keywords:

Created on 2012年05月16日 06:08 by Marcelo.Delgado, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Messages (2)
msg160806 - (view) Author: Marcelo Delgado (Marcelo.Delgado) Date: 2012年05月16日 06:08
I have found inconsistency between running this code in the interactive shell and running it from a file:
Int. Shell:
n**0 ## n is a negative number
result: -1
File:
n**0 ## n is a negative number
result: 1
I am fairly new to Python, so I don't know what result should be the correct one, but if thit IS a mistake i would prefer the result of the Int. Shell :)
msg160808 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012年05月16日 07:12
It sounds like you're seeing the difference between this:
>>> n = -7
>>> n ** 0
1
and this:
>>> -7 ** 0
-1
This isn't a bug; it's to do with how Python expressions are parsed: in the second case, the expression is grouped as -(7 ** 0) rather than (-7) ** 0.
BTW, it's helpful to post exact code when filing a possible bug. :-)
History
Date User Action Args
2022年04月11日 14:57:30adminsetgithub: 59030
2012年05月16日 07:12:13mark.dickinsonsetstatus: open -> closed

nosy: + mark.dickinson
messages: + msg160808

resolution: not a bug
2012年05月16日 06:18:31Marcelo.Delgadosetcomponents: + Interpreter Core, - Regular Expressions
2012年05月16日 06:08:44Marcelo.Delgadocreate

AltStyle によって変換されたページ (->オリジナル) /