Skip to main content

Practice ยท 2 of 3

Delegating proxy with __getattr__

Implement class Proxy that wraps any object passed to __init__: - attribute reads that fail on the Proxy itself must be **delegated** to the wrapped object via __getattr__ - Proxy.real(obj) must return the wrapped object - calls on delegated methods must work (e.g. Proxy('hi').upper() returns 'HI') - reads of attributes the wrapper defines directly must NOT be delegated (define sniff on Proxy returning 'proxy')

Difficulty: advanced

Back to lesson: Practice: Attribute Lookup Practice