long.py 751 B

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright David Abrahams 2004. Distributed under the Boost
  2. # Software License, Version 1.0. (See accompanying
  3. # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. import sys
  5. if (sys.version_info.major >= 3):
  6. long = int
  7. '''
  8. >>> from long_ext import *
  9. >>> print(new_long())
  10. 0
  11. >>> print(longify(42))
  12. 42
  13. >>> print(longify_string('300'))
  14. 300
  15. >>> is_long(long(20))
  16. 'yes'
  17. >>> is_long('20')
  18. 0
  19. >>> x = Y(long(4294967295))
  20. '''
  21. def run(args = None):
  22. import sys
  23. import doctest
  24. if args is not None:
  25. sys.argv = args
  26. return doctest.testmod(sys.modules.get(__name__))
  27. if __name__ == '__main__':
  28. print("running...")
  29. import sys
  30. status = run()[0]
  31. if (status == 0): print("Done.")
  32. sys.exit(status)