Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35309
| Date | 2012-12-21 12:15 -0500 |
|---|---|
| From | Mitya Sirenef <msirenef@lightbird.net> |
| Subject | Re: Pass and return |
| References | <02b7f61c-6eef-4301-a0bc-6cf8473b6fa1@googlegroups.com> <mailman.1137.1356068710.29569.python-list@python.org> <XnsA1305A4D52D45duncanbooth@127.0.0.1> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1162.1356110144.29569.python-list@python.org> (permalink) |
On 12/21/2012 03:52 AM, Duncan Booth wrote: > 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. > That's true, a docstring is preferable in many cases. -m -- Lark's Tongue Guide to Python: http://lightbird.net/larks/
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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