954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Zen of Python: One right way?

Python was my first programming language and I have been programming for about 5 years now. I LOVE Python, but there is one thing I haven't got myself to believe yet. In the Zen of Python one of the entries is: "There should be one, and preferably only one, obvious way to do things." And while I was able to write that from memory, I still have a hard time with it.

So, can any of you Pythoneers/Pythonistas explain this to me? Logic and/or examples would be great ( although good luck proving it to me WITHOUT logic :p ).

Thanks in advance,

- WolfShield

WolfShield
Posting Whiz in Training
236 posts since Oct 2010
Reputation Points: 28
Solved Threads: 4
 
lrh9
Posting Whiz in Training
243 posts since Oct 2009
Reputation Points: 119
Solved Threads: 36
 

I think this motto should not be understood too strictly. Here are a few hints

1) If there is only one (preferably obvious) way to do things, this reduces considerably the design part of writing software. Everybody agrees on the unique possible solution.

2) Obviously (and hopefully) this is not so in real life. There ARE several ways to do things, so the motto must be understood as an unreachable ideal.

3) Perhaps, this applies best to writers of APIs or UIs. Offering only one way to do things makes a much simpler interface. So perhaps when Tim Peters wrote the zen of python, he mainly targetted python developers and this was a guidance rule for python, to offer only the best way to do each thing.

4) As everybody knows, this was also a response to perl's TIMTOWTDI, which looks appealing to the beginning perl programmer, but rapidly leads to indecipherable code. At the time python and the zen of python were written, perl was a leader in scripting languages, and pythonistas had to give arguments as to why their language was better.

Gribouillis
Posting Maven
Moderator
2,786 posts since Jul 2008
Reputation Points: 1,044
Solved Threads: 691
 

Awesome,
Thanks for shining some light on it for me.

- WolfShield

WolfShield
Posting Whiz in Training
236 posts since Oct 2010
Reputation Points: 28
Solved Threads: 4
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: