Skip to content

docs: fix Person._name init typo in 05_Object_model/02#198

Open
mvanhorn wants to merge 1 commit intodabeaz-course:masterfrom
mvanhorn:osc/197-classes-encap-typo
Open

docs: fix Person._name init typo in 05_Object_model/02#198
mvanhorn wants to merge 1 commit intodabeaz-course:masterfrom
mvanhorn:osc/197-classes-encap-typo

Conversation

@mvanhorn
Copy link
Copy Markdown

Fixes #197

What changed

Notes/05_Object_model/02_Classes_encapsulation.md introduced _name as a private attribute but initialized it to 0:

class Person(object):
    def __init__(self, name):
        self._name = 0

The REPL block directly below then shows:

>>> p = Person('Guido')
>>> p._name
'Guido'

That only works if self._name = name. This PR changes the initializer to match the output shown in the same example.

One-line docs diff.

The Private Attributes example initialized self._name to 0, which
contradicted the REPL example two lines below where p._name read back
as 'Guido' (the name passed into __init__). Initialize to name so the
code and REPL output match.

Fixes dabeaz-course#197
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Typo in chapter '5.2 Classes and Encapsulation'

1 participant