Generate a class in Python, implementing the __init__ and __str__ methods to initialize a variable and print its value.
name = "John Doe"
class Person:
    def __init__(self, name):
        self.name = name

    def __str__(self):
        return self.name

p = Person('John Doe')
print(p)