Courseiva
Design PatternshardMultiple SelectObjective-mapped

PCPP2 Design Patterns Practice Question

Which TWO of the following are valid ways to implement the Proxy pattern in Python?

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Inheriting from the target class and overriding its methods

Proxy can be implemented using class-based wrapping or by overriding magic methods like __getattr__.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Using the 'import' hook in the sys module

    Why it's wrong here

    This is for module loading, not object proxying.

  • Inheriting from the target class and overriding its methods

    Why this is correct

    This is a standard way to implement a virtual or remote proxy.

  • Using a decorator to modify the class structure

    Why it's wrong here

    Decorators modify the function or class, they are not the proxy implementation itself.

  • Changing the global variable scope

    Why it's wrong here

    This is not a pattern implementation technique.

  • Using the __getattr__ magic method to intercept property access

    Why this is correct

    This allows the proxy to act as a transparent wrapper.

About these practice questions

This PCPP2 question is part of Courseiva's 194-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed August 2026 · checked against the official Python Institute exam blueprint

This PCPP2 practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCPP2 exam.