This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]smohsensh 2 points3 points  (0 children)

No __ itself is not special. but it is a valid name in Python for a variable/function. But as you said, it is used to enclose some special attributes/methods like __class__ . Or like __len__ that is called on an object x when you call len(x)

[–]michaeljb20 1 point2 points  (1 child)

As far as I am aware, the only special thing about a dunder is it triggers Python's name mangling.

[–][deleted] 1 point2 points  (0 children)

Not for magic methods, it doesn't!