rosuav at gmail.com
Wed Mar 5 13:45:25 CET 2014
On Wed, Mar 5, 2014 at 11:35 PM, Mark Lawrence <breamoreboy at yahoo.co.uk> wrote:
>> if the_list is None:
> Really great thinking, test the name the_list, which strangely enough tells
> me that this beast is a list, in the same way that THIS_IS_A_CONSTANT is a
> constant, to see if it's None. Congratulations, you've been promoted to
> captain of my dream team.
Uhh... why? What's wrong with something either being a list or being
None to indicate no list?
def foo(x, target_list=None):
if target_list is not None: target_list = default_targets
You can't use "if target_list:" here, because that would also catch an
empty list. You need some kind of sentinel that says "there isn't a
More information about the Python-list