Single assignment variables in Python
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
invars Initial version Dec 7, 2018
tests Initial version Dec 7, 2018
.gitignore Initial version Dec 7, 2018
.gitlab-ci.yml Fix .gitlab-ci.yml Dec 7, 2018
CHANGELOG.md Fix setup.py Dec 7, 2018
LICENSE Add LICENSE Dec 3, 2018
MANIFEST.in Fix setup.py Dec 7, 2018
README.md Initial version Dec 7, 2018
VERSION Fix setup.py Dec 7, 2018
setup.cfg Configured .gitlab-ci.yml: test + deploy pypi Dec 7, 2018
setup.py Fix setup.py Dec 7, 2018

README.md

invars

This package brings invariable variables or single assignment variables to Python (like in Erlang and other functional programming languages).

Examples

one = 1
two = 2
...
two += one  # invalid!
total = 0
for i in range(4):
    total += i  # invalid!

Installation

$ pip install invars

Usage

$ invars my_script.py

Why?

In functional programming, assignment is discouraged in favor of single assignment. [...] Imperative assignment can introduce side effects while destroying and making the old value unavailable while substituting it with a new one

Wikipedia

Single assignment variables simplifies a lot of things because it takes out the "time" variable from your programs.

Stack Overflow

TODO

  • Integrate with flakes8