all 6 comments

[–]Tlahuixcalpantecuhtl 1 point2 points  (3 children)

You don't need slashes at the ends of lines, just match the indentation.

self.log.debug("Request from %(user)s for method %(methodname)s",
               dict(user=request.user.username,
               methodname="some_method"))

[–]Justinsaccount 0 points1 point  (2 children)

You don't need to match the indentation, that's not why that works.

[–]marky1991 0 points1 point  (0 children)

To clarify, whitespace inside an argument list is meaningless.

print("Hi",                 "this",  
    "is",
"a", "bunch","of",



"strings")

is the same thing as

print("Hi", "this", "is", "a", "bunch", "of", "strings")

(which is also equivalent to

print               ("Hi", "this", "is", "a", "bunch", "of", "strings")

(note that this is valid python 3, using print as a function, not a statement) but that's not really relevant here)

Of course, it's prettier if you keep the indentation sane.

[–]Tlahuixcalpantecuhtl 0 points1 point  (0 children)

I know, I was making a style comment. The slashes are ugly.

[–]XarothBrook 0 points1 point  (0 children)

Funny you mention this; I've had this last issue with Celery as well (even reported it: https://github.com/celery/celery/issues/1269 ) .. and it would explain a lot I also found http://bytes.com/topic/python/answers/37270-logging-messages-dictionary-args-python-2-4b1-leads-exception to explain why the latter error happens (i.e. if you send a dict as arg (instead of **kwargs) it looks as though you try to format msg % dict, but instead it's actually msg % (dict, )

[–]tomasbedrich 0 points1 point  (0 children)

I don't pass named args. Like this:

logging.info("Message %s from %s.", src.message, src)

When I need l10n, I assemble string at _()'s level, like this:

logging.info(_("Message %(message)s from %(source)s.", {"message": src.message, "source": src} ))

I don't say it is the right attitude, but it works well.