Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #87877
| References | <fg92halkvjecqedpogsmkov3o53f0i922b@4ax.com> |
|---|---|
| Date | 2015-03-24 21:29 +1100 |
| Subject | Re: module attributes and docstrings |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.99.1427192988.10327.python-list@python.org> (permalink) |
On Tue, Mar 24, 2015 at 7:55 PM, Mario Figueiredo <marfig@gmail.com> wrote:
> So things like the one below are something I got used to do, but that
> don't work after all, as I learned today:
>
> value_factory = lambda _, row: row[0]
> """Row factory. To be used with single-column queries."""
>
> There are other things I could possibly do, like turning that lambda
> into a function, or document attributes in the module docstring. They
> are fair responses.
They certainly are. Any time you assign a lambda function directly to
a simple name, it's probably worth replacing with a def function:
def value_factory(_, row):
"""Row factory. To be used with single-column queries."""
return row[0]
(Though I'd be inclined to give the first parameter a proper name here)
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
module attributes and docstrings Mario Figueiredo <marfig@gmail.com> - 2015-03-24 09:55 +0100
Re: module attributes and docstrings Chris Angelico <rosuav@gmail.com> - 2015-03-24 21:29 +1100
Re: module attributes and docstrings Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-24 22:49 +1100
Re: module attributes and docstrings Mario Figueiredo <marfig@gmail.com> - 2015-03-26 10:48 +0100
Re: module attributes and docstrings Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-27 18:31 +1100
Re: module attributes and docstrings Marko Rauhamaa <marko@pacujo.net> - 2015-03-27 09:49 +0200
Re: module attributes and docstrings Terry Reedy <tjreedy@udel.edu> - 2015-03-24 15:33 -0400
Re: module attributes and docstrings Mario Figueiredo <marfig@gmail.com> - 2015-03-26 10:53 +0100
Re: module attributes and docstrings Chris Angelico <rosuav@gmail.com> - 2015-03-26 21:27 +1100
csiph-web