Skip to content

Commit

Permalink
AboutAttributeAccess: super would resolve to object
Browse files Browse the repository at this point in the history
  • Loading branch information
programmer-ke committed Apr 7, 2022
1 parent 800cdf5 commit 850064a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions koans/about_attribute_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ def __getattribute__(self, attr_name):
# Guess what happens when self.no_of_getattribute_calls is
# accessed?

# Using 'object' directly because using super() here will also
# trigger a __getattribute__() call.
return object.__getattribute__(self, attr_name)
return super().__getattribute__(attr_name)

def my_method(self):
pass
Expand Down Expand Up @@ -158,7 +156,7 @@ def __setattr__(self, attr_name, value):
elif attr_name[-3:] == 'pie':
new_attr_name = "a_" + new_attr_name

object.__setattr__(self, new_attr_name, value)
super().__setattr__(new_attr_name, value)

def test_setattr_intercepts_attribute_assignments(self):
fanboy = self.PossessiveSetter()
Expand Down Expand Up @@ -188,7 +186,7 @@ def __setattr__(self, attr_name, value):
if attr_name[0] != '_':
new_attr_name = "altered_" + new_attr_name

object.__setattr__(self, new_attr_name, value)
super().__setattr__(new_attr_name, value)

def test_it_modifies_external_attribute_as_expected(self):
setter = self.ScarySetter()
Expand Down

0 comments on commit 850064a

Please sign in to comment.