24,628 karma · joined Oct 21, 2019 (7y ago) · 5,512 submissions
https://www.bitecode.dev/
Email: contact at bitecode.dev
comment 3y ago · link · parent
The tenacity library comes with an intriguing mix of iterators and context managers to allow the users to retry blocks with this syntax:
from tenacity import Retrying, stop_after_attempt
for attempt in Retrying(stop=stop_after_attempt(3)):
with attempt:
1 / 0
You can use the same mechanism yourself, by creating and linking a custom context manager and iterator: class YouAndIhaveUnfinishedBusiness:
def __init__(self, notify_success, attempt_number):
self.notify_success = notify_success
self.attempt = attempt_number
def __enter__(self):
pass
def __exit__(self, exc_type, exc_value, traceback):
if exc_value:
print(f"You have disappointed me {self.attempt} time(s).")
else:
self.notify_success()
return True
class DoOrDoNotThereIsNoTry:
def __init__(self, max_attempts):
self.max_attempts = max_attempts
self.success = False
def __iter__(self):
for i in range(self.max_attempts):
yield YouAndIhaveUnfinishedBusiness(self.succeed, i+1)
if self.success:
print("You are ready for the Kumite.")
break
else:
print("We trained him wrong on purpose, as a joke.")
def succeed(self):
self.success = True1565.
Python cocktail: mix a context manager and an iterator in equal parts(bitecode.dev ↗)
1 points · by BiteCode_dev · 3y ago · 1 comment
comment 3y ago · link · parent
Many animals have evolved in different direction for educational, emotional and sexual structures.
I don't see any impossibility here.
Only the believe the future will like the present, which is obviously not true.
comment 3y ago · link · parent
Everytime you pay anything with something else than cash, it is recorded: the amount, the time, the place, and the nature of the thing you buy.
There is no way to go to a gay bar (or another place loaded with consequences) without a trace. And this is needed for human dignity.
There is way to support a controversial political movement without a trace. And this is necessary for new idea to come up.
There is not way for kids to do dumb things without a trace. And this is necessary for growing.
There is no way to pay for something when electricity or network goes down. And this is necessary to deal with crisis.
Basically, cash buys humanity margin of maneuver, and a fallback against any decaying societal or technical system.
comment 3y ago · link · parent
> people consider it unnecessary
In fact, I've discussed a cashless society with friends, and the majority is against, precisely because of this.
Now it may be my bubble, and not apply to the average French citizen.
comment 3y ago · link · parent
comment 3y ago · link · parent
A geographer scripting her GIS in Python or a quant doing some pandas analysis has a very limited programming experience, since her expertise is in her job.
And so we see more and more code produced by people that don't know what is slow and fast, what is safe or dangerous, what is maintainable or not. This code is popular, because it solves a real problem by people deeply familiar with the problem, way more than a programmer would be.
I have an example at $current_client, where they have some matlab code that handles tremendous amounts of money, with no comments, no doc, no tests, side effect everywhere and some interesting quadratic behaviors. They solved by loading balancing the thing on 6 servers with 17 processes, and manual testing.
comment 3y ago · link · parent
This also keeps my traffic stats clean: people that comes are the ones that are interested in the content. The number are smaller, but closer to what my real readership looks like. Since I have no ads, I don't aim for volume, so I rather know the truth.
comment 3y ago · link · parent
I tried to come up with something that would convey in a few words that the GIL was going to be removed for sure this time. But as a Frenchmen, I couldn't find better.
"GIL will be removed" was the closest, but it's very long, and it sounds like all those times we had the promise it would be, but it never did.
So the Prophetic perfect tense is the best compromise: it asserts near certainty, it's short, and worst case scenario the article remove ambiguity.
Plus the news popped up this week in HN front page, so a lot of people knew the context.