11

Heinz: It's Time to Say Goodbye to These Obsolete Python Libraries

 2 years ago
source link: https://lwn.net/Articles/901887/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Heinz: It's Time to Say Goodbye to These Obsolete Python Libraries

[Posted July 20, 2022 by corbet]
Martin Heinz encourages Python developers to move on to a number of newer modules.
Using os.urandom isn't actually the problem here though, the reason the secrets module got introduced is because people were using the random module for generating passwords and such, even though the random module doesn't produce cryptographically safe tokens.

(Log in to post comments)

Heinz: It's Time to Say Goodbye to These Obsolete Python Libraries

Posted Jul 20, 2022 17:16 UTC (Wed) by domdfcoding (guest, #159754) [Link]

Slightly strange to have the headings be the modules you're *supposed* to use. At a glance it looks like you shouldn't use pathlib or secrets, because *they're* obsolete.

Heinz: It's Time to Say Goodbye to These Obsolete Python Libraries

Posted Jul 20, 2022 18:03 UTC (Wed) by iabervon (subscriber, #722) [Link]

The thing that's really amazing about using pathlib is that, since the objects have functions that proxy os (and open()), you can use that API to provide a whole VFS for whatever you want. Ever wonder what would happen if your code was running on a system with a different directory separator than the system it's actually running on, but you could still open files and do various filesystem operations? What if your disk contents were something different from what's actually on disk? If you provide a different Path as the root, all of the subsequent code, including suitably pathlib-using libraries that take a Path object, will use code you control.

Heinz: It's Time to Say Goodbye to These Obsolete Python Libraries

Posted Jul 20, 2022 18:45 UTC (Wed) by josh (subscriber, #17465) [Link]

Yeah, that's a *great* feature of Python. This is something we need in Rust: a way to represent and manipulate Path values from another OS.

Heinz: It's Time to Say Goodbye to These Obsolete Python Libraries

Posted Jul 20, 2022 19:32 UTC (Wed) by mathstuf (subscriber, #69389) [Link]

Heinz: It's Time to Say Goodbye to These Obsolete Python Libraries

Posted Jul 20, 2022 19:37 UTC (Wed) by developer122 (subscriber, #152928) [Link]

It's not hard to see how one could make unix paths (for example) the language standard and translate them to windows or what-have-you (even very esoteric stuff) before it actually hits the OS. A really powerful feature.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK