Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store_attr: does not update instance variable #496

Open
thatgeeman opened this issue Nov 7, 2022 · 0 comments
Open

store_attr: does not update instance variable #496

thatgeeman opened this issue Nov 7, 2022 · 0 comments

Comments

@thatgeeman
Copy link

Hi! Thanks for this wonderful library. Reporting a scenario where store_attr does not behave the way I want it to:

# case 1: works
class T:
    def __init__(self, a, b, c):
        store_attr() 
    def __repr__(self):
        return f'T({self.__stored_args__})'

# case 2: fails
class T_:
    def __init__(self, a, b, c):
        self.a = a - 1  # modify variable a
        store_attr()
    def __repr__(self):
        return f'T({self.__stored_args__})'
        
T(1, 2, 3), T_(1, 2, 3)
# (T({'a': 1, 'b': 2, 'c': 3}), T_({'a': 1, 'b': 2, 'c': 3}))

In the second case, I would've expected T_.a to store the updated attribute, but this is not the case. Is this not the intended use case (to store all attributes) or is it supposed to be used only to store the args passed to instantiate the class?
Cheers,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant