Skip to content

Commit 4642ccd

Browse files
Doc: Do not encourage using a base class name in a derived class (GH-22177)
1 parent c0f22fb commit 4642ccd

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Doc/faq/programming.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,18 +1517,18 @@ order` (MRO) with ``type(self).__mro__``, and return the next in line after
15171517
How can I organize my code to make it easier to change the base class?
15181518
----------------------------------------------------------------------
15191519

1520-
You could define an alias for the base class, assign the real base class to it
1521-
before your class definition, and use the alias throughout your class. Then all
1520+
You could assign the base class to an alias and derive from the alias. Then all
15221521
you have to change is the value assigned to the alias. Incidentally, this trick
15231522
is also handy if you want to decide dynamically (e.g. depending on availability
15241523
of resources) which base class to use. Example::
15251524

1526-
BaseAlias = <real base class>
1525+
class Base:
1526+
...
1527+
1528+
BaseAlias = Base
15271529

15281530
class Derived(BaseAlias):
1529-
def meth(self):
1530-
BaseAlias.meth(self)
1531-
...
1531+
...
15321532

15331533

15341534
How do I create static class data and static class methods?

0 commit comments

Comments
 (0)