생성자에서 Bike의 인스턴스를 반환해야합니다. 나는, 나는 다음과 같은 오류 위의받을 수 있나요 때생성자에서 클래스 인스턴스 반환
class Bike(object):
def __init__(self,color):
self.bikeColor = color
return self #It should return an instance of the class; is this not right?
myBike = Bike("blue")
는 : 예를 들어이 경우
TypeError: __init__() should return None, not 'Bike'
를 그 만 return None
로 가정하면 어떻게 인스턴스를 반환 할 수 있을까?
아니요, 오류가 나타나면 e를 입력하십시오. – JBernardo
초기화 프로그램입니다. 인스턴스를 반환하려면'__new__'을 시도하십시오. – JBernardo