On 11/15/2010 1:39 AM, Dmitry Groshev 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. t=t unbinds and rebinds 't' to the same object. A waste.
Only rebind if needed.
    if not pred(t): t = default_value

? Of course we can write it as
     t = foo() if pred(foo()) else default_value
but here we have 2 foo() calls instead of one. Why can't we write just
something like this:
     t = foo() if pred(it) else default_value
where "it" means "foo() value"?

Too magical.

I agree with most other comments.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to