Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Messed up indentation makes undesired piece of code being run! #68294

Closed
jentyk mannequin opened this issue May 1, 2015 · 4 comments
Closed

Messed up indentation makes undesired piece of code being run! #68294

jentyk mannequin opened this issue May 1, 2015 · 4 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@jentyk
Copy link
Mannequin

jentyk mannequin commented May 1, 2015

BPO 24106
Nosy @ericvsmith, @bitdancer

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2015-05-01.17:26:27.120>
created_at = <Date 2015-05-01.17:15:47.849>
labels = ['interpreter-core', 'type-bug', 'invalid']
title = 'Messed up indentation makes undesired piece of code being run!'
updated_at = <Date 2015-05-02.02:21:37.194>
user = 'https://bugs.python.org/jentyk'

bugs.python.org fields:

activity = <Date 2015-05-02.02:21:37.194>
actor = 'r.david.murray'
assignee = 'none'
closed = True
closed_date = <Date 2015-05-01.17:26:27.120>
closer = 'r.david.murray'
components = ['Interpreter Core']
creation = <Date 2015-05-01.17:15:47.849>
creator = 'jentyk'
dependencies = []
files = []
hgrepos = []
issue_num = 24106
keywords = []
message_count = 4.0
messages = ['242336', '242338', '242343', '242371']
nosy_count = 3.0
nosy_names = ['eric.smith', 'r.david.murray', 'jentyk']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue24106'
versions = ['Python 2.7']

@jentyk
Copy link
Mannequin Author

jentyk mannequin commented May 1, 2015

In [14]: for i in xrange(10):
....: if 1==1:
....: print "It's true"
....: else:
....: print "It isn't true. Seriously??"
....:
It's true
It's true
It's true
It's true
It's true
It's true
It's true
It's true
It's true
It's true
It isn't true. Seriously??

Is the behaviour intentional? I do not think so...

@jentyk jentyk mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels May 1, 2015
@bitdancer
Copy link
Member

Whitespace is significant in Python. This is a fundamental part of the language. So yes, this is intentional. (Look up what the 'else' clause means on an if statement in the language reference.)

@ericvsmith
Copy link
Member

I think David meant the "else" clause on a "for" statement:

https://docs.python.org/2/reference/compound_stmts.html#the-for-statement

@bitdancer
Copy link
Member

Oops. Yes, that's what I meant :) Thanks for the correction and link, Eric.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants