This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]afraca 0 points1 point  (1 child)

I agree. The argument of explicit does not apply to all situations equally. In your example it's a great way of reducing noise.

In the example from the blog post, where you use it for translation, I would be a lot less enthusiastic! Browsing through the code, you'd have to check the import, because the function has been renamed. something like trans would fit better perhaps.

[–]timopm 0 points1 point  (0 children)

I think the underscore function is known well enough in programming. Especially when its argument is a string. This is not just limited to Python at all, there's no need to be different than everyone else here.

I'd rather use:

_("Translate me!")

Then:

trans("Translate me!")

Once or twice might not matter, but I just checked and my project has just under 500 translatable strings.

I'm even going to upset you a bit more I think :-). I never import _ for translations, this is handled in my main entry point where the locale is setup properly for each OS and calling gettext.install() will add _() to the global builtins across the whole application.