python / cpython

The Python programming language
https://www.python.org/
Other
60.75k stars 29.33k forks source link

Generator store recall #120897

Closed karanbosamia closed 2 hours ago

karanbosamia commented 6 days ago

Feature or enhancement

Proposal:

Can a function be inside a class in generator where store_recall method could reinstantiate the object so that it can store the same to the namespace again and the value could be stored at the time of when the instance is called?

# Add a code block here, if required
def __init__(self):
    self.old_value = self.value

def store_recall(self):
    return self.old_value # which is stored in the class at the time of instantiation

Is this possible?

Has this already been discussed elsewhere?

No

Links to previous discussion of this feature:

N/A

Zheaoli commented 6 days ago

Would you mind to share fully demo code or share why the feature is necessary?

ronaldoussoren commented 2 hours ago

This is a question about using Python, that's not what this issue tracker is used for.

Please ask your question at https://discuss.python.org/c/users/7.