Skip to content

Files

Latest commit

0d8e31e · Jan 30, 2024

History

History

stdlib

Polyfills - stdlib

Backporting of some of the features natively available in newer Python versions:

  • bool class (as well as True and False)
  • sorted() function (Python 2.4)
  • sum() function (Python 2.3)
  • enumerate() function (Python 2.3)
  • print() function (keyword arguments such as end or sep were added in Python 3.3, see module docstring for more details)
  • NotImplementedError exception (Python 2.2)
  • set() class (Python 2.4)

For a quick one-time workaround for True and False:

exec("try: (True, False)\nexcept NameError: exec('True = 1==1; False = 1==0')")