2012-01-23 2 views
-3

파이썬 및 django .i이 새로운 장고 등록 모듈의 코드를 이해하고 싶습니다. 코드에서 값을 디버깅하고 싶습니다. 그래서 내가어떻게 변수 값을 디버깅 할 수 있습니다 __init__.py

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() 
+1

먼저 파이썬을 알아보세요. 웹에는 수많은 자원이 있습니다. – seler

답변

1

들여 쓰기는 파이썬에서 많은 문제와 오류에서 알 수 있듯이, 당신은 들여 쓰기 문제가 있습니다. 새 코드 블록을 만들 때 들여 쓰기를 수행해야합니다 (예 : if, for 또는 while 문 이후).

그냥 module 전에 공백을 제거 :

i = path.rfind('.') 
module, attr = path[:i], path[i+1:] 

print i 
#or 
import pdb; pdb.set_trace() 
+0

시도했지만 여전히 오류가 있습니까? 문제의 코드를 업데이트하여 그 내용을 인쇄하십시오. , 내가 어디에서 서버를 실행 퍼티에서 인쇄 진술은 올 것인가? – XMen

+0

변경됨 내 메모장 ++ 설정이 탭으로 바뀝니다. 공백으로 교체하십시오. 감사합니다. – XMen

관련 문제