Undecorate python functions, methods or classes
Project description
This library provides an easy way to strip a function of its decorators.
Tested on python 2.6 up to 3.6:
Quickstart
Install:
$ pip install undecorated
Try it on one of your functions:
>>> from undecorated import undecorated
>>> undecorated(my_decorated_function)
<function my_decorated_function at 0x7fbdd6e95938>
undecorated has returned your original function clean of any decorators.
It also works with class decorators!
Example
>>> from functools import wraps
>>> from undecorated import undecorated
>>>
>>> def decorate_with(*decorations):
... def decorator(f):
... @wraps(f)
... def wrapper(*args, **kwargs):
... print decorations
... return f(*args, **kwargs)
... return wrapper
... return decorator
...
>>> @decorate_with('yellow_bauble')
... @decorate_with('red_bauble')
... @decorate_with('tinsel')
... def tree():
... print 'tree'
...
>>> tree()
('yellow_bauble',)
('red_bauble',)
('tinsel',)
tree
>>> undecorated(tree)()
tree
Project
This project uses Semantic Versioning <http://semver.org>.
License
Copyright 2016 Ionuț Arțăriși <ionut@artarisi.eu>
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file undecorated-0.3.0.tar.gz
.
File metadata
- Download URL: undecorated-0.3.0.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83eca0a85e6e62ac8bc6bf938c8a70003e58ef084932d5930d7699e5759a3a3e |
|
MD5 | 1b8b2e0cbf0c7d5c180d32884a583ae2 |
|
BLAKE2b-256 | 7d61262785a7a47c7613ddd41608d2370e44768d48060d15071f298dbac19f9a |
File details
Details for the file undecorated-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: undecorated-0.3.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d668d6c076f05b0bdf3bc399af9541f8b9afa4fad653ddec4afa2eca606162f9 |
|
MD5 | ddc90aa1ccd74750a1ae670c935d71dd |
|
BLAKE2b-256 | ae6394c4786e13fe1ea5b5743ed9498777befe6a1a5adf30605c6406106463d2 |
File details
Details for the file undecorated-0.3.0-py2-none-any.whl
.
File metadata
- Download URL: undecorated-0.3.0-py2-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c627ab442be70240f86bc54f57efae1194a242ee8f051befaf7760f51fb44f22 |
|
MD5 | 82fbded03b757829b1734e395f12a267 |
|
BLAKE2b-256 | 62d5943ec88ba20a41e6d7b6a65224b573fa8ab275dc79d0000fc957096a0968 |