Skip to content

Instantly share code, notes, and snippets.

@nclv
Created January 23, 2020 21:04
Show Gist options
  • Save nclv/f035ee876532f0783ba9b701e4e4d938 to your computer and use it in GitHub Desktop.
Save nclv/f035ee876532f0783ba9b701e4e4d938 to your computer and use it in GitHub Desktop.
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