Skip to content

Question: double forward underscores  #30

Closed
@vyahello

Description

@vyahello

Hey guys, I'm pretty excited about your course and job you have done to make it, that's really thorough work.

But sometimes I'm getting a bit confused when seeing double underscores in functions/variables names in various 100DaysOfWeb chapters.
I know that those are used as super-private objects or relative, but can you guys explain me as experts, what is reason to not use a single forward underscore as conventional privacy in python but use double underscores?
For instance, please take a look at a code snippet below (chapter 33-36). Can't we use just self._result name instead of self.__result here to mark that it should be a private one?

class switch:
    __no_result = uuid.uuid4()

    def __init__(self, value):
        self._found = False
        self.__result = switch.__no_result

Do you think it's worth to mention that somewhere in a course? thx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions