n00b question on spacing

Joshua Landau joshua.landau.ws at gmail.com
Sat Jun 22 11:50:47 EDT 2013


On 22 June 2013 14:36, Joshua Landau <joshua.landau.ws at 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)



More information about the Python-list mailing list