# Python logging with string formatting issue

**URL:** https://discourse.slicer.org/t/python-logging-with-string-formatting-issue/3366
**Category:** Development
**Created:** [July 3, 2018, 5:58pm UTC](https://discourse.slicer.org/t/python-logging-with-string-formatting-issue/3366 "2018-07-03T17:58:03Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)
#### Post date: [July 3, 2018, 7:21pm UTC](https://discourse.slicer.org/t/python-logging-with-string-formatting-issue/3366/3 "2018-07-03T19:21:14Z")

</div>

I’m using pylint as one of my linters and it explicitly warned to do it as:

```python
logging.debug("This is a %s", a)

```

instead of

```python
logging.debug("This is a %s" % a)

```

> **logging-not-lazy (W1201)**:  
> Specify string format arguments as logging function parameters Used when a logging statement has a call form of “logging.(format\_string % (format\_args…))”. Such calls should leave string interpolation to the logging method itself and be written “logging.(format\_string, format\_args…)” so that the program may avoid incurring the cost of the interpolation in those cases in which no message will be logged. For more, see [PEP 282 – A Logging System | peps.python.org](http://www.python.org/dev/peps/pep-0282/).

---

_[View the full topic](https://discourse.slicer.org/t/python-logging-with-string-formatting-issue/3366)._
