Python Syntax Gotchas

Cluster focuses on discussions of Python's quirky syntax features, classic gotchas, implementation details like CPython behaviors, and references to PEPs, with jokes about braces and comparisons to other languages.

📉 Falling 0.4x Programming Languages
2,568
Comments
20
Years Active
5
Top Authors
#347
Topic ID

Activity Over Time

2007
4
2008
33
2009
68
2010
68
2011
132
2012
138
2013
133
2014
150
2015
154
2016
145
2017
170
2018
167
2019
143
2020
185
2021
210
2022
189
2023
196
2024
135
2025
146
2026
2

Keywords

constants.html PEP REPL python.org SomeClass github.com GitHub datetime.now GCC FYI python cpython print expression assignment code yield str variable syntax

Sample Comments

azinman2 Jan 4, 2017 View on HN

Their python is weird if it doesn't use eval?

__turbobrew__ Oct 9, 2024 View on HN

Continuing Pythons tradition of breaking perfectly functional code.

xapata Apr 10, 2018 View on HN

Great ideas that should be backported into CPython. Especially the message when forgetting the colon!

creata Apr 13, 2021 View on HN

Why is it "clearly" an error? This syntax has been around forever and is widely used by code golfers, so if it were unintentional, I'm sure the Python devs would've fixed it by now.

toyg Apr 19, 2012 View on HN

That's a classic Python gotcha, mentioned in all books and tutorials nowadays.

ketralnis Oct 20, 2021 View on HN

Huh? Python does it without any fancy sigils

Jasper_ Jan 24, 2022 View on HN

Apologies, I must have been confusing it with some other Python syntax tricks I've seen. I don't write too much Python anymore..

jroll Jul 27, 2012 View on HN

Gotcha, thanks! I forgot about __future__.

visarga May 31, 2022 View on HN

This makes Python have Perl vibes.

shusaku Sep 4, 2022 View on HN

FYI Fortran has this feature so if you feel like python is really missing this feature try using a more advanced language