n00b question on spacing
Rick Johnson
rantingrickjohnson at gmail.com
Sat Jun 22 11:24:44 EDT 2013
On Saturday, June 22, 2013 8:36:43 AM UTC-5, Joshua Landau wrote:
> message = "Item wrote to MongoDB database "
> message += "{0[MONGODB_DB]}/{0[MONGODB_COLLECTION]}".format(settings)
> log.msg(message, level=log.DEBUG, spider=spider)
If you're going to whore out parts of the string to
variables i would suggest going for the gold and actually
make it readable. Plus, your use of the format syntax is
incorrect.
_arg1 = settings['MONGODB_DB']
_arg2 = settings['MONGODB_COLLECTION']
_fmtstr = "Item wrote to MongoDB database {0}, {1}"
msg = _fmtstr.format(_arg1, _arg2)
log.msg(msg, level=log.DEBUG, spider=spider)
If you want readability, now you got it.
More information about the Python-list
mailing list