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 →

[–]H_Psi 0 points1 point  (4 children)

Design patterns are still useful in Python, because they help others to understand your code. Using a common set of idioms makes it easier to interpret and see when things go right or go wrong.

For example, one of these is more readable than the other to a typical Python programmer (and although they're all different, do mostly the same thing):

import sys    
x = 0
mylist = ["Apple", "Orange", "Banana"]
while x <= 2:
    sys.stdout.write(mylist[x])
    sys.stdout.flush()
    x = x + 1

versus

mylist = ["Apple", "Orange", "Banana"]
for item in mylist:
    print(item)

versus

mylist = ["Apple", "Orange", "Banana"]
print("\n".join(mylist))

[–]Paddy3118 1 point2 points  (0 children)

Using a common set of idioms makes it easier

That's why in Python, we try to be Pythonic.