New submission from Decorater:
So, many people rely on Decorators in class that accepts an instance of itself
like so:
class ExampleClass:
"""Example class with an example decorator that cannot be used."""
def __init__(self):
self.list_of_items = []
def add_item(self, item):
self.list_of_items.append(item)
@self.add_item("test_item")
def test_item():
print("Example function of ExampleClass that demonstrates the inability
to use decorators with self passed to it.")
Many people fall for this on classes and then they are like "Why is it not
letting me do this?". As such there is got to be a way to somehow support
something like this in Python 3.7 as it could be useful on classes like this.
The class above is an example, however I know of an library out there that
allows you to import from a file and also allows you to use the same thing
(that is imported) that would be bound to "self.[whatever it is called in the
class]". As such people try to avoid that import and use the one in
"self.[whatever it is called in the class]" to try to fit their needs (which
ends up failing for them).
----------
messages: 289818
nosy: Decorater
priority: normal
severity: normal
status: open
title: Cannot use Decorators of the same class that requires an instance of
itself to change variables in that class.
versions: Python 3.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue29848>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com