A proxy, in its most general form, is a class functioning as an interface to something else. The proxy could interface to anything: a network connection, a large object in memory, a file, or some other resource that is expensive or impossible to duplicate. In short, a proxy is a wrapper or agent object that is being called by the client to access the real serving object behind the scenes
Hmm!, what would this look like in terms of code ?
delegation refers to one object relying upon another to provide a specified set of functionalities
This class for example delegates its functionalities to another object:
class CustomInt:
def __init__(self):
self.obj = int()
def __getattr__(self, attr):
return getattr(self.obj, attr) # Delegation
Since it's a class functioning as an interface for something else, can I consider it as a proxy class ?