Pybites · @pybites
122 followers · 100 posts · Server fosstodon.org

New article:

⚠️Why you should avoid import * in Python 🐍
pybit.es/articles/why-you-shou

Covering:
- Why modules are great and namespacing explained
- Why import * is a problem
- A practical example where a function gets overriden
- The recommended way to do imports
- What PEP8 has to say about this
- Protection workaround, use __all__ to define your module's public interface

#python #pythonprogramming #modules #encapsulation #namespacing #zenofpython #bestpractices #pitfalls #imports #dundermethods

Last updated 1 year ago

Laura Langdon · @LauraLangdon
561 followers · 2022 posts · Server hachyderm.io

Just found myself considering when/whether to work on a particular blog post that’s been bobbing about in my brain, and I answered myself with “Now is better than never. Although never is often better than *right* now.”

I have been assimilated.

#python #zenofpython

Last updated 1 year ago

Jeff Forcier · @bitprophet
545 followers · 3692 posts · Server social.coop

query: should the string message inside Exception (sub)classes be considered part of the API / contract?

On one hand, client code performing "stringly typed" comparisons to a caught exception's text, is a code smell. Changing to raise a subclass of the old exception, w/ a different message, "should" be backwards compatible.

OTOH, esp when a codebase historically had too-broad exception classing, users have to rule 9 & do that string compare. Now they're broken. Ugh.

#python #zenofpython

Last updated 1 year ago

Microdesign · @Microdesign
4 followers · 5 posts · Server mastodon.uno
Microdesign · @Microdesign
4 followers · 4 posts · Server mastodon.uno
Ryuno-Ki · @RyunoKi
573 followers · 12542 posts · Server layer8.space

Go Proverbs - go-proverbs.github.io/

Like but for .

„Clear is better than clever“ and „A little copying saves a dependency“ are my favs. What are yours?

#zenofpython #go #GoProverbs #golang

Last updated 2 years ago

Cam_doc 🏳️‍🌈 · @Natir
121 followers · 4455 posts · Server mastodon.xyz

@Lomig@octodon.social Pardon désoler j'aurais du faire plus attention (faudrait il une instance mastondon pour les bretonnant ?). Pour moi le beurre doux n'existe pas c'est du beurre sans sel, je précise beurre salé car //explicite is better than implicite//

#zenofpython

Last updated 8 years ago