Issue595791
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.
Created on 2002-08-16 00:01 by moody834, last changed 2022-04-10 16:05 by admin. This issue is now closed.
Messages (5) | |||
---|---|---|---|
msg12009 - (view) | Author: James Pomeroy (moody834) | Date: 2002-08-16 00:01 | |
Platform: OS X 10.1.5 XDarwin: 1.1 (XFree86 4.2) IDLE: 0.8 Python: 2.2.1 Code (from Python Tutorial sec. 4.4) [I don't know if my indentation will be preserved here, but the code was indented per Python convention]: >>> for n in range(2, 10): ... for x in range(2, n): ... if n % x == 0: ... print n, 'equals', x, '*', n/x ... break ... else: ... # loop fell through without finding a factor ... print n, 'is a prime number' Result in IDLE: 3 is a prime number 4 equals 2 * 2 5 is a prime number 5 is a prime number 5 is a prime number 6 equals 2 * 3 7 is a prime number 7 is a prime number 7 is a prime number 7 is a prime number 7 is a prime number 8 equals 2 * 4 9 is a prime number 9 equals 3 * 3 Result using (xterm) command line matched example given in Python Tutorial: 2 is a prime number 3 is a prime number 4 equals 2 * 2 5 is a prime number 6 equals 2 * 3 7 is a prime number 8 equals 2 * 4 9 equals 3 * 3 |
|||
msg12010 - (view) | Author: Gregor Lingl (glingl) | Date: 2002-08-16 12:00 | |
Logged In: YES user_id=505031 Apparently this is a bug in the INPUT to IDLE, as the incorrect output is produced, if the else-part in the statement is incorrectly idented as part of the if-statement instead as a part of the for-statement |
|||
msg12011 - (view) | Author: James Pomeroy (moody834) | Date: 2002-08-16 15:22 | |
Logged In: YES user_id=448016 UPDATE: This issue all appears if I use OS X's default terminal. Same output as with IDLE. So, only xterm produces the result expected. |
|||
msg12012 - (view) | Author: Raymond Hettinger (rhettinger) * | Date: 2002-08-18 19:42 | |
Logged In: YES user_id=80475 Hello James, It looks like your bug report has an error in that it is not "indented per Python convention". When it was hand typed into IDLE, the 'else' clause needed to be aligned with the outermost 'for' rather than the 'if' block. That is an easy typo to make since IDLE automatically indents to most recent block and you have to hit backspace to move out a level. Thank you for submitting the bug report. If you find something else, please let us know. In the meantime, I'll mark this one as invalid and close the report. Raymond Hettinger |
|||
msg12013 - (view) | Author: James Pomeroy (moody834) | Date: 2002-08-18 20:19 | |
Logged In: YES user_id=448016 Wow. Apparently I need a better prescription for my glasses. I I tried it again (mind you, when I submitted it the first time I had tried it a few times), and it worked perfectly. Please accept my humble apologies. I don't know why I couldn't "see" that I was not copying the code exactly. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:05:35 | admin | set | github: 37042 |
2002-08-16 00:01:17 | moody834 | create |