Skip to main content

The set of useful decorators.

Project description

pydecos - is a set of useful decorators.

  • deprecate: to deprecate class/method/function. Deprecation reason can be specified.
  • ...

Installation

For most users, the recommended method to install is via pip:

pip install pydedecos

or from a source:

python setup.py install

Import

from pydecos import deprecated

Usage examples

- @deprecated

  • function
from pydecos import deprecated


@deprecated
def some_func(t):
  print('weeeee' * t)


some_func(3)
# <input>:1: DeprecationWarning: Call to deprecated function some_func.
# weeeeeweeeeeweeeee
  • class
from pydecos import deprecated


@deprecated
class SomeClass:
    def some_method(self):
        ...


SomeClass()
# DeprecationWarning: Deprecated class has been invoked "SomeClass".
# SomeClass()
  • method
from pydecos import deprecated


class SomeClass:

    @deprecated
    def some_method(self):
        ...


SomeClass().some_method()
# DeprecationWarning: Deprecated function/method "some_method" has been invoked.
# SomeClass().some_method()
  • deprecation with reason specified
from pydecos import deprecated


@deprecated('Use the new function "awesome_func()" instead')
def some_func(t):
  return t


some_func(3)
# DeprecationWarning: Deprecated function/method "some_func" has been invoked: Use the new function "awesome_func()" instead.
#  some_func(3)

- @timestamp

from pydecos import timestamp


@timestamp
def some_func(t):
  return t


some_func(3)
print(some_func.created_at)

# 2021-01-15 20:58:45.071720

- @count_call

from pydecos import count_call


@count_call
def some_func():
  pass


some_func()
some_func()
some_func()
print(some_func.counter)
# 3

Changelog

0.0.2 (15.01.2021)

Added new decorators

  • time_limit (linux only)
  • count_call
  • timestamp
  • timer
  • makebold
  • makeitalic
0.0.1 (14.01.2021)
  • initial commit

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

pydecos-0.0.2.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

pydecos-0.0.2-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file pydecos-0.0.2.tar.gz.

File metadata

  • Download URL: pydecos-0.0.2.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.0

File hashes

Hashes for pydecos-0.0.2.tar.gz
Algorithm Hash digest
SHA256 14bf02184ec10b5fd6bcaba272370f1845b3358cc39a907b9b0dbb60b2e0b7f7
MD5 06dbbdbe3baccdcb25504e89d1f7fabd
BLAKE2b-256 5cddf2a8cf736d65e26312bdef19c4feef1f0bd2501366458569628234b87464

See more details on using hashes here.

File details

Details for the file pydecos-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pydecos-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.0

File hashes

Hashes for pydecos-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ac92a8477639226f4470d8d801b6905a7217097314eef3334dd8eeeb00835441
MD5 770d31281bc54c6556dccfbc256edc93
BLAKE2b-256 4dd571dd9d2e676c8de477e908a1546dd75034271bc8b5c2a48dee17f894327c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page