작성
·
150
0
안녕하세요. 클래스 메소드 심화 부분에 있는 Car 클래스 다루는 곳에서 None이 마지막에 출력되네요
class Car():
"""
Car Calss
Author : You Young Jae
Data: 2021.06.06
"""
# 클래스 변수
car_count = 0
def __init__(self, company, details):
self._company = company
self._details = details
Car.car_count += 1
def __str__(self):
return 'str: {} - {}'.format(self._company, self._details)
def __repr__(self):
return 'repr: {} - {}'.format(self._company, self._details)
def detail_info(self):
print('Current Id: {}'.format(id(self)))
print('Car Detail Info: {} {}'.format(self._company, self._details.get('price')))
def __del__(self):
Car.car_count -= 1
car1 = Car('Ferrari', {'color' : 'White', 'horsepower': 400, 'price': 8000})
car2 = Car('Bmw', {'color' : 'Black', 'horsepower': 270, 'price': 5000})
car3 = Car('Audi', {'color' : 'Silver', 'horsepower': 300, 'price': 6000})
# ID 확인
print(id(car1))
print(id(car2))
print(id(car3))
print(car1._company == car2._company)
print(car1 is car2)
print(dir(car1))
print(dir(car2))
print()
print()
print(car1.__dict__)
print(car2.__dict__)
print()
print()
print(Car.__doc__)
print()
print()
car1.detail_info()
car2.detail_info()
print()
print()
print(Car.detail_info(car1))
print(Car.detail_info(car2))