Live data from Hacker News

What's up Python? Epic CPython commit, Django 5 and 2FA for PyPI

bitecode.dev

51–60 of 123 posts

Re: What's up Python? Epic CPython commit, Django 5 and 2FA for PyPI

#51

OK, a Django update from me. I heavily used Django since version 0.96 (2007) until 1.5 (2014) (with Python 3)! Then came a long break with lower-level infrastructure work: linux kernel, perf tuning, some C, some Go and zig. Last week I picked up Django again. After 10 years (!!!) of not even looking at it. It felt like meeting a good old friend: they are the same, but older and more mature. Conversations are the same…

Similar experience. Started on 0.96, used daily until about 2.x and then took a break. Came back last year and was delighted to find most of the API remained stable. Before reading the release notes for Django 5 I was expecting at least a few breaking changes for my 4.2 apps, but there's almost none.

Part of the reason I took a break from tech in the first place was the relentless upgrade cycle. Thrilled that we've solved at least a few of the problems in sustainable ways.

Re: What's up Python? Epic CPython commit, Django 5 and 2FA for PyPI

#52
post #41
post #34

I'm still annoyed that they are deprecating datetime.datetime.utcnow(). I have over 1000 references to that function in my projects folder. I understand the footguns that naive datetimes present to the unwary, and yet I still prefer to work with naive always-UTC datetimes. Alas I will end up doing some kind of crazy find-and-replace (at least in the Python 3 code) to something like `datetime.datetime.now(tz=datetime.…

Another solution is to make a file called "my_patches.py": import datetime class my_datetime(datetime.datetime): @staticmethod def utcnow(): return datetime.datetime.now(tz=datetime.timezone.utc).replace(tzinfo=None) datetime.datetime = my_datetime And then in your codebase make sure you import my_patches whenever you use datetime. E.g.: import my_patches import datetime print(datetime.datetime.utcnow())

That solves the specific problem, but if you were my coworker, I’d have to toss you off the nearest bridge.

Don’t monkeypatch Python, m’kay?

Re: What's up Python? Epic CPython commit, Django 5 and 2FA for PyPI

#53

[flagged]

Python is not a scripting language, it's a weakly-typed general-purpose programming language. I too dislike the lack of strong-typing, but there are dozens of good options if that's what I need in a codebase. It sounds like your problem is with people who write Python, not Python itself. Not every person who writes code has the time or ability to learn all the nuances of strongly-typed functional languages. In my opi…

Python’s strongly, dynamically typed. Try adding “12”+3 and it will throw a TypeError at you.

Re: What's up Python? Epic CPython commit, Django 5 and 2FA for PyPI

#54
post #11

[flagged]

What does the term "scripting language" mean to you?

Not the original poster, but to me it usually refers to a language that is expressive and high-level but usually not fast or efficient enough to implement the actual heavy lifting. It seems fair to call Python a scripting language. This is not a derogatory term, rather it actually describes a great way to build software and explains Python's success.

Re: What's up Python? Epic CPython commit, Django 5 and 2FA for PyPI

#55
post #40

Earlier quoted context omitted.

You can have centralized TOTP too, I believe e.g. Vault or 1password can do that?

Good to know, I wasn't aware. But if you're storing passwords, TOTP seed, and recovery codes all in the same shared password vault, it's not really multi-factor anymore. It's security theatre.

You should probably not do that, but as coder543 says in another comment, there are reasons why even that is preferable to not having TOTP. And assuming you enforce multi-factor authentication to access your vault, it is sort of transitively multiple factors (except for security vulnerabilities affecting the vault).

It’s not ideal, individual accounts seems like the only reasonable solution for legal and auditing reasons, but at least it’s possible to conveniently share users with 2FA enabled if you need to.

Re: What's up Python? Epic CPython commit, Django 5 and 2FA for PyPI

#56
post #41

Earlier quoted context omitted.

Another solution is to make a file called "my_patches.py": import datetime class my_datetime(datetime.datetime): @staticmethod def utcnow(): return datetime.datetime.now(tz=datetime.timezone.utc).replace(tzinfo=None) datetime.datetime = my_datetime And then in your codebase make sure you import my_patches whenever you use datetime. E.g.: import my_patches import datetime print(datetime.datetime.utcnow())

That solves the specific problem, but if you were my coworker, I’d have to toss you off the nearest bridge. Don’t monkeypatch Python, m’kay?

I think it's fine and pythonic[1,2] to monkey patch when used in moderation and done explicitly:

   from my_patches import monkey
   monkey.patch_datetime_utcnow()
I wouldn't do it as a side-effect of an import. Down that path lies Ruby. :-)

[1]: https://www.gevent.org/api/gevent.monkey.html

[2]: https://docs.pytest.org/en/6.2.x/monkeypatch.html

Re: What's up Python? Epic CPython commit, Django 5 and 2FA for PyPI

#57

Earlier quoted context omitted.

Python is not a scripting language, it's a weakly-typed general-purpose programming language. I too dislike the lack of strong-typing, but there are dozens of good options if that's what I need in a codebase. It sounds like your problem is with people who write Python, not Python itself. Not every person who writes code has the time or ability to learn all the nuances of strongly-typed functional languages. In my opi…

Python’s strongly, dynamically typed. Try adding “12”+3 and it will throw a TypeError at you.

That only works with a few built in types, like numbers. For any other type, you had better hope that the author has added such checks.

Re: What's up Python? Epic CPython commit, Django 5 and 2FA for PyPI

#58
post #5

If you read nothing else, the commit message adding JIT support is worth your time: https://github.com/python/cpython/pull/113465

To the guy who said the pull was horrible: IMO, the most important thing about a pull request is to... actually be productive. I've worked with people in the past who would nit-pick my commit messages wanting me to waste hours of my time trying to use arcane Git commands. Any of which might and probably will clobber my work. If you're doing Git reviews a good use of resources is to look for security problems, perform…

A good reason for enforcing some rule on git commit messages though is to have a message that helps when bisecting to find where an issue was introduced in the past. If the commit message is too meanless or too different from whatever is the convention, it makes you spend more time when tracking and solving issues.

Re: What's up Python? Epic CPython commit, Django 5 and 2FA for PyPI

#59
post #34

I'm still annoyed that they are deprecating datetime.datetime.utcnow(). I have over 1000 references to that function in my projects folder. I understand the footguns that naive datetimes present to the unwary, and yet I still prefer to work with naive always-UTC datetimes. Alas I will end up doing some kind of crazy find-and-replace (at least in the Python 3 code) to something like `datetime.datetime.now(tz=datetime.…

And for no particularly good reason! Sure, it's not great, but lots of things aren't. It's at worst a possible footgun, otherwise mostly cosmetic.

It should never be acceptable to break working software for anything else than critical security problems.

Re: What's up Python? Epic CPython commit, Django 5 and 2FA for PyPI

#60

Earlier quoted context omitted.

Yeah, I'm getting old. I would prefer TLDR formal version and then the fun xmas version for people that feel festive. But hey I'm not paying for this so who am I to complain :)

[flagged]

Yeah, ChatGPT can't reliably generate poetry which scans. (It can't count syllables in words, so this would be a bit much to expect of it.) I haven't read the entire poem, but the bits I have seen at least have the right syllable counts (although some rather odd stress patterns).
Post reply on HN