django-planet
Jan. 20, 2020

Having some fun with Python

published by James Bennett
in blog James Bennett
original entry Having some fun with Python

The other day on a Slack I hang out in, someone posted an amusing line of Python code:

port = "{port}:{port}".format(port=port)

If it’s not clear after the inevitable Swedish-chef-muppet impression has run through your mind, this string-formatting operation will replace the contents of port with a string containing two copies of whatever was in port, separated by a colon. So if port was "foo", now it will …

Read full entry