Using Python decorators to do Hoare Logic

I’m relatively new to Python from a strong Java background. I am trying to create a base class to do Hoare Logic. Class decorators seem to be the way to go with this. I’ve produced the following code, can you comment on this, and suggest an easier way to do this? It seems awfully over complicated to how easy this would be with Java.

def hoare_logic(description, pre_execution=None, post_execution=None):     def decorator_func(function_to_decorate):         def wrapper_func(*args, **kwargs):             # Hoare Pre-Condition             if pre_execution is not None:                 pre_condition = pre_execution(*args, **kwargs)                 print("Hoare Pre-Condition {!r}".format(description, pre_condition))         # Hoare Command         return_value = function_to_decorate(*args, **kwargs)          # Hoare Post-Condition         if post_execution is not None:             post_condition = post_execution(*args, **kwargs)             print("Hoare Post-Condition {!r}".format(description, post_condition))          return return_value      return wrapper_func  return decorator_func   @hoare_logic(description='unit test description') def command(arg):     if arg is not None:         print("command")         if arg == 'foobar':             return False         else:             return True     else:         raise ValueError  # self.assertRaises(ValueError, command, None) command(True) command(False) command('foo') command('bar') command('foobar') 

Once I have a grip with the basic mechanism, I intend to adapt this to provide API contracts & a BDD type scenario functionality framework for unit testing. So please keep this in mind. I’ve deliberately exclude class wrapper & imports to make this simpler to follow, I’m interested in serious scrutiny of the core functionality implementation in python. I’m unsure of my treatment of *args, **kwargs but from what I can see I need this for Python decorators. Is there a better way to handle parametrisation of the wrapped function?

You will need to add these if you want to run this as a class, but it should run as a script. The commented line does work if this a class, but not as a script.

Please be kind, if I’ve broken the question rules, please help me improve the compliance of the question with comments rather than just close it.