나는 지금 udacity.web_development 과정을 통해 자신을 가르치고 있습니다. 내 코딩은 괜찮아지고 있지만 나는 정기적으로 문제가 아니라 프로세스와 관련이있다.클래스 내부의 함수를 테스트하는 방법 [python, pyCharm]
like this : 클래스 내부에있는 동안이 함수 (passwort_check)를 테스트하는 방법을 모릅니다. 나는 그것을 부를 수 없다. "인쇄 MainHandler.passwort_check ((self 또는 MainHandler),"string ")"을 맨 아래에 입력하면 오류가 발생합니다.
지금이 웹 핸들러는 모두 쓸모가 없습니다. 하지만 나중에 필요 하거든. 모든 것을 주석으로 달기는하지만 내가 필요한 한 가지 기능은 올바른 해결책이 될 수 없습니다. 이 내 오류가
import webapp2
import re
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.write('Hello world!')
def passwort_check(self, passwort_string):
if re.match("^[a-zA-Z0-9_-]{3,20}$", passwort_string):
print passwort_string
else: print "change pw"
print MainHandler.passwort_check(MainHandler,"hallo")
app = webapp2.WSGIApplication([
('/', MainHandler)
], debug=True)
:
이
내 코드입니다TypeError: unbound method passwort_check() must be called with MainHandler instance as first > argument (got type instance instead)
하지만 내 질문은 더 generall입니다 : 너희들 또는 전문가 방법/experianced 코더이 경우
에 codevalidation을해야합니까
당신은 문제의 오류의 세부 사항을 정말를 포함해야한다. 그렇지 않으면 오류의 원인을 추측 할 수 있습니다. –
이 파일의 맨 아래에 넣습니다 : Print MainHandler.passwort_check (MainHandler, "hallo") –
이 나오면 : TypeError : unbound 메서드 passwort_check()는 MainHandler 인스턴스를 첫 번째 인수로 호출해야합니다 (대신 형식 인스턴스가 있습니다) –