Created
January 23, 2020 21:04
-
-
Save nclv/f035ee876532f0783ba9b701e4e4d938 to your computer and use it in GitHub Desktop.
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
import functools | |
def while_true(func): | |
""" Décore la fonction d'une boucle while True pour les inputs. | |
On peut tester ses propres exceptions. | |
""" | |
@functools.wraps(func) | |
def wrapper(*args, **kwargs): | |
while True: | |
try: | |
res = func(*args, **kwargs) | |
if res == 'verif': | |
continue | |
break | |
except ValueError as VE: | |
print(VE) | |
return res | |
return wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment