Decorators are syntactic sugar. They add no functionality.

@decorator
def/class possibly_long_name ...

abbreviates

def/class possibly_long_name ...
<possibly many lines running off screen or page>
possibly_long_name = decorator(possibly_long_name)

thereby warning the reader at the beginning that possibly_long_name will be rebound and avoiding typing possibly_long_name thrice.

Neither consideration applies to module imports.
Wrapping the functions and classed inside the module does not wrap the module, it mutates it. Module names tend to be short and would only need to be written twice, not thrice. And the mutation call would immediately follow the import line, so readers can easily see what happens.

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to