In Django documentation django.conf.urls | Django documentation | Django
There's such codes:
class RegexURLPattern(LocaleRegexProvider):
...
def lookup_str(self)
callback = self.callback
# Python 3.5 collapses nested partials, so can change "while" to "if"
# when it's the minimum supported version.
while isinstance(callback, functools.partial):
callback = callback.func
...
The code is to callback the argument of funtion 'view' and execute it.
Why while is better than if excluding 'Python 3.5'?
There is only one callback argument passed in from django.conf.urls.url,which seen in:
def url(regex, view, kwargs=None, name=None):
elif callable(view):
return RegexURLPattern(regex, view, kwargs, name)
It seems if is more readable than while.