Skip to content

Unable to set a property of a class as a default parameter for a subclass #128099

@Bot1-Pzon

Description

@Bot1-Pzon

Bug report

Bug description:

While developing one of my personal projects I encountered this unexpected and unintuitive behaviour:
I could not use a class variable of a parent class as a default argument of one of his sub classes.

class Parent_Class:
    a = 1

    class Sub_Class:

        def method(x = Parent_Class.a): #! "Parent_Class" is not defined
            ...

I think this is not intended as it is not intuitive nor logical, therefore I frame it as a bug.

Hoping to help.

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions