Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ealmloff/functional-python
A python decorator that enforces functional programming within a function.
https://github.com/ealmloff/functional-python
Last synced: 8 days ago
JSON representation
A python decorator that enforces functional programming within a function.
- Host: GitHub
- URL: https://github.com/ealmloff/functional-python
- Owner: ealmloff
- License: gpl-3.0
- Created: 2020-11-21T22:41:43.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2020-11-22T01:27:02.000Z (about 4 years ago)
- Last Synced: 2024-12-22T04:41:59.493Z (16 days ago)
- Language: Python
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# functional-python
A python decorator that enforces functional programming within a function.The decorator requires the function to use no global variables unless the variables are all caps or builtin to python.
The decorator accepts a boolean value to signify weither or not caching should be implementedExample:
from math import pi
from functional import functionalSTATIC_GLOBAL_VAR = 100
nonStaticGlobal = -100@functional()
def goodFunction(): # will not raise an exception
global STATIC_GLOBAL_VAR
STATIC_GLOBAL_VAR -= 1
print(STATIC_GLOBAL_VAR)
print(print)goodFunction()
@functional()
def badFunction(): # will raise an exception
global nonStaticGlobal
nonStaticGlobal -= 1
print(nonStaticGlobal)badFunction()