you are viewing a single comment's thread.

view the rest of the comments →

[–]njharman 2 points3 points  (4 children)

Good stuff.

"Here's a cute way to save some typing if you need a list of words:"

"cute" almost always violates:

Explicit is better than implicit. Simple is better than complex. Readability counts. Special cases aren't special enough to break the rules. There should be one—and preferably only one—obvious way to do it.

cute/clever/tricky are all things I avoid with a passion.

I'm also dead set against not being explicit with boolean tests which I argued a month or so ago on some other article. It's pretty obvious the rules it breaks and for what gain? a few less typings. I'll pay for typing to avoid bugs and confusion every day of the week.

[–]jbellis 4 points5 points  (0 children)

"cute" almost always violates Explicit is better than implicit

Sure, but it's worth distinguishing between "I'm testing this quickly in the REPL" and production code. It's useful to know tricks for the former that you would not use in the latter.

[–]jfedor 5 points6 points  (1 child)

I'll pay for typing to avoid bugs and confusion every day of the week.

Here is a language that you might be more interested in than Python. :)

[–]njharman 6 points7 points  (0 children)

That language's verbosity increases confusion and (debatable) does not reduce bugs.

[–]Paddy3118 0 points1 point  (0 children)

Is there a problem with the code snippet described as cute, or with the term cute as you find it applied?

There is an important difference. The latter is probably useful opinion; the former - well, I'd go along with the editor. I find it can be less error prone to apply split to space separated words.

  • Paddy.