assert type([]) == type(())

Tim Chase python.list at tim.thechases.com
Sat Jan 2 17:45:16 CET 2010


> However the following is not an error
> 
> for x in []:
>     assert type(x) == type(())
> 
> I expected an AssertionError but get no errors at all.
> Any explaination?


   number_of_times_through_the_loop = 0
   for x in []:
     assert type(x) == type(())
     number_of_times_through_the_loop += 1

   print number_of_times_through_the_loop

make sense? :)

-tkc






More information about the Python-list mailing list