/trunk/Examples/python/functor/runme.py

# · Python · 17 lines · 9 code · 5 blank · 3 comment · 1 complexity · 56516f7b04da29b324a29a070fb302de MD5 · raw file

  1. # Operator overloading example
  2. import example
  3. import math
  4. a = example.intSum(0)
  5. b = example.doubleSum(100.0)
  6. # Use the objects. They should be callable just like a normal
  7. # python function.
  8. for i in range(0,100):
  9. a(i) # Note: function call
  10. b(math.sqrt(i)) # Note: function call
  11. print a.result()
  12. print b.result()