Whether on purpose or not, it is a clear example of why it's important to give clear names. If this was a bug, I could clearly find it just by looking at the code.
There's always a possibility that's an issue with the page formatter for code. I know Confluence can be a bit funny about that if you paste into a code block.
Maybe this indent decided to leave the print statement (where it is destined to be)
for x in c:
print(x)
# Recommended
cities = [âUKâ, âUSAâ, âUAEâ]
for city in cities:
print(city)
and moved in with that for loop neighbor against all odds.
Seriously, indent really matters in Python. As well as the case (especially for keywords), so Pass instead of pass
# Recommended
def fetch_users():
# do something
Pass
will trigger a NameError unless there is a variable named Pass.
And speaking of technical debt, these two kinds of bugs (wrong indentation and case incosistency) in poorly written Python code are sneaky enough to go unnoticed since they may not trigger any error messages in some cases.
This is a pretty poor example of clear variable names (see Naming Conventions #2 above)
The variable name's purpose would be clearer if it were 'countries', not 'cities'!
Whether on purpose or not, it is a clear example of why it's important to give clear names. If this was a bug, I could clearly find it just by looking at the code.
It's also a relatively good example of why compiled languages are so (much more) useful :-)
For loop should also not be indented...
There's always a possibility that's an issue with the page formatter for code. I know Confluence can be a bit funny about that if you paste into a code block.
Maybe this indent decided to leave the
print
statement (where it is destined to be)and moved in with that
for
loop neighbor against all odds.Seriously, indent really matters in Python. As well as the case (especially for keywords), so
Pass
instead ofpass
will trigger a NameError unless there is a variable named Pass.
And speaking of technical debt, these two kinds of bugs (wrong indentation and case incosistency) in poorly written Python code are sneaky enough to go unnoticed since they may not trigger any error messages in some cases.
Also, the quotation marks in the
cities
list are not"
(\x22
) butâ
(\u201C
) andâ
(\u201D
) unicode characters. It would raiseSyntaxError
.