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


Groups > comp.lang.python > #48930

Re: n00b question on spacing

References <CAJ=2b07ETuSuo2+3Xu6vMOJA+q1JwUFTezO3LaYLG8wXd+FLBQ@mail.gmail.com> <51C4D2FF.8000709@digipen.edu> <CAN1F8qVk+Vor1USX0V7mS13K3rR8NyRc9Gt9KkF32RGakZJ_Kw@mail.gmail.com>
From Joshua Landau <joshua.landau.ws@gmail.com>
Date 2013-06-22 16:50 +0100
Subject Re: n00b question on spacing
Newsgroups comp.lang.python
Message-ID <mailman.3697.1371916294.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 22 June 2013 14:36, Joshua Landau <joshua.landau.ws@gmail.com> wrote:
> My favourite way would be along the lines of:
>
> message = "Item wrote to MongoDB database "
> message += "{0[MONGODB_DB]}/{0[MONGODB_COLLECTION]}".format(settings)
> log.msg(message, level=log.DEBUG, spider=spider)

To make a habit of replying to myself, I thought I'd point out I wrote
it this way mostly because I have no idea how big "settings" is.

If it's not large and only contains keys that are valid identifiers,
it'd be more readable to write:

message = "Item wrote to MongoDB database "
message += "{MONGODB_DB}/{MONGODB_COLLECTION}".format(**settings)
log.msg(message, level=log.DEBUG, spider=spider)

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


Thread

Re: n00b question on spacing Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-22 16:50 +0100

csiph-web