{"library":"random2","title":"random2 Library","description":"random2 is a Python library that provides a Python 3 compatible implementation of the Python 2 `random` module. Its primary purpose is to assist in migrating Python 2 code to Python 3 by preserving the exact behavior and algorithms of the older `random` module, particularly for applications requiring reproducible results from Python 2 seeds. The current version is 1.0.2, and the library appears to be unmaintained since 2017.","language":"python","status":"abandoned","last_verified":"Fri Apr 17","install":{"commands":["pip install random2"],"cli":null},"imports":["import random2","from random2 import randint"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import random2\n\n# Seed for reproducibility (mimics Python 2 behavior)\nrandom2.seed(42)\n\nprint(f\"Random integer between 1 and 10: {random2.randint(1, 10)}\")\nprint(f\"Random choice from a list: {random2.choice(['apple', 'banana', 'cherry'])}\")\nprint(f\"Random sample of 2 from a list: {random2.sample(range(10), 2)}\")\n\n# Demonstrates getting/setting state for exact reproduction\nstate = random2.getstate()\nprint(f\"Another random integer: {random2.randint(1, 10)}\")\nrandom2.setstate(state)\nprint(f\"Same random integer after restoring state: {random2.randint(1, 10)}\")","lang":"python","description":"This quickstart demonstrates basic usage of `random2` including seeding, generating random numbers, choices, and sampling, showcasing state preservation typical for Python 2 compatibility.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}