带注释的行超过80个字符:
MIDDLEWARE_CLASSES = (
'mydogslow.middleware.MyWatchdogMiddleware',
'gattlib.djangomiddleware.SetRemoteAddrFromXRealIP',
'i18n.middleware.SetLanguageMiddleware',
'whitelabels.middleware.SetWhitelabelMiddleware', # after SetLanguageMiddleware
'myaffiliateprogram.middleware.BlockReferringURLs',
)
我可以分解的最自然的方式是:
MIDDLEWARE_CLASSES = (
'mydogslow.middleware.MyWatchdogMiddleware',
'gattlib.djangomiddleware.SetRemoteAddrFromXRealIP',
'i18n.middleware.SetLanguageMiddleware',
'whitelabels.middleware.'
'SetWhitelabelMiddleware', # after SetLanguageMiddleware
'myaffiliateprogram.middleware.BlockReferringURLs',
)
不幸的是,悬挂缩进违反了PEP8。
提前感谢您向我展示如何打破这一阵容。
答案 0 :(得分:9)
我只想移动评论:
MIDDLEWARE_CLASSES = (
'mydogslow.middleware.MyWatchdogMiddleware',
'gattlib.djangomiddleware.SetRemoteAddrFromXRealIP',
'i18n.middleware.SetLanguageMiddleware',
# This middleware needs to be after SetLanguageMiddleware
'whitelabels.middleware.SetWhitelabelMiddleware',
'myaffiliateprogram.middleware.BlockReferringURLs',
)