Day 87, closure in Python

Brush up Python for an interview.

Closure in Python. Yeah!

def outF(outArg):
  def innerF(innerArg):
    return outArg + innerArg
  return innerF

plusOne = outF(1)
plusTwo = outF(2)
print plusOne(10)
print plusTwo(10)

More things:
– more interviews
– get a parking ticket. Ouch!

Advertisements
Standard