n00b question on spacing

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


On 22 June 2013 16:24, Rick Johnson <rantingrickjohnson at gmail.com> wrote:
> 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.

Erm, as you wish.

> Plus, your use of the format  syntax is
> incorrect.

Wut?

>   _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.

If you say so.



More information about the Python-list mailing list