Listing 10 - Page 0: No Title

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 10\10.1465 - No Title.py
# Description: No Title
##############################################################################

class Telephone :
    def __init__(self, number, type=None):
        self.number = number
        self.type = type
    def __str__(self):
        type = self.type or ""
        return f"{self.number} {type}"
    def __eq__(self, other):
        return self.number == other.number and (
               (self.type == other.type) or (
                self.type is None or other.type is None))
    @property
    def number(self):
        return self.__number
    @number.setter
    def number(self, value):
        if value is None or not value.strip():
            raise ValueError("Number cannot be None or blank")
        self.__number = value
Click here to download the file