views:

100

answers:

2

I was wondering if it's frowned upon to use the decorator module that comes with python. Should I be creating decorators using the original means or is it considered okay practice to use the module?

A: 

I'm not sure of what you mean by the "decorator module." But if you care about properly mimicking the wrapped function while using minimal boilerplate, you should take a look at the functools module.

Couple of reasons for "properly" wrapping functions off the top of my head:

  • (2.x, not sure of 3.x) - Pickling objects with decorated methods
  • Compatibility with any metaprogramming
Jeremy Brown
+1  A: 

the decorator module in pypi is a third party module from Michele Simionato. It does not belong to the python standard library.

In most cases you dont need this module to work with decorators.

Still it provides you with some useful tools that can simplify some uses of decorators. In any case it is a nice module to learn about decorators

joaquin
Thanks for this answer. I was just wondering if it were good practice or not. I think I have gathered that I should create my decorators using more traditional means rather than using the module in pypi.
Kyle Terry