Steven D'Aprano a écrit :
(snip)
Avoiding early exits is an over-reaction to the Bad Old Days of spaghetti
code.
Mostly, yes. It can also be a way to help avoiding "resource leaks"
(memory or whatever) - just like try/finally blocks or the 'with'
statement in Python.
But used wisely, earl
On Dec 29, 7:00 pm, Steven D'Aprano wrote:
> On Mon, 29 Dec 2008 05:31:17 -0800, Aaron Brady wrote:
> > One style of coding I heard about once only permits returns at the end
> > of a function. It claims it makes it easier to see the function as a
> > mathematical object.
>
> That's silly. You tr
On Mon, 29 Dec 2008 05:31:17 -0800, Aaron Brady wrote:
> One style of coding I heard about once only permits returns at the end
> of a function. It claims it makes it easier to see the function as a
> mathematical object.
That's silly. You treat the function as a black box: input comes in, and
On Dec 28, 11:56 am, Gerard Flanagan wrote:
> On Dec 28, 5:19 pm, Roger wrote:
>
> > Hi Everyone,
> [...]
> > When I define a method I always include a return statement out of
> > habit even if I don't return anything explicitly:
>
> > def something():
> > # do something
> > retur
John Machin a écrit :
On Dec 29, 8:26 pm, Bruno Desthuilliers wrote:
John Machin a écrit :
(snip)
Please don't. Follow MRAB's advice, with the corollary that a
generator is forced by the compiler to be a "procedure" in MRAB's
terminology.
I fail to see any *practical* difference between MRAB
On Dec 29, 8:26 pm, Bruno Desthuilliers wrote:
> John Machin a écrit :
>
>
>
> > On Dec 29, 7:06 am, Roger wrote:
> >>> Curious. When I see a bare return, the first thing I think is that the
> >>> author forgot to include the return value and that it's a bug.
> >>> The second thing I think is tha
John Machin a écrit :
On Dec 29, 7:06 am, Roger wrote:
Curious. When I see a bare return, the first thing I think is that the
author forgot to include the return value and that it's a bug.
The second thing I think is that maybe the function is a generator, and
so I look for a yield. If I don't
On Dec 28, 5:12 pm, John Machin wrote:
> On Dec 29, 7:06 am, Roger wrote:
>
>
>
> > > Curious. When I see a bare return, the first thing I think is that the
> > > author forgot to include the return value and that it's a bug.
>
> > > The second thing I think is that maybe the function is a genera
On Dec 29, 7:06 am, Roger wrote:
> > Curious. When I see a bare return, the first thing I think is that the
> > author forgot to include the return value and that it's a bug.
>
> > The second thing I think is that maybe the function is a generator, and
> > so I look for a yield. If I don't see a y
On Dec 29, 8:36 am, Benjamin wrote:
> On Dec 28, 1:35 pm, Steven D'Aprano
> cybersource.com.au> wrote:
> > The second thing I think is that maybe the function is a generator, and
> > so I look for a yield.
>
> You shouldn't, though; Generators can't contain any return statement.
What gave you th
Benjamin wrote:
On Dec 28, 1:35 pm, Steven D'Aprano wrote:
The second thing I think is that maybe the function is a generator, and
so I look for a yield.
You shouldn't, though; Generators can't contain any return statement.
Yes, they can. It doesn't return a value, it just raises a StopIter
On Dec 28, 1:35 pm, Steven D'Aprano wrote:
> The second thing I think is that maybe the function is a generator, and
> so I look for a yield.
You shouldn't, though; Generators can't contain any return statement.
--
http://mail.python.org/mailman/listinfo/python-list
> Curious. When I see a bare return, the first thing I think is that the
> author forgot to include the return value and that it's a bug.
>
> The second thing I think is that maybe the function is a generator, and
> so I look for a yield. If I don't see a yield, I go back to thinking
> they've left
On Sun, 28 Dec 2008 12:38:50 -0500, Steve Holden wrote:
> Roger wrote:
>> Hi Everyone,
>>
>> First I want to thank everyone that posts to this group. I read it
>> daily and always learn something new even if I never feel like I have
>> anything to contribute but my questions.
>>
>> When I defin
Gerard Flanagan wrote:
On Dec 28, 5:19 pm, Roger wrote:
Hi Everyone,
[...]
When I define a method I always include a return statement out of
habit even if I don't return anything explicitly:
def something():
# do something
return
Is this pythonic or excessive? Is this an un
Roger wrote:
Hi Everyone,
First I want to thank everyone that posts to this group. I read it
daily and always learn something new even if I never feel like I have
anything to contribute but my questions.
Same here, I always read the news, but hardly post anything since am not
very much expe
Roger a écrit :
When I define a method I always include a return statement out of
habit even if I don't return anything explicitly:
def something():
# do something
return
Is this pythonic or excessive?
If it's the last statement in the function body, it is indeed "excessive
On Dec 28, 5:19 pm, Roger wrote:
> Hi Everyone,
[...]
> When I define a method I always include a return statement out of
> habit even if I don't return anything explicitly:
>
> def something():
> # do something
> return
>
> Is this pythonic or excessive? Is this an unnecessary af
Roger wrote:
> Hi Everyone,
>
> First I want to thank everyone that posts to this group. I read it
> daily and always learn something new even if I never feel like I have
> anything to contribute but my questions.
>
> When I define a method I always include a return statement out of
> habit even
On Dec 28, 11:19 am, Roger wrote:
> Hi Everyone,
>
> First I want to thank everyone that posts to this group. I read it
> daily and always learn something new even if I never feel like I have
> anything to contribute but my questions.
>
> When I define a method I always include a return statement
Hi Everyone,
First I want to thank everyone that posts to this group. I read it
daily and always learn something new even if I never feel like I have
anything to contribute but my questions.
When I define a method I always include a return statement out of
habit even if I don't return anything e
21 matches
Mail list logo