This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#static vars are not directly posible in python | |
# for eg to count no. of times a func is called | |
def myFunc(): | |
myFunc.count =getattr(myFunc,"count",0) + 1 | |
print myFunc.count | |
return | |
if __name__ == "__main__": | |
while getattr(myFunc,"count",0) < 5: | |
myFunc() |
No comments:
Post a Comment