840 karma · joined September 17, 2016
Also: https://github.com/python/mypy/blob/501a07b45af8e44eda665e53...
Also did you know mypy ignores typing of class decorators? You simply can't return a different type other than type[thisclass].
Or how make a wrapper function with args and kwargs to pass through?
[1]: https://docs.python.org/3/library/typing.html#typing.datacla...
2. Generated TPSV would look like an unreadable hard to edit mess. I doubt any tool would calculate max column length to adjust tab count for all cells. It basically kills any streaming.
It's so much fun to `return err` through every layer. Explicit no-op attached to every call, yeah!
> No unexpected uncaught exception logs blowing up your terminal (aside from actual program crashes via panics)
A great opportunity to search a code base for logging messages and reconstruct traces by hand. A real true craft!
> full-control of errors in your code as values you can handle, return, and do anything you want with
Yes, it's a real engineering marvel. Exceptions are so bad at this, you could only catch it and, wait...
> Rust, for example, has a good compromise of using option types and pattern matching to find error conditions, leveraging some nice syntactic sugar to achieve similar results.
Thank you for mentioning Rust, I guess. It's very saddle not to include `try` on the table.
Good code consists of easy to use abstractions. In general Chris's blog is dedicated to poking bad abstractions and giving good examples. `substring` is objectively bad.
You (and other commentators) literally arguing that keeping staff in the head or making some documentation or notes or forcing yourself or others check low level implementation details are better than making one trivial fix and forget about it. I find it really amusing.
It could use `str*` functions without any issues then. Nul-terminated strings are perfectly safe with assumptions to follow.
Anecdote: I fixed 3 reported segfaults and another 2 after fuzz-testing in a small 500 line lib. Original author had the same cowboy mindset about keeping all stuff in his head. It's always last words before getting into CVE database.
This very mindset is a source of bugs and vulnerabilities. The author has high marks from me on safety and "make it hard to use wrong" and it's quite surprising to see such code.
The function has quite questionable implementation. It fails miserably for strings with length < i.
Sweet summer child. Let me unfold a very precise prediction:
* By the end of 2nd-3rd year. Trump/congress/republican party would propose an amendment that president could rule two consecutive terms. It would be accepted.
* Trump would be elected to the next term.
* By the end of 6th-7th year there would be proposal to extend presidency to three terms.
* Rinse and repeat.
If you think it's unreal I have very bad news for you: how often it happens in real world.
"President is the main person end has exceptional power". That's the mental model for most people. There is no any internal conflict with law violation and any space for reflection what's wrong with it.
> I built this mainly around the habit of budget tracking at the end of the day.
I've built 3 personal financial trackers. 2 CLI based and last a web-based to be able to serve it in termux as a local android app.
Anecdote: the only thing which make it usable in the end is a joint account (most transactions are happened there) which reduced monthly transaction count to low acceptable level and did not become a chore without fancy importing from bank statements. Joint account allows to record only transfers and not individual expenses. It easily could be a separate account for small expenses, it has a low value to know which kind of grocery takes most of money.
sqlx looks like a usual builder, I don't see nothing criminal about it.
from sqlbind import WHERE, FIELDS, join_fragments
q = Q() # a QueryParams factory
fields = []
joins = []
filters = []
if some_condition:
fields.append('sub_table.field')
joins.append('INNER JOIN sub_table ON (subid)')
filters.append(q.sub_table.date > since)
sql = f'''\
SELECT {FIELDS('table.field', *fields)}
FROM table
{join_fragments(' ', joins)}
{WHERE(*filters)}
'''
Personally I prefer this explicitness to ORM for complex queries which include recursive or multiple joins to the same table.But I agree ORM shines with simple joins especially if models include proper relationship and there is no need to specify 'ON' condition every time.