Skip to content

Instantly share code, notes, and snippets.

@vmorris
Created April 4, 2020 13:09
Show Gist options
  • Save vmorris/0ca0b55e006e9ac835964b1689e22e71 to your computer and use it in GitHub Desktop.
Save vmorris/0ca0b55e006e9ac835964b1689e22e71 to your computer and use it in GitHub Desktop.
python string formatting 101
>>> def log(msg, *args):
... if args:
... msg %= args
... print(msg)
...
>>> log('hi')
hi
>>> log('hi %s', 'mom')
hi mom
>>> log('testing %s %s %s', 1, 2, 3)
testing 1 2 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment