0
여기 내 코드 승/클래스에서 다르게 동작 이클립스/pydev 아래에 클래스를 넣으면 enterParam과 checkStr이 정의되지 않았다는 불평을하기 시작합니다. 내가 도대체 뭘 잘못하고있는 겁니까?함수 호출 대 python3에서 클래스 O를
class ParamInput:
#Check if the value has only allowed characters
def checkStr(self, value):
return (set(value) <= allowed)
#Enter parameter
def enterParam (self, msg)
value=input(msg)
if len(value) == 0:
print("Cannot be empty, try again")
enterParam(msg) #<==== not defined
if not checkStr(value): #<====not defined
print("incorrect symbols detected, try again")
enterParam(msg) #<====not defined
return value
- 고마워요!;) 자바에서 오는을, 나는 약 잊었다 그. –
이 동작에 대한 설명은 http://stackoverflow.com/a/5467009/821378을 참조하십시오. 또한 셀프에 액세스 할 필요가 없다면 일반적으로 모듈 수준에서 함수를 유지하는 것이 가장 좋습니다. 메소드를 만들 필요가 없습니다. –