Comment

Comment by dec0dedab0de

my favorite cheat is using locals() with string formatting something like this:

  def example_cheater(color, flavor, age):
    
      template = 'I am {age} years old and I like to wear {color} hats and eat {flavor} icecream'
      return template.format(**locals())

Obviously a contrived example, and it can be argued that using locals() is not very pythonic, but I think it makes the code look much nicer.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton