Skip to content

Behaviour of pattern matching and class private names is currently ambiguous #94499

Closed
@da-woods

Description

@da-woods

Feature or enhancement

class C:
  def f(self, x):
    match x:
      case D(__something=y):
        return y

Currently (Python 3.10, 3.11) this matches x.__something. Under most other circumstances it'd look up x._C__something. This seems reasonable to me, but doesn't seem to be tested for (so it isn't clear that it's been "decided")

I propose to keep the current behaviour, but add a test so that it's at least "fixed"

Previous discussion

I asked on Python-dev list https://mail.python.org/archives/list/[email protected]/thread/LILLO3MBTVY6ZQT3VNUVXATEPS3ASGQF/ - the one reply suggested the current behaviour was OK

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions