Learning Python: Chapter 15

A function definition may be put inside an if-block.

if DEBUG:
  def do_something():
    print ‘useful debug information’
    do_some_work()
else:
  def do_something():
    do_some_work()

Leave a Reply