Fstrings.wtf
Overall reaction to the quiz
- Many found it fun and educational; scores varied widely (roughly half marks to ~20/26).
- Several experienced Python users realized they didn’t know f-strings or the format mini-language as well as they thought.
- Some felt most questions were trivia about
str.formatsyntax rather than true “WTFs”. - A few commenters said the quiz made them dislike Python’s complexity; others argued these are powerful, desirable features.
F-string behavior & surprising details
- Key learnings:
var=debugging syntax,!a(ascii) in addition to!r/!s, ellipsis object, centering (^), prefixes via#, nested f-strings behavior changes in 3.12. - Insight: f-strings just call
format(value, spec); behavior depends on__format__for each type. - Example surprise: strings and ints support padding specs, but
None(and default object types) raiseTypeErrorwhen given a non-empty format spec. - Discussion of walrus (
:=) inside f-strings: visually similar constructs like{a:=10}(alignment) vs{(a:=10)}(assignment) behave very differently, which some find error-prone.
Format mini-language vs interpolation
- Many pointed out that “WTFs” mostly stem from the format-spec mini-language, not interpolation itself.
- Some complained Python now has multiple overlapping string-formatting styles (
%,.format, f-strings, templates), violating “one obvious way”. - Others say the mini-language is “sticky” once learned and worth the power (padding, alignment, numeric bases, etc.).
Language design and feature bloat
- Debate over how far interpolation should go:
- Python/C# allow arbitrarily complex expressions in interpolated strings (“leave it to taste”).
- Rust allows only identifiers, which some find nicely restrictive and others find too limiting.
- C++ standard avoids interpolation entirely; you pass arguments explicitly.
- Concerns that Python’s growing pile of small syntactic features (f-string tricks, walrus, multiple format styles) crosses a complexity threshold where people fall back to ad-hoc helpers instead of learning the system.
Usage patterns, tooling, and ergonomics
- Some advocate heavy commenting whenever f-strings get nontrivial; others want linters to ban advanced usage.
- Logging: several argue that using f-strings in log calls defeats lazy interpolation and can hurt performance/memory; others consider it a micro-optimization and choose based on readability.
- Comparisons: multiple mentions of JS’s quirks (e.g.,
jsdate.wtf, Wat talk), Perl’s celebrated weirdness, and Java/C# templating experiences. Mixed feelings whether Python is “as bad as JS” or still relatively tame.