Q:

python/django - [u''] is not empty

Sorry for silly question first of all.
I am getting a list of user inputs of same type like: 
<input name="booknames" type="text">
<input name="booknames" type="text">
<input name="booknames" type="text">

and in viws: 
if request.POST.getlist('booknames'):
    print 'yes'
else:
    print 'no'

even if no user inputs there, i am getting yes. I printed the list, I get [u''] which is empty. 
am I missing something? 

A:

[u''] is not empty. It's a list with one element, the empty string. Lists are considered True in a boolean context if they have any elements, which that list does. If you want to see whether your list has any non-empty elements, try any(request.POST.getlist('booknames')).

