On Nov 15, 2:39 am, Dmitry Groshev <lambdadmi...@gmail.com> wrote: > Here are some proposals. They are quite useful at my opinion and I'm > interested for suggestions. It's all about some common patterns. > First of all: how many times do you write something like > t = foo() > t = t if pred(t) else default_value
Never! [snip] > And the third. The more I use python the more I see how "natural" it > can be. By "natural" I mean the statements like this: > [x.strip() for x in reversed(foo)] > which looks almost like a natural language. But there is some > pitfalls: > if x in range(a, b): #wrong! This is true only if x is an integer such that a <= x < b > it feels so natural to check it that way, but we have to write > if a <= x <= b This is true if x is an integer OR a float. Two very different cases, deserving of different notation. André -- http://mail.python.org/mailman/listinfo/python-list