Re: [Tutor] multiple function returns

2013-06-28 Thread Alan Gauld
On 28/06/13 19:51, Jim Mooney wrote: Now you'll make me learn what lambda is. Ah, it's like an anonymous function in jQuery, That's the idea but Python lambdas are a bit crippled so its really an anonymous expression... :-( But if you know JQuery then lambdas should be easy to pick up. And t

Re: [Tutor] multiple function returns

2013-06-28 Thread Dave Angel
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

Re: [Tutor] multiple function returns

2013-06-28 Thread Steven D'Aprano
On 28/06/13 14:18, Jim Mooney wrote: What's the Pythonic standard on multiple returns from a function? It seems easiest to just return from the point where the function fails or succeeds, even it that's multiple points. Or is it considered best to defer everything to one return at the end? The

Re: [Tutor] multiple function returns

2013-06-28 Thread Alan Gauld
On 28/06/13 05:18, Jim Mooney wrote: What's the Pythonic standard on multiple returns from a function? There is no standard. Multiple returns are quite common but they come with all the usual caveats for using them, they can introduce complexity and hard to find bugs so use them sensibly. Co