Sunday, August 15, 2010

reason why there is no "if Empty" in python

Programmer Question

the zen of python says "Explicit is better than implicit."



i find that an is Empty to check whether some sequence is empty is so much more explicit than implicit booleanness



if some_sequence is Empty:
fill_sequence(some_sequence)


compare with



if not some_sequence:
fill_sequence(some_sequence)


this gets even more confusing with some unfavorably choosen variable names



if saved:
mess_up()


compare with



if saved is not Empty:
mess_up()


see also: http://stackoverflow.com/questions/53513/python-what-is-the-best-way-to-check-if-a-list-is-empty i find it ironic that the most voted answer claims that implicit is pythonic.



so is there a higher reason why there is no is Empty in python?



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails