1

for example:

class Test(object):
    __id = 1

    @classmethod
    def get(cls):
        #cls is the same with Test here
        return cls.__id

Test.__id #wrong
Test._Test__id #right
Test.get() #right

from this example, I have two questions.

1`since Test is the same with cls, why I can't access __id by Test.__id, but I can access it by cls.__id

2` what happen in python when execute 'object.a' (acecess the 'a' attribute of Object)

bin381
  • 342
  • 1
  • 4
  • 14

0 Answers0