Skip to content

Commit f72101b

Browse files
Doc: Do not encourage using a base class name in a derived class (GH-22177)
(cherry picked from commit 4642ccd) Co-authored-by: Andre Delfino <adelfino@gmail.com>
1 parent 9e935ad commit f72101b

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

Doc/faq/programming.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,18 +1518,18 @@ provide the ``self`` argument.
15181518
How can I organize my code to make it easier to change the base class?
15191519
----------------------------------------------------------------------
15201520

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

1527-
BaseAlias = <real base class>
1526+
class Base:
1527+
...
1528+
1529+
BaseAlias = Base
15281530

15291531
class Derived(BaseAlias):
1530-
def meth(self):
1531-
BaseAlias.meth(self)
1532-
...
1532+
...
15331533

15341534

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

0 commit comments

Comments
 (0)