2 ms·
I'll admit I don't know what magic the Python interpreter is capable of. I was imagining cases where an indentation change does not break readability: for
by pohl 17y ago
I'll admit I don't know what magic the Python interpreter is capable of. I was imagining cases where an indentation change does not break readability:
for foo in bar:
foo.fizzle()
baz.wibble()
...versus...
for foo in bar:
foo.fizzle()
baz.wibble()
...how would it know that I wanted to wibble the baz every time I fizzle a foo, as opposed to wibbling the baz only after all foo have been fizzled?
- nailer 17y agoBecause you've told it to by making your data look correct. Python executes your data the same way you yourself parse it: by how it appears. Brace requiring languages execute your data using different rules than you use to parse it. Redundancy of logic is universally known to be a poor engineering practice.
- pohl 17y agoTortoise: I'd like a bicycle helmet, please. Achilles: Why do you want to wear a helmet? Tortoise: So that I won't hurt my head if I bump it. Achilles: You won't bump it. Tortoise: Suppose I do. Achilles: You won't bump your head. Tortoise: But suppose, hypothetically, that I fall off my bike and bump my head. What would protect it from injury? Achilles: Your head is not injured, because you didn't bump it. Tortoise: But that's the very basis of my hypothesis! Achilles: Yeah, I'm going to just ignore you said that, and tell you again that you won't bump your head. Tortoise: How do you know? Achilles: Because you made sure that it didn't come into contact with anything. Tortoise: Good night, dear Achilles. May you encounter others like you.
- nailer 17y agoSorry poor Tortoise, you're putting words into Achilles mouth. Fortunately, Python gives you: * A helmet. It won't parse unblocked code like any other language. I'm not sure why you think blocking a second time with brackets would improve things or avoid this risk. But hey, if you want to wear a second helmet, that's cool. May you encounter others like you. :^) * A mirror where things are as large as they appear (the blocking looks like it executes), unlike other languages where these can get out of sync and cause problems. If you enjoy this risk, that's awesome. High five. * A handy warning light should you accidentally stray too far to the wall (Python will telling you that your readability is broken at the same time it tells you your blocking is - and you only need one fix). If you'd prefer not to be told about this, two places to fix things, and enjoy receiving badly written code, that's your prerogative and who am I to say anything other than that it's not mine. Achilles: Nice bike and helmet. Tortoise: No! Achilles: Er, ok. Could you explain? Tortoise: I need to get a helmet! Achilles: You're already wearing one. Tortoise: But what if I fall? Achilles: You're wearing a helmet, which will protect you. Tortoise: But I need to get a helmet. Achilles: No you don't, you're wearing one. Oh and by the way, you need to be visible at night. The helmet's reflective, so you probably don't want to cover it with another ... Tortoise: You're not listening to me! Achilles: I am listening, but I'm also disagreeing. Are you listening to my disagreement?