__init__.py에서 변수 값을 디버깅하려면 어떻게합니까?
-
12-11-2019 - |
문제
Python 및 Django의 새로운 기능 .I Django-registration 모듈의 코드를 이해하고 싶습니다. 코드의 가치를 디버그하려는 Django 등록 모듈의 코드를 이해하고 싶습니다. 그래서 나는 여기에 갇혀있다
i = path.rfind('.')
module, attr = path[:i], path[i+1:]
print {i}
#or
import pdb; pdb.set_trace()
.
등록 양식이 표시되지 않고 오류가 발생합니다.
IndentationError at /accounts/register/
unexpected indent (__init__.py, line 19)
Request Method: GET
Request URL: http://50.56.78.125:8000/accounts/register/
Django Version: 1.3.1
Exception Type: IndentationError
Exception Value:
unexpected indent (__init__.py, line 19)
.
어떻게 디버깅 할 수 있습니까? i의 값을 어떻게 볼 수 있습니까?
이것은 코드입니다 :
i = path.rfind('.')
module, attr = path[:i], path[i+1:]
try:
mod = import_module(module)
except ImportError, e:
raise ImproperlyConfigured('Error loading registration backend %s: "%s"' % (module, e))
try:
backend_class = getattr(mod, attr)
except AttributeError:
raise ImproperlyConfigured('Module "%s" does not define a registration backend named "%s"' % (module, attr))
return backend_class()
. 해결책
들여 쓰기는 중요합니다. Python에서는 오류가 제안되면 압흔 문제가 있습니다.if
, for
또는 while
문을 예를 들어, 새 코드 블록을 만들 때만 들어야합니다.
module
전에 공백을 제거하십시오.
i = path.rfind('.')
module, attr = path[:i], path[i+1:]
print i
#or
import pdb; pdb.set_trace()
. 제휴하지 않습니다 StackOverflow