readonly
readonly is a python package that acts as an alternative to frozenset, but for dictionaries.
🛠️ Requirements
readonly requires Python 3.9 or above.
To install Python 3.9, I recommend using pyenv.
# install pyenv
git clone https://github.com/pyenv/pyenv ~/.pyenv
# setup pyenv (you should also put these three lines in .bashrc or similar)
# if you are using zsh
cat << EOF >> ~/.zshrc
# pyenv config
export PATH="${HOME}/.pyenv/bin:${PATH}"
export PYENV_ROOT="${HOME}/.pyenv"
eval "$(pyenv init -)"
EOF
# or if you using the default bash shell, do this instead:
cat << EOF >> ~/.bashrc
# pyenv config
export PATH="${HOME}/.pyenv/bin:${PATH}"
export PYENV_ROOT="${HOME}/.pyenv"
eval "$(pyenv init -)"
EOF
# Close and open a new shell session
# install Python 3.9.10
pyenv install 3.9.10
# make it available globally
pyenv global system 3.9.10
To manage the Python 3.9 virtualenv, I recommend using poetry.
# install poetry
curl -sSL https://install.python-poetry.org | python3 -
poetry --version
Poetry version 1.1.13
# Having the python executable in your PATH, you can use it:
poetry env use 3.9.10
# However, you are most likely to get the following issue:
Creating virtualenv readonly-dxc671ba-py3.9 in ~/.cache/pypoetry/virtualenvs
ModuleNotFoundError
No module named 'virtualenv.seed.via_app_data'
at <frozen importlib._bootstrap>:973 in _find_and_load_unlocked
# To resolve it, you need to reinstall virtualenv through pip
sudo apt remove --purge python3-virtualenv virtualenv
python3 -m pip install -U virtualenv
# Now, you can just use the minor Python version in this case:
poetry env use 3.9.10
Using virtualenv: ~/.cache/pypoetry/virtualenvs/readonly-dxc671ba-py3.9
🚨 Installation
With pip
:
python3.9 -m pip install readonly
🚸 Usage
>>> from readonly import readonly
>>> import math
>>> math = readonly(math)
# raises AttributeError
>>> math.pi = 3.0
🎉 Credits
The following projects were used to build and test readonly
.
👋 Contribute
If you are looking for a way to contribute to the project, please refer to the Guideline.
📝 License
This program and the accompanying materials are made available under the terms and conditions of the GNU GENERAL PUBLIC LICENSE.