Skip to content

Instantly share code, notes, and snippets.

@terror
Last active November 14, 2021 02:50
Show Gist options
  • Save terror/2968c70565a5aea65675fe5041b0435b to your computer and use it in GitHub Desktop.
Save terror/2968c70565a5aea65675fe5041b0435b to your computer and use it in GitHub Desktop.
from string import Template
def main():
x = 'world'
# I.
print(f'hello {x}!')
# II.
print('hello {}!'.format(x))
# III.
print('hello %s!' % x)
# IV.
t = Template('hello $x!')
print(t.substitute(x=x))
# lol
(lambda s: print('hello {}!'.format(f'{"%s" % Template("$s").substitute(s=s)}')))(x)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment