[Tutor] multiple function returns
Chris “Kwpolska” Warrick
kwpolska at gmail.com
Fri Jun 28 18:12:29 CEST 2013
On Fri, Jun 28, 2013 at 6:06 PM, Jim Mooney <cybervigilante at gmail.com> 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 ;')
The Lazy Typist would actually do:
def foo(x):
return bool(x)
Or even:
foo = lambda x: bool(x)
--
Kwpolska <http://kwpolska.tk> | GPG KEY: 5EAAEA16
stop html mail | always bottom-post
http://asciiribbon.org | http://caliburn.nl/topposting.html
More information about the Tutor
mailing list