Readit News logoReadit News
cwilkes commented on Python f-string cheat sheets (2022)   fstring.help/cheat/... · Posted by u/shlomo_z
cloudbonsai · 5 days ago
You haven't seen the full depth yet. Suppose that you encountered with this line:

    print(f"{n:.2g}")
What will it print? Here is the official explanation from https://docs.python.org/3.12/library/string.html#formatspec:

    g - General format. For a given precision p >= 1, this rounds the number to p significant digits and then formats the result in either fixed-point format or in scientific notation, depending on its magnitude. A precision of 0 is treated as equivalent to a precision of 1.

    The precise rules are as follows: suppose that the result formatted with presentation type 'e' and precision p-1 would have exponent exp. Then, if m <= exp < p, where m is -4 for floats and -6 for Decimals, the number is formatted with presentation type 'f' and precision p-1-exp. Otherwise, the number is formatted with presentation type 'e' and precision p-1. In both cases insignificant trailing zeros are removed from the significand, and the decimal point is also removed if there are no remaining digits following it, unless the '#' option is used.

    With no precision given, uses a precision of 6 significant digits for float. For Decimal, the coefficient of the result is formed from the coefficient digits of the value; scientific notation is used for values smaller than 1e-6 in absolute value and values where the place value of the least significant digit is larger than 1, and fixed-point notation is used otherwise.

    Positive and negative infinity, positive and negative zero, and nans, are formatted as inf, -inf, 0, -0 and nan respectively, regardless of the precision.
Make sense? You now should be able to see why it's called f-string.

cwilkes · 4 days ago
Maybe should be called “iq-string” for Interview Question string.
cwilkes commented on MCP overlooks hard-won lessons from distributed systems   julsimon.medium.com/why-m... · Posted by u/yodon
throwawaymaths · 16 days ago
i mean isnt all this stuff up to the mcp author to return a reasonable error to the agent and ask for it to repeat the call with amendments to the json?
cwilkes · 16 days ago
This implies that the input process did a check when it imported the data from somewhere else.

GIEMGO garbage in even more garbage out

cwilkes commented on Coinbase says hackers bribed staff to steal customer data, demanding $20M ransom   cnbc.com/2025/05/15/coinb... · Posted by u/gpi
dachris · 3 months ago
Why is this such an issue with crypto?

Wealth status is often very well known for public figures and entrepreneurs. People are driving around in $200k cars.

Is it due to the liquidity of cryptocurrencies that $5 wrench attacks work better?

cwilkes · 3 months ago
Scammers attract scammers?
cwilkes commented on Laziness Death Spirals   lesswrong.com/posts/JBR6A... · Posted by u/surprisetalk
highfrequency · 10 months ago
Entirely eliminating the feeling of guilt is the first step to beating procrastination.

There is a strong negative feedback cycle where you procrastinate, feel guilty about it, and then procrastinate further because you are subconsciously seeking to escape the guilt through distraction.

cwilkes · 10 months ago
I recommend the book “Unwinding Anxiety” by Judson Brewer for further reading. Another book of his “Hunger Habits” is really good.
cwilkes commented on Posting a 5x5 crossword every day   crucig.com... · Posted by u/ldom22
cwilkes · a year ago
Most of these entries are Naticks where the two crosses are proper nouns. That’s really unpleasant as it usually means there’s no way to figure out the cross unless you know the two terms.

https://en.wikipedia.org/wiki/Rex_Parker

In 2008, he invented on his blog the crossword term "natick" (after Natick, Massachusetts) for an "unguessable" square crossed in both directions by proper nouns considered obscure.

cwilkes commented on CrowdStrike global outage to cost US Fortune 500 companies $5.4B   theguardian.com/technolog... · Posted by u/Terretta
leros · a year ago
Crowdstrike's contracts and terms of service will have clauses about how much liability they have when things go wrong. I have no idea what Crowdstrike's policy is, but pretty often, the liability is limited to the amount of money you've paid them during the outage.

I've been involved in procurement at a big corporation and one thing we always modified in contracts was making the vendor 100% liable for any damages caused by their outages, but many vendors wouldn't make that modification.

cwilkes · a year ago
I’ve heard of that for civil engineering firms but the amount of damages is capped at the yearly contract amount.

Which in this case is probably a lot less than what these companies are paying in clean up costs.

Dead Comment

cwilkes commented on Boeing may reacquire Spirit at higher price despite hating optics   arstechnica.com/tech-poli... · Posted by u/donatzsky
toomuchtodo · a year ago
A reasonable premium for ruthless financialization of their supply chain and to make an attempt to survive the dysfunction they created.
cwilkes · a year ago
I cannot upvote this enough. They continuously squeeze suppliers either on a bill or to make more faster. Accidents are bound to happen.
cwilkes commented on     · Posted by u/bookofjoe
cwilkes · 2 years ago
“Back in July 2025, six years before Apple introduced Siri, Susan Bennett made some recordings.”

The author is from the future?

cwilkes commented on How I write HTTP services in Go after 13 years   grafana.com/blog/2024/02/... · Posted by u/matryer
tdeck · 2 years ago
I don't agree that this example is more "programmer friendly". Anything you want to do with the username other than null check and passing an argument is going to be based directly on the string representation. Insert into a database? String. Display in a UI? String. Compare? String comparison. Sort? String sort. Is it really more "programmer friendly" to create wrapper types for individual strings all over your codebase that need to have passthrough methods for all the common string methods? One could argue that it's worth the tradeoff but this C2 definition is far from helpful in setting a clear boundary.

Meanwhile the real world usages of this term I've seen in the past have all been things like enums as strings, lists as strings, numbers as strings, etc... Not arbitrary textual inputs from the user.

cwilkes · 2 years ago
You inherit some code. Is that string a username or a phone number? Who knows. Someone accidentally swapped two parameter values. Now the phone number is a username and you’ve got a headache of trying to figure out what’s wrong.

By having stronger types this won’t come up as a problem. You don’t have to rely on having the best programmers in the world that never make mistakes (tm) to be on your team and instead rely on the computer making guard rails for you so you can’t screw up minor things like that.

u/cwilkes

KarmaCake day979July 9, 2015View Original