You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: materials/source/notes/session09.rst
+42-2Lines changed: 42 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,9 +22,49 @@ Matthew D Briggs
22
22
Issues that came up during the week.
23
23
====================================
24
24
25
-
"private" attributes and dunders...
25
+
"private" attributes and dunders
26
+
--------------------------------
27
+
28
+
``_something`` vs ``__something`` vs ``__something__``
29
+
30
+
Adding parameters to a subclass __init__
31
+
----------------------------------------
32
+
33
+
In general, when you override a method in a subclass, you want the method signature to be the same. That is -- all the parameters should be the same.
34
+
35
+
36
+
However, sometimes, particularly with ``__init__``, you may need a couple extra parameters. To keep things clean and extensible, you want to put the extra parameters at the beginning, before the super class' parameters:
37
+
38
+
And this lets you use ``*args`` and ``**kwargs`` to pass along the usual ones.
0 commit comments