Skip to content
CodeKruPro

A method that reads a name defined in the class body

Predict the outputHardPython only
main.py
x = "global"

class Config:
    x = "class"

    def show(self):
        return x

    def show_attr(self):
        return self.x

c = Config()
print(c.show())
print(c.show_attr())
print(Config.x)

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in