@property デコレータを使う
ディスクリプタを実装したクラスの操作に慣れたところで、今度は @property デコレータを使って自分で作ってみましょう。頑張ってください!
この演習はコースの一部です
Python 中級オブジェクト指向プログラミング
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
class BankAccount:
def __init__(self, email):
self.email = email
# Define and decorate a method to begin the process of
# creating a descriptor for the email attribute
@____
def ____(self):
return f"Email for this account is: {____.____}"