static_var n'a pas vraiment de raison d'être dans affichage.py
This commit is contained in:
parent
394531a537
commit
3f1b7401ca
2 changed files with 23 additions and 21 deletions
20
cranslib/decorators.py
Normal file
20
cranslib/decorators.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import functools
|
||||
|
||||
def static_var(*couples):
|
||||
"""Decorator setting static variable
|
||||
to a function.
|
||||
|
||||
"""
|
||||
# Using setattr magic, we set static
|
||||
# variable on function. This avoid
|
||||
# computing stuff again.
|
||||
def decorate(fun):
|
||||
functools.wraps(fun)
|
||||
for (name, val) in couples:
|
||||
setattr(fun, name, val)
|
||||
return fun
|
||||
return decorate
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue