How to access class-scope variables without self?

Python doesn't let class variables fall into scope this way, there are two ways to do this, the first is to use a class method:

@classmethod
def foo(cls):
    print(cls.foo_string)

Which I would argue is the best solution.

The second is to access by name:

@staticmethod
def foo():
    print(Foo.foo_string)

Do note that in general, using a class as a namespace isn't the best way to do it, simply use a module with top-level functions instead, as this acts more as you want to.

The reason for the lack of scoping like this is mainly due to Python's dynamic nature, how would it work when you insert a function into the class? It would have to have special behaviour added to it conditionally, which would be extremely awkward to implement and potentially fragile. It also helps keep things explicit rather than implicit - it's clear what is a class variable as opposed to a local variable.