print line number and source filename
Stephen Hansen
me+list/python at ixokai.io
Tue Jun 22 15:00:09 EDT 2010
On 6/22/10 10:26 AM, Shashwat Anand wrote:
> ---- begin -----
> import logging
> logging.basicConfig(level=logging.DEBUG,format="%(asctime)s"
> "%(levelname)-5.5s [%(name)s %(module)s:%(funcName)s:%(lineno)d]"
> "%(message)s")
>
> def run():
> x = 5
> logging.debug("X = %d" % x)
>
> run()
> ----- end -----
>
> You can probably use string default concatenation feature of python.
> Anyway, am just nitpicking. Loved your example, as I was unaware of
> logging module.
As a sort of personal policy, I never use string concatenation. I do not
advocate this position or advise that others should follow it, but in my
experience-- for me-- it does not scale. I find I often want to go back
and modify or enhance an output with new data, and string concatenation
ends up becoming cumbersome after awhile, and so I always use format
strings so I don't have to rewrite the line to convert from + to % later.
(And in a couple years when I can migrate to Py3, I'll start using
.format())
--
Stephen Hansen
... Also: Ixokai
... Mail: me+list/python (AT) ixokai (DOT) io
... Blog: http://meh.ixokai.io/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20100622/853f63cc/attachment-0001.sig>
More information about the Python-list
mailing list