I love assert

Chris Angelico rosuav at gmail.com
Thu Nov 13 00:27:53 CET 2014


On Thu, Nov 13, 2014 at 10:23 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
> However, the programmer could have played this frustration out already
> in his head and written:
>
>      assert len(choices) > 0
>      count = next_size / len(choices)

assert choices
count = next_size / len(choices)

Or even just:

count = next_size / len(choices) # choices won't be empty

ChrisA



More information about the Python-list mailing list