Mastodon Feed: Post

Mastodon Feed

Boosted by glyph ("Glyph"):
treyhunner ("Trey Hunner 🐍") wrote:

Python Tip #99 (of 365):

Don't convert pathlib.Path objects to strings

Using a pathlib.Path object in an f-string or a print call is fine and I do this often.

But if you THINK you need to convert a pathlib.Path object to a string to pass it off to some other path-handling utility, you probably don't need to. Most path-handling utilities in Python support pathlib.Path objects just fine.

#Python #DailyPythonTip