mirror of
https://github.com/wassname/simpeg.git
synced 2026-07-08 09:51:24 +08:00
Raise an exception if name is not provided when hooking a lambda function.
This commit is contained in:
@@ -23,7 +23,10 @@ def hook(obj, method, name=None, overwrite=False, silent=False):
|
||||
|
||||
If name is None, the name of the method is used.
|
||||
"""
|
||||
if name is None: name = method.__name__
|
||||
if name is None:
|
||||
name = method.__name__
|
||||
if name == '<lambda>':
|
||||
raise Exception('Must provide name to hook lambda functions.')
|
||||
if not hasattr(obj,name) or overwrite:
|
||||
setattr(obj, name, types.MethodType( method, obj ))
|
||||
if getattr(obj,'debug',False):
|
||||
|
||||
Reference in New Issue
Block a user