Skip to content
Advertisement

What’s the difference between accessing a class’ attribute via the class’ name vs classmethod?

I was asked during an interview what is the difference between the following two ways to access a class’ attribute:

JavaScript

PS: I know the difference between classmethod and staticmethod.

Advertisement

Answer

Using cls would also work with inheritance,

JavaScript

Though there might be more differences

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement