frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Ulysses S. Grant and the Art of Optimism

https://empirewriter.com/optimism/
1•goles•20s ago•0 comments

3-line exploit revealed for critical Nvidia Container Toolkit flaw

https://www.scworld.com/news/3-line-exploit-revealed-for-critical-nvidia-container-toolkit-flaw
1•Bender•21s ago•0 comments

Phishers have found a way to downgrade–not bypass–FIDO MFA

https://arstechnica.com/security/2025/07/no-phishers-are-not-bypassing-fido-mfa-at-least-not-yet-heres-why/
1•Bender•1m ago•0 comments

Local Cuisine was on the menu at Cafe Neandertal

https://arstechnica.com/science/2025/07/local-cuisine-was-on-the-menu-at-cafe-neanderthal/
1•tomrod•4m ago•0 comments

HP Is Launching an Ad Business with Laptop-Targeted Ads

https://www.adweek.com/commerce/hp-is-launching-an-ad-business-with-laptop-targeted-ads-and-a-streaming-service/
1•dotcoma•6m ago•0 comments

Google's Windsurf Deal Is a Wake-Up Call for AI Startup Employees

https://www.bloomberg.com/news/newsletters/2025-07-18/google-s-windsurf-deal-a-wake-up-call-for-ai-startup-employees
2•thm•10m ago•0 comments

Class of 2025: PhD students' realigned priorities in wake of Covid and cuts

https://www.nature.com/articles/d41586-025-02023-w
2•rntn•10m ago•0 comments

Sarepta tells FDA it won't halt shipments despite patient deaths

https://apnews.com/article/sarepta-muscular-dystophy-death-fda-gene-therapy-756b7ef43591b685fc197d6acb29c4c1
1•geox•10m ago•0 comments

React Router and React Server Components: The Path Forward

https://remix.run/blog/react-router-and-react-server-components
1•SpaceIcedLatte•14m ago•0 comments

Gum: A Go-powered tool for writing shell scripts, no Go code required

https://github.com/charmbracelet/gum
2•bundie•14m ago•0 comments

AI's energy demand ratchets up pressure on Republicans

https://www.eenews.net/articles/ais-energy-demand-ratchets-up-pressure-on-republicans/
1•pera•14m ago•0 comments

Popular NPM linter packages hijacked via phishing to drop malware

https://www.bleepingcomputer.com/news/security/popular-npm-linter-packages-hijacked-via-phishing-to-drop-malware/
2•OptionOfT•16m ago•0 comments

Using leaked data to examine vulnerabilities in SMS routing and SS7 signalling

https://medium.com/@lighthousereports/using-leaked-data-to-examine-vulnerabilities-in-sms-routing-and-ss7-signalling-8e30298491d9
2•todsacerdoti•16m ago•0 comments

Unexpected inconsistency in records – Jon Skeet's coding blog

https://codeblog.jonskeet.uk/2025/07/19/unexpected-inconsistency-in-records/
1•OptionOfT•16m ago•0 comments

Where Did All Those Brave Free Speech Warriors Go?

https://www.techdirt.com/2025/05/19/where-did-all-those-brave-free-speech-warriors-go/
4•the_why_of_y•24m ago•0 comments

Interesting thoughts on the limits of AI in the context of software development

https://www.ufried.com/blog/ai_and_software_development_5/
1•BinaryIgor•25m ago•0 comments

A Look Back at WeChat's PhxSQL and the 'Fastest Majority'

https://www.supasaf.com/blog/general/phxsql
1•supasaf•26m ago•0 comments

New Russian law criminalizes online searches for controversial content

https://www.washingtonpost.com/world/2025/07/17/russia-internet-censorship/
4•voxleone•28m ago•0 comments

DunedinPACNI estimates the longitudinal Pace of Aging from a single brain image

https://www.nature.com/articles/s43587-025-00897-z
1•bookofjoe•30m ago•0 comments

Why Is ReactOS Development So Undervalued?

2•Waraqa•33m ago•1 comments

AI guzzled books without permission. Authors are fighting back

https://www.washingtonpost.com/technology/2025/07/19/ai-books-authors-congress-courts/
3•amirkabbara•35m ago•1 comments

Kimi K2 scored 59% on the aider polyglot coding benchmark

https://twitter.com/paulgauthier/status/1946165321611526229
1•tosh•36m ago•0 comments

Spectrally Tunable Lighting: How LEDs can emulate blackbody emitters

https://enody.lighting/journal/01-spectrally-tunable-lighting/
1•carterpeterson•36m ago•0 comments

'I was floored by the data': Psilocybin shows anti-aging properties

https://www.livescience.com/health/ageing/i-was-floored-by-the-data-psilocybin-shows-anti-aging-properties-in-early-study
4•Bluestein•41m ago•0 comments

Extending Iterated, Spatialized Prisoners Dilemma to Understand Multicellularity

https://lksshw.github.io/
1•ca98am79•44m ago•0 comments

Field Guide to the North American Weigh Station

https://hackaday.com/2025/06/26/field-guide-to-the-north-american-weigh-station/
1•toomuchtodo•45m ago•0 comments

uv 0.8

https://github.com/astral-sh/uv/releases/tag/0.8.0
2•tosh•45m ago•0 comments

Is automating your AI too hard? Let AI automate that too

https://github.com/czlonkowski/n8n-mcp
1•greggh•45m ago•2 comments

Origami Space Planes Could Solve a Major Problem in Orbit

https://gizmodo.com/origami-space-planes-could-solve-a-major-problem-in-orbit-2000629875
1•Bluestein•46m ago•0 comments

Scenarios for solar radiation modification need to include perceptions of risk

https://iopscience.iop.org/article/10.1088/2752-5295/addd42
1•PaulHoule•47m ago•0 comments
Open in hackernews

Fstrings.wtf

https://fstrings.wtf/
212•darkamaul•4h ago

Comments

underdeserver•3h ago
Cute quiz! As a reminder, if you're doing anything even slightly complicated with f-strings (beyond :x or var=), leave a comment.
zahlman•3h ago
Ohg abg orgjrra gur oenprf! ;)
Disposal8433•3h ago
As someone who works on a codebase with almost no comments, please leave a comment for every block of code that does something and explain why (1 comment for every 5 or 10 lines of code should be fine).

And for regex you have this in some languages: https://docs.python.org/3/library/re.html#re.X

cluckindan•1h ago
Please include any technical and especially business reasons in the ”why”, please.
elteto•3h ago
Hey, I’m doing complicated things with f-strings so I’m leaving a comment as requested.
zahlman•3h ago
21/26, with a couple of sleep-deprived brainfarts and a misclick. Learned very little, although I had the wrong reasoning for one of the ones I got right (tested afterward). I don't even use the {var=} thing or walrus operator, though.

I would definitely not do nearly as well on jsdate.wtf. I really still think JS has the greater WTFs.

the_mitsuhiko•3h ago
I was not sure about the difficulty. Python has some really weird behaviors with some of the custom __format__. For instance f"{'None':<010}" will pad out, but f"{None:<010}" will error. The only one I ended up putting in is the gotcha that bool is an int subclass and gets the int behavior for custom format parameters (which almost sounds like a bug). f'{''''''''''''}' is also a weird one, but that is mostly an issue with the string concatenation syntax and not fstrings :)

There definitely are some more odd / confusing ones.

OJFord•3h ago
> For instance f"{'None':<010}" will pad out, but f"{None:<010}" will error.

Is that any different than being surprised that 1 + 1 is 2 and '1' + '1' is '11'?

lionkor•3h ago
not really, since None stringifies to "None", so you would expect None -> "None" -> padding and whatnot added
the_mitsuhiko•2h ago
I don't know, but I find this quite confusing:

    >>> f"{'42':<10}"
    '42        '
    >>> f"{42:<10}"
    '42        '
    >>> f"{None:<10}"
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: unsupported format string passed to NoneType.__format__
(Or any other type. What can be padded is quite inconsistent)
OJFord•1h ago
Ah I see, fair enough I suppose. Quite nice for catching bugs though to be honest - since you'll hit an error and realise you need to handle the None case appropriately, rather than a more subtle 'None' appearing somewhere bug.
Retr0id•3h ago
I made a mistake on 7, but wouldn't have done if I had syntax highlighting.
istrice•3h ago
Nice quiz! I admit I was surprised a couple of times (especially with f"{1<5:1<5}"), many of these features are hardly ever needed
Liftyee•3h ago
I like this quiz format much more than just reading a doc because I get to guess what it might do before finding out, which reinforces how well I remember it. As a Python amateur I had no idea fstrings were so powerful!
frickit•2h ago
These games just reinforce that I’m an idiot.
meinersbur•3h ago
Just learned about the ellipsis statement and the !a modifier (I already knew !r and !s).
tialaramex•3h ago
String interpolation is one of those features like inference where if you've had it before then going without is very annoying, and so you add some and that's nicer, then you add more, each step seems like it's an improvement, and then one day you realise you're looking at unintelligible nonsense and you say "Oh no, what have we done?"

This is unusual, often CS would love to have as much of whatever as we can, but mathematics says no that's literally or practically impossible - but here both none and lots are awful and shouldn't be permitted.

One option, which Python and C# both picked is, well, leave it to taste. You can write sixteen pages of layered expressions in the uncommented interpolated string and it'll work, but your colleagues will curse your name and plot your destruction. Or at least you'll fail code review if you enforce such things.

Another option, in standard C++ 23 today for example, is refuse to take even the first step. You can have rich formatting, but standard C++ does not provide interpolation at all, if you want to format six parameters then pass them as parameters.

I'm happy with Rust's "Only a tiny bit of interpolation" where you can interpolate only identifiers, not any other expressions, but that's definitely more interpolation than some will be happy with, yet of course in some cases it's not quite enough.

Waterluvian•1h ago
Purity and practicality are at odds and every language finds a different balance between the two. There is no one correct balance so busy minds will inevitably have loud opinions they want accepted as the one correct balance.
sublinear•33m ago
> CS would love to have as much of whatever as we can, but mathematics says no

What does this have to do with either topic?

cluckindan•3h ago
If this was JavaScript syntax, most of the comments would be lamenting the unintuitive syntax and weird features.
crazygringo•2h ago
Right, I assumed the real point the quiz was making is that Python is as full of footguns as JavaScript, since I've seen this type of thing for JS a bunch of times.

Not saying I agree, but was definitely expecting that to be the main topic of discussion here...

jvolkman•1h ago
But if it were Perl, they'd be celebrating.
WithinReason•3h ago
thanks I hate Python now
kosolam•2h ago
I doesn’t exist. Lol
psychoslave•2h ago
Awesome, makes me glad I didn't touch Python for years now.

Hell is paved with good will I guess. Probably Justine should update https://justine.lol/lex/

skrebbel•2h ago
> makes me glad I didn't touch Python for years now.

C'mon, every language has quirks.

bogtog•1h ago
Many of these are desirable features!
CivBase•2h ago
16/26

I always use a reference when doing anything non-trivial with format strings of any kind and this quiz confirmed I should keep doing that.

Also I've been using Python professionally for over a decade but TIL about the Ellipsis object.

neoden•2h ago
How can I setup a linter to prohibit stuff like this in my code base?
hackyhacky•2h ago
Just use Python 3.5.
jwilk•1h ago
str.format() can be cursed too, e.g.:

  >>> '{:{}{}}'.format('m', 'o<2', 3)
  'moooooooooooooooooooooo'
serf•2h ago
the reward for 100% should be a directory of languages that deals with strings in a sane/singular/readable way.

it's cool that half of those features are there. it's not cool that half the devs that read the thing after creation are going to have to look up the f string features.

Y_Y•1h ago
I've compiled a directory of those lamguages here:
nojs•2h ago
> This is the first special feature of f-strings: adding a trailing equals sign lets you print out the expression and what it evaluates to.

    >>> foo='bar'; print(f"{foo=}")
    foo='bar'
Wow, never knew you could do that.
black_puppydog•2h ago
such a boon for print(f) debugging. :)
jszymborski•47m ago
No more will I have to

print("foo", foo)

ck45•2h ago
Python release notes are really worth reading, for me there's usually some "positive surprise"

The = support was added in Python 3.8: https://docs.python.org/3/whatsnew/3.8.html#f-strings-suppor...

carlhjerpe•30m ago
If you come from verbosity land C# release notes are magically good as well, always some way to reduce boilerplate while maintaining "implicit verbosity" which your proprietary LSP resolves 100% correctly.

I'd prefer writing C# if I had the Linux interaction libs Python has. I'm too dumb to write syscall wrappers

ahartmetz•1h ago
Incredibly common for debug output. In C++, I have made it a habit to just copy the expression, once with quotes and once without. It's informative and doesn't require thinking, or, well, I'm still working on that.
stkdump•1h ago
It's the kind of thing you do with macros in C++.
acdha•55m ago
It makes me sad that the PEP for the equivalent behaviour for function keyword arguments wasn’t accepted. It’s really common to see foo(bar=bar) and I think it’s not only cleaner but would help see subtle differences if that was foo(bar=) because it would make the cases where some arguments aren’t simply being passed through more obvious: foo(bar=, …, baaz=baaz.get_id()) avoids the most interesting detail being easily missed.
carlhjerpe•33m ago
Do you know why? I didn't know of the fstring one either but I've thought to myself across many languages that a way to print the expression (or just varname in my head) with the result should exist.
roenxi•31m ago
And it seems like a bad idea because of that wow factor - it isn't really adding enough to justify having surprising behaviour. It is more likely to be a bug than a feature.

It'd be better to just let people implement their own function that prints a subset of locals(), or provide a standard function that does the same.

stephenlf•2h ago
Much easier than date.wtf
ejiblabahaba•2h ago
Learned a few tricks that I'm sure are buried on fstring.help somewhere (^ for centering, # for 0x/0b/0o prefixes, !a for ascii). I missed the nested f-strings question, because I've been stuck with 3.11 rules, where nested f-strings are still allowed but require different quote characters (e.g. print(f"{f'{{}}'}") would work). I guess this got cleaned up (along with a bunch of other restrictions like backslashes and newlines) in 3.12.

F-strings are great, but trying to remember the minute differences between string interpolation, old-style formatting with %, and new-style formatting with .format(), is sort of a headache, and there's cases where it's unavoidable to switch between them with some regularity (custom __format__ methods, templating strings, logging, etc). It's great that there's ergonomic new ways of doing things, which makes it all the more frustrating to regularly have to revert to older, less polished solutions.

sfoley•1h ago
Yeah I consider that one to be a trick question. I knew same-quote-style nested f-strings were coming, I just didn't know which version, and I still use the `f'{f"{}"}'` trick because I want my code to support "older" versions of python. One of my servers is still on 3.10. 3.11 won't be EOL until 2027.
jdranczewski•1h ago
I usually refer to https://pyformat.info/, which doesn't have all this detail, but most of the reasonable stuff is included
jvdvegt•1h ago
Why would "0^5" evaluate to 5? (question 21)

And is there a way to link to a specific question?

andrewfurey2003•1h ago
xor
palotasb•1h ago
^ is the XOR operator, 0 XOR 5 is 5. (Exponentiation is *)

https://docs.python.org/3/library/operator.html#mapping-oper...

teddyh•29m ago
Exponentiation is ** or pow()
procaryote•1h ago
One can question why python needs N built-in ways to printf with different syntax, different ways to escape things and different footguns.
6thbit•2m ago
“ There should be one-- and preferably only one --obvious way to do it.” — Zen of Python
carlhjerpe•55m ago
I really like the f"{ varname = }" syntax, didn't know about it before.

I have so much Python to learn, I scored 10/26

Ezhik•20m ago
I learned a bunch of these when trying to make an f-string-like library for Lua [1], but `f"{...}" and the walrus ones caught me off-guard.

Glad this is nowhere near Wat [2], though.

[1]: https://ezhik.jp/f-string.lua/

[2]: https://www.destroyallsoftware.com/talks/wat