https://github.com/davidbuchanan314/magic-numbers
magically import magic number constants
https://github.com/davidbuchanan314/magic-numbers
magic magic-numbers python-imports python3 terrible-hack
Last synced: 7 months ago
JSON representation
magically import magic number constants
- Host: GitHub
- URL: https://github.com/davidbuchanan314/magic-numbers
- Owner: DavidBuchanan314
- License: mit
- Created: 2024-12-06T15:54:23.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-14T20:59:49.000Z (about 1 year ago)
- Last Synced: 2025-07-21T18:28:32.591Z (7 months ago)
- Topics: magic, magic-numbers, python-imports, python3, terrible-hack
- Language: Python
- Homepage: https://pypi.org/project/magic-numbers/
- Size: 17.6 KB
- Stars: 16
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# magic-numbers
Magically import magic number constants. Like so:
```py
from magic_numbers import FORTY_TWO, SIXTY_NINE, FOUR_HUNDRED_AND_TWENTY
from magic_numbers import ONE_THOUSAND_THREE_HUNDRED_AND_TWELVE
from magic_numbers import THREE_POINT_ONE_FOUR_ONE_FIVE_NINE_TWO as PI
from magic_numbers import NEGATIVE_SIX_HUNDRED_AND_SIXTY_SIX
from magic_numbers import MINUS_ZERO_POINT_ONE
print(f"{FORTY_TWO = }") # 42
print(f"{SIXTY_NINE = }") # 69
print(f"{FOUR_HUNDRED_AND_TWENTY = }") # 420
print(f"{ONE_THOUSAND_THREE_HUNDRED_AND_TWELVE = }") # 1312
print(f"{PI = }") # 3.141592
print(f"{NEGATIVE_SIX_HUNDRED_AND_SIXTY_SIX = }") # -666
print(f"{MINUS_ZERO_POINT_ONE = }") # -0.1
```
Note: Floats can only be specified using "point", there is no support (yet) for fractions like `THREE_AND_A_HALF` or `TWO_THIRDS`
## Installation
```sh
python3 -m pip install magic-numbers
```