Decorating: A Meta Repo To Decorators
This project was encouraging a explore the limits of decorators powers in Python, whose, however is not so knew for everyone (mainly the beginners), is a extremely useful feature of the language similar, whose can be similar of Lisp Macros, but without change the AST. The famous examples is the
@writing decorator. BTW, because is fun too. All the repository is made from scratch, just using the Python
stdlib , nodependency!
INFO: we need some people to do support for Python2, only Python3 for now. Check #3
stable: last release:
sudo pip install decorating
sudo pip install git+https://www.github.com/ryukinix/decorating
Public decorators on the API of decorators
Using as decorator and mixed with context-managers
Using with nested context-managers
Another project mine calledMAL whose is a basic command line interface for MyAnimeList, I recently test the features of @writing only adding 3 lines on my code! Check the awesome effect:
sudo git clone https://www.github.com/ryukinix/decorating cd decorating sudo make develop
The develop mode creates a .egg-info (egg-link) as symlink with your standard
dist-packages directory. Don’t be worry with the
decorating.egg-info , is only information for the package egg to link with your
PYTHONPATH . For that, the usage is dynamic, you can modify the code in test on the command line always using absolute imports in anywhere (like the first example)
Avoid I blame you. You maybe don’t will like that. I’m not Linus, but I can really do heavy critiques sometimes.[/lain ]. Although I’m joking, keep your life more easy, so setup the
pre-commit after clone!
In the root of git repository, do that commands:
sudo pip install pre-commit pylint nose2 pre-commit install
If you don’t know about pre-commit, check pre-commit website.
Now you can create a new branch
git checkout -b feature based on the
master (or other you wants improves, like
dev ) and send a pull-request for me!
If you just wants know something, I give a suggestion, create a new issue! I’ll happy with it.
Because good things need be free.
转载本站任何文章请注明：转载至神刀安全网，谢谢神刀安全网 » Decorating: Literally Decorating Your Own Terminal with Python Decorators