An open API service indexing awesome lists of open source software.

https://github.com/grgomariani/python-decorators

A list of useful python decorators
https://github.com/grgomariani/python-decorators

bdd console debug decorator dfa python-decorators

Last synced: about 15 hours ago
JSON representation

A list of useful python decorators

Awesome Lists containing this project

README

        

# Python Decorators

#### Description

A list of helpful self-made Python decorators.
Might be of use to someone while thinking about some design patterns you could use in your next project.

All code and examples are made to run on Python 3.3+

```python
@use_this_decorator
def on_this_function():
pass
```

## Analyze
A group of helpful decorators for debugging and optimizing your code. Decorate your functions to keep track of how many times you call them and how long their execution takes.

[___Check Example Code___](example_analyze.py)

## BDD tests
A short take on Behaviour Driven Development testing.

[___Check Example Code___](example_bdd_tests.py)

## Change
Decorators that change the function or it's input arguments. Or both.

[___Check Example Code___](example_change.py)

## Command Line
A fun way to emulate the command line in under 50 lines of code. Try it!

[___Check Example Code___](example_command_line.py)

## Conditional
The decorator that executes the given function only if the condition is met.

[___Check Example Code___](example_conditional.py)

## DFA
Deterministic Finite Automaton Emulator. A really simplified one, at least.

[___Check Example Code___](example_dfa.py)

## do in main thread
Executes the given function in the main thread.

[___Check Example Code___](example_do_in_main_thread.py)

## Max Refresh
I should really get a better name for this. Best to check the example.

[___Check Example Code___](example_max_refresh.py)

## Print Me
Prints the function, it's arguments and result. Really helpful for debugging.

[___Check Example Code___](example_print_me.py)

## Stack Results
Emulates a giant stack on which to put results that can be taken care of later.

[___Check Example Code___](example_stack_results.py)

## Ternary
A slightly different take on ternary operator.

[___Check Example Code___](example_ternary.py)

## TODO
Writing a lot of functions that are only defined? Use this.

[___Check Example Code___](example_todo.py)

## VA_ARGS
C-style va_args operator.

[___Check Example Code___](example_va_args.py)