Skip to content
Snippets Groups Projects
Commit c3460c30 authored by Nicolas Mansard's avatar Nicolas Mansard Committed by Nicolas Mansard
Browse files

Added the decorator optionalparentheses.

parent 89a6a07f
No related branches found
No related tags found
No related merge requests found
...@@ -84,3 +84,13 @@ setattr(Entity,'__repr__',Entity.__str__) ...@@ -84,3 +84,13 @@ setattr(Entity,'__repr__',Entity.__str__)
import sys import sys
sys.ps1 = '% ' sys.ps1 = '% '
# Enable function that can be call without()def optionalparentheses(f):
def optionalparentheses(f):
class decoclass:
def __repr__(self):
res=f()
if isinstance(res,str): return res
else: return ''
def __call__(self,*arg):
return f(*arg)
return decoclass()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment