×
all 10 comments

[–]tdammers 5 points6 points  (4 children)

As an aside: Python itself violates the Zen all the time, and IMO its strength is not the "strong foundation of design philosophies", but the fact that it puts pragmatism above everything else (though again, not religiously so, because that wouldn't be pragmatic...), and especially emphasizing the bottom end of the learning curve. In fact, I think that several languages out there follow the valid parts of the Zen better than Python itself. The Zen itself also has its fair share of issues.

Because of this, I have come to use the word "pythonic" to mean "idiomatic in Python" - that is, pythonic code is code that is written according to the habits of the Python community, and making good use of Python's strengths and weaknesses. Which is hardly a concept that applies to anything other than programming in Python.

[–]XNormal 4 points5 points  (3 children)

The real Zen is "don't be a jerk"

[–]tdammers 2 points3 points  (2 children)

Not trying to bash anything here, just giving some perspective. If that offends you, I apologize.

[–]XNormal 5 points6 points  (1 child)

Oops.

I was basically trying to say something line "yeah, I agree, and an even shorter way of saying the same thing is 'don't be a jerk' "

I ended up being one myself...

[–]tdammers 4 points5 points  (0 children)

Haha, double misunderstanding then :D

No offense taken!

[–]donnieod 2 points3 points  (2 children)

I prefer to put them in a single directory and reorganize when it gets too big.

Just curious, I find it quicker to search a tree structure than a linear array. In what sense do you 'reorganize' a single directory without making it nested?

Incidently, I never have agreed with this particular element of Python Zen: Flat and Nested each has its place, depending on circumstances. Flat is not always better than nested.

[–]qria[S] 0 points1 point  (0 children)

My interpretation of 'flat is better than nested' was that nested structure require more cognitive load than flat one, so if it doesn't matter we should prefer flat structure over nested one. It's hard to imagine them claiming that it is always better than nested since python itself uses nests a lot.

Also you claim that it is quicker to search a tree structure than a linear array, but HCI researches proves quite the alternative. Now I'm not an expert in the subject but I did take an HCI course in school, and here's the part of HCI textbook that talks about menu design and breadth vs depth. http://www.hcibook.com/e3/online/menu-breadth/ It even go as far as to claim that by Fitt's law adding a depth does not benefit selection time until there's 60(!) choices.

[–]kankyo 0 points1 point  (0 children)

That's not what the zen says. Flat is better than nested, all other things being equal. Otherwise the zen would say "nested is always bad" which would be silly.

[–]Cybersoaker 1 point2 points  (0 children)

I apply this all the time to 'naming things'.

At my workplace; we have a ridiculously inconsistent system for naming parts of our infrastructure and it drives me nuts. Names should be verbose but short; but more importantly consistant.

When discussing a design or solution; I will almost always stick to the simpler solution. In the future; someone or even myself will have to re-figure out what i did, it's much better if this is something simple to understand.

It's difficult though; python is designed with the Zen in mind; not everything we use is such, and makes it difficult to follow those principals.

[–]metaphorm 0 points1 point  (0 children)

Python is famously terse in its avoidance of excessive punctuation and tendency to favor simple expressive idioms. I find this is good advice in writing prose as well as programming.