Access static variable from static method

Use @classmethod instead of @staticmethod. Found it just after writing the question.

In many languages (C++, Java etc.) "static" and "class" methods are synonyms. Not in Python.


def get_msg():
    return "hello " + Messenger.name

You can't use self.name because self is not defined. self is a naming convention for the first parameter of non-static or non-classmethod methods. It points to the object on which you called the method. Since your method is static, you don't need an object to call it on.