I have a descriptor
class ReferredItem():
def __init__(self, method):
self.method = method
def __get__(self, obj, objtype):
...
I use it as decorator:
class MyClass():
@ReferredItem
some_method(self):
...
I’ve seen the decorators are lower case. But classes should be named in camel case.
Should i name the class like referred_item? Or leave it as it is now?
PEP8 states that
without explaining what the exceptions are, but in the standard library, classes that are most commonly used as functions usually follow the function naming convention. E.g.
itertools.groupbyis actually a class, but you don’t notice that in ordinary usage; it’s an implementation detail andgroupbycould be rewritten as an actual function.You can adopt a similar style by using the all-lowercase decorator naming convention for classes used as decorators:
referred_item, notReferredItem.