Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #35279

Re: Pass and return

From Duncan Booth <duncan.booth@invalid.invalid>
Newsgroups comp.lang.python
Subject Re: Pass and return
Date 2012-12-21 08:52 +0000
Message-ID <XnsA1305A4D52D45duncanbooth@127.0.0.1> (permalink)
References <02b7f61c-6eef-4301-a0bc-6cf8473b6fa1@googlegroups.com> <mailman.1137.1356068710.29569.python-list@python.org>

Show all headers | View raw


Mitya Sirenef <msirenef@lightbird.net> wrote:

> On 12/21/2012 12:23 AM, iMath wrote:
>> Pass and return
>> Are these two functions the same ?
>>
>> def test():
>>      return
>>   
>> def test():
>>      pass
> 
> 
>  From the point of style, of course, the latter is
> much better because that's the idiomatic way
> to define a no-op function. With a return, it
> looks like you might have forgotten to add the
> value to return or deleted it by mistake.
> 
I would say it is *an* idiomatic way to define a no-op function.

Another idiomatic way is to use a doc-string as the only body, 
that way you can also explain why you feel the need for an empty 
function.

-- 
Duncan Booth http://kupuguy.blogspot.com

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Pass and return iMath <redstone-cold@163.com> - 2012-12-20 21:23 -0800
  Re: Pass and return Mitya Sirenef <msirenef@lightbird.net> - 2012-12-21 00:40 -0500
  Re: Pass and return Mitya Sirenef <msirenef@lightbird.net> - 2012-12-21 00:45 -0500
    Re: Pass and return Duncan Booth <duncan.booth@invalid.invalid> - 2012-12-21 08:52 +0000
      Re: Pass and return Mitya Sirenef <msirenef@lightbird.net> - 2012-12-21 12:15 -0500
  Re: Pass and return Chris Angelico <rosuav@gmail.com> - 2012-12-21 17:19 +1100
  Re: Pass and return Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-21 08:27 +0000
  Re: Pass and return iMath <redstone-cold@163.com> - 2012-12-22 07:11 -0800

csiph-web