Skip to content

Class Documentation Issue #138011

@Fosters4him

Description

@Fosters4him

Documentation

In the tutorial "MyClass" class discussion, MyClass is defined as follows.

class MyClass:
    """A simple example class"""
    i = 12345

    def f(self):
        return 'hello world'

In the method object section, x.f() is said to be normally called after it is bound, however this statement ends in error, "Missing 1 required positional argument 'self'

Then it states the following script will repeat forever, however it gets the same error Missing 1 required positional argument 'self'

xf = x.f
while True:
    print(xf())

To fix the issue remove the "self" from method f() as below and everything works as intended.

    def f():
        return 'hello world'

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions