""" Ex. 7.10 from "A primer on..." Implement a class so that the code lines given in the exercise work and give the desired output. From the use cases we see that the code needs the following: 1. Either no constructor or a constructor that takes no arguments 2. A __call__ method which takes a single argument 3. A __str__ special method The exercise could have been solved differently, for instance with no attributes and no constructor, but this is one possible solution. """ class Hello: def __init__(self): self.greeting = "Hello, " def __call__(self, arg): return self.greeting + arg + '!' def __str__(self): return self.greeting + "World!" a = Hello() print(a("students")) #output: Hello, students! print(a) #output: Hello, World!