Я пытаюсь увидеть, где будет скрываться синтаксическая ошибка Python. Как Django, так и pylint утверждают синтаксическую ошибку в custom.py:41. Строки 41-42 читаем:Где моя синтаксическая ошибка?
(reading_threshold =
int(request.POST['reading_threshold']))
Я не вижу ничего, что я могу заметить, как неправильно в этом заявлении или синтаксисе в custom.py.
Какая у меня ошибка?
Слегка облагороженная версия файла гласит:
from django.http import HttpResponse
def threshold_check(user, item, text = None):
if user.issuperuser():
if text == None:
return True
else:
return text
else:
if (user.status >= item.threshold and user.reading_threshold <=
item.threshold):
if text == None:
return True
else:
return text
else:
if text == None:
return False
else:
return ''
def threshold_check_required(item):
def outer_wrap(view_function):
def inner_wrap(request, *arguments, **keywords):
if request.user.issuperuser():
return view_function(request, *arguments, **keywords)
else:
if (request.user.status >= item.threshold and
request.user.reading_threshold <= item.threshold):
return view_function(request, *arguments, **keywords)
else:
return HttpResponse('')
return inner_wrap
return outer_wrap
def threshold_controls(request):
user = request.user
if user and user.status != None:
if request.method == 'POST':
try:
(reading_threshold =
int(request.POST['reading_threshold']))
except ValueError:
reading_threshold = user.reading_threshold
try:
(writing_threshold =
int(request.POST['writing_threshold']))
except ValueError:
writing_threshold = user.writing_threshold
writing_threshold = min(user.status, writing_threshold)
reading_threshold = min(writing_threshold,
reading_threshold)
user.reading_threshold = reading_threshhold
user.writing_threshold = writing_threshold
user.save()
return render_to_response('threshold_controls.html',
{
'user': user
})
else:
return render_to_response('threshold_controls_blank.html')
Это аргумент функции? Если не то, что это даже означает? У меня есть ощущение, что для этого нужно больше контекста. –
Возможно, вы имели в виду расширение на две строки? В этом случае добавление parenthasis не поможет, но добавление '\\' в конце строки, чтобы указать, что оно продолжается на следующей строке, будет работать. –
Вы можете разложить его по двум линиям, перемещая открытый палец на * конец * первой строки, после знака =. –