/tags/rel-1-3-26/SWIG/Examples/python/varargs/runme.py

# · Python · 34 lines · 11 code · 16 blank · 7 comment · 2 complexity · 1201bd91f72b9999dd7f28dd43044be1 MD5 · raw file

  1. # file: example.py
  2. import sys
  3. import example
  4. # Call printf
  5. example.printf("Hello World. I'm printf\n")
  6. # Note: We call printf, but use *python* string formatting
  7. for i in range(0,10):
  8. example.printf("i is %d\n" % i)
  9. # This will probably be garbled because %d is interpreted by C
  10. example.printf("The value is %d\n")
  11. # Call fprintf
  12. example.fprintf(sys.stdout,"Hello World. I'm fprintf\n")
  13. for i in range(0,10):
  14. example.fprintf(sys.stdout,"i is %d\n" % i)
  15. # This won't be garbled since %d is not interpreted
  16. example.fprintf(sys.stdout,"The value is %d\n")
  17. # This function calls our NULL-terminated function
  18. example.printv("Hello","World","this","is","a","test.")