On 06/28/2013 12:06 PM, Jim Mooney wrote:
def foo(x):
...     if x:
...         return True
...     return False

I'll leave it to you to work out why that works.  It's very handy!

Hey, it saves typing an "else" and as you know, I'm the Lazy Typist.
My program to make dicts, lists, etc from a single string, using no
special characters, has saved me so much little-finger typing already
I'd never part with it, flawed as it is. It's good-enough ;')



If one were trying to save keystrokes here, one would just use

foo = bool

and be done with it.

Or at least,

def foo(x):
    return bool(x)

But saving keystrokes should seldom be the goal, unless you're dealing with a disability. In most cases, the comments and the testing code will be much bigger than the actual running code.


--
DaveA
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to