python method of taking a number as a temporary maximum of minimum

  • 2020-12-18 01:52:00
  • OfStack

Programming sometimes requires an initial maximum (or minimum) as temp, of course you can customize it to 10000 (whatever), but there is a value in python that you can replace:

This is available in python 2.7 (but not python3)


>>> import sys
>>> sys.maxint
2147483647

You can also use the numpy library (this python3 can also be used, but make sure you have numpy installed first, of course)


>>> import numpy as np
>>> np.iinfo(np.int16).max
32767
>>> np.iinfo(np.int32).max
2147483647
>>> np.iinfo(np.int16).min
-32768
>>> np.iinfo(np.int32).min
-2147483648

Related articles: