2012-01-23 73 views
-3

新的調試變量的值到Python和Django的。我想了解Django的註冊模塊爲了這個,我想調試代碼值的代碼。 所以我卡在這裏,我如何能在__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 = 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

第一學習Python。網絡上有無數的資源。 – seler

回答

1

凹痕不要緊很多蟒蛇,併爲錯誤提示,你有一個缺口問題。後ifforwhile語句您應該創建新的代碼塊,例如,當只縮進。

module之前,只需刪除空格:

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

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

嘗試過,但仍然錯誤?更新了有問題的代碼,請給出打印聲明。 ,打印語句將來自我運行服務器的地方的膩子? – XMen

+0

工作改變了我的記事本++設置爲標籤替換空間,謝謝 – XMen