神刀安全网

Decorating: Literally Decorating Your Own Terminal with Python Decorators

Decorating: A Meta Repo To Decorators

Decorating: Literally Decorating Your Own Terminal with Python Decorators Decorating: Literally Decorating Your Own Terminal with Python Decorators Decorating: Literally Decorating Your Own Terminal with Python Decorators Decorating: Literally Decorating Your Own Terminal with Python Decorators Decorating: Literally Decorating Your Own Terminal with Python Decorators Decorating: Literally Decorating Your Own Terminal with Python Decorators Decorating: Literally Decorating Your Own Terminal with Python Decorators

Abstract

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 @animated and @writing decorator. BTW, because is fun too. All the repository is made from scratch, just using the Python stdlib , nodependency!

Installation

INFO: we need some people to do support for Python2, only Python3 for now. Check #3

stable: last release: sudo pip install decorating

bleeding-edge: sudo pip install git+https://www.github.com/ryukinix/decorating

Usage

Public decorators on the API of decorators decorating :

  • debug
  • cache
  • counter
  • count_time
  • animated
  • writing

Examples

Animated

Using as decorator and mixed with context-managers Decorating: Literally Decorating Your Own Terminal with Python Decorators

Well

Using with nested context-managers Decorating: Literally Decorating Your Own Terminal with Python Decorators

Writing

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:

Decorating: Literally Decorating Your Own Terminal with Python Decorators

Developers

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 site-packages / 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)

Contributing

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.

License

Decorating: Literally Decorating Your Own Terminal with Python Decorators

MIT

Because good things need be free.

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » Decorating: Literally Decorating Your Own Terminal with Python Decorators

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址