|
|
Log in / Subscribe / Register

"Structural pattern matching" for Python, part 1

"Structural pattern matching" for Python, part 1

Posted Aug 7, 2020 11:56 UTC (Fri) by flussence (guest, #85566)
In reply to: "Structural pattern matching" for Python, part 1 by mb
Parent article: "Structural pattern matching" for Python, part 1

> Literally dozens of major good features have been integrated in the past 15 years.
> One of the most recent ones being f-strings, for example.

Look up Perl's format() function. You won't find many uses of that in modern code, because the community collectively realised some time in the 20th century that making people carry the cognitive load of a loquacious bespoke sublanguage that duplicates half of printf (and then doesn't even fix strftime) is absolutely bananas.

And f-strings are explicitly runtime-evaluated. You don't even get constant-folding!


to post comments

"Structural pattern matching" for Python, part 1

Posted Aug 7, 2020 13:41 UTC (Fri) by excors (subscriber, #95769) [Link]

Perl's documentation introduces "format" as being based on FORTRAN, BASIC and nroff, so it's hardly surprising that it doesn't attract many users nowadays. (https://perldoc.perl.org/perlform.html)

f-strings sound a lot more like Perl's interpolated strings (f"Hello {name}" vs "Hello $name") which are widely used, plus they have nicer syntax when embedding expressions (f"HELLO {name.upper()}" vs "HELLO @{[ uc $name ]}", the latter being a horrific but common Perl idiom). They've also got the printf-ish format specifiers which I doubt I'd be able to use without checking the documentation every time, but f-strings seem useful even without that.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds