[Tutor] help about to how many times the function called

Steven D'Aprano steve at pearwood.info
Fri Jan 4 10:25:08 CET 2013


On 04/01/13 20:17, lei yang wrote:
> Hi experts
>
> I have a function will print PASS status
>
>
>
> def print_pass(t_elapsed):
>      """
>      Print PASS to stdout with PASS (green) color.
>      """
>      print_stdout(bcolors.PASS + "PASS" + bcolors.ENDC + " (%.2f s)" % t_elapsed)
>
> I want to calculate the pass number, so I want to get " how many times
> this function called"
>
> any help?


how_many_times = 0

def print_pass(t_elapsed):
     """
     Print PASS to stdout with PASS (green) color.
     """
     global how_many_times
     how_many_times += 1
     print_stdout(bcolors.PASS + "PASS" + bcolors.ENDC + " (%.2f s)" % t_elapsed)




-- 
Steven


More information about the Tutor mailing list