Apr-17-2020, 05:54 AM
(Apr-17-2020, 03:01 AM)buran Wrote: I give up. My example is doing exactly what your "working", but actually not working example, for existing and non-existing attribute. You keep saying that the problem persist, but never show actual working code that reproduce the error and full traceback produced.
buran, i'm sorry if I didn't post the corrected code, I describe below:
# Native Module Import: import_module from importlib import import_module v_appget = "website" v_conget = "runcode" t_conget = "Runcode" v_metget = "scree" # method does not exist # Import dynamic module: calling the controller and pattern method: v_pathmod = "apps." + v_appget + ".controllers." + v_conget # Import dynamic module: passing as path the path assigned to the variable: o_module = import_module (v_pathmod) # Retrieve the class: passed as an attribute parameter in the class-controller variable: o_class = getattr (o_module, t_conget) # Retrieve the method: passed as an attribute parameter in the method-controller variable: o_method = getattr (o_class, v_metget, None) # Instantiate the object: related to the class method: o_return = o_method () # Access the controller class and check the existence of the method: o_metexist = hasattr (o_class, v_metget) # Output: print (o_metexist)Thus it generates the error, because the method of the class does not exist according to the variable (v_metget), above. The idea would be to obtain the Boolean False result instead of the error below:
o_return = o_method() TypeError: 'NoneType' object is not callable