Skip to content

Instantly share code, notes, and snippets.

@evfro
Forked from amkatrutsa/default_args_overriding.py
Created February 20, 2018 07:45
Show Gist options
  • Save evfro/3c3413c043295b78ff95b9a7833f80f3 to your computer and use it in GitHub Desktop.
Save evfro/3c3413c043295b78ff95b9a7833f80f3 to your computer and use it in GitHub Desktop.
class Base(object):
def __init__(self, a):
self._a = a
class Derived(Base):
def __init__(self, a={"a": 3}, b=10):
super().__init__(a)
self._b = b
def update_a(self, a):
self._a["a"] = a
b_class = Base(5)
d_class = Derived()
print(d_class._a)
print(d_class._b)
d_class.update_a(100)
print(d_class._a)
print(d_class._b)
d_class = Derived()
print(d_class._a)
print(d_class._b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment