[Tutor] help about to how many times the function called
bob gailer
bgailer at gmail.com
Fri Jan 4 18:41:33 CET 2013
On 1/4/2013 4:25 AM, Steven D'Aprano wrote:
> 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"
It is unclear to me what you want to do with the pass number or what
PASS means or where bcolors comes from.
If you don't need to refer to the pass number outside the function
another way (better IMHO):
def print_pass(t_elapsed, how_many_times=0):
"""
Print PASS to stdout with PASS (green) color.
"""
how_many_times += 1
print_stdout(bcolors.PASS + "PASS" + bcolors.ENDC + " (%.2f s)" %
t_elapsed)
I for one would appreciate a more complete explanation.
--
Bob Gailer
919-636-4239
Chapel Hill NC
More information about the Tutor
mailing list