Apr-16-2020, 11:23 PM
(Apr-16-2020, 11:40 AM)buran Wrote:o_method = getattr (o_class, v_metget) AttributeError: type object 'Runcode' has no attribute 'other'In your code you don't try to check for "other". Please, post full traceback and the actual code that produce the error.
(Apr-16-2020, 10:28 AM)JohnnyCoffee Wrote: So far so good the code above runs perfectly.
There are couple of issues with your code, line 13. It's not possible your code is actually running:
class = getattr (module, conget)1.class
is reserved word, so it's not possible to assign to it (use it as variable name). This will raise SynatxError.
>>> class = 'foo' File "<stdin>", line 1 class = 'foo' ^ SyntaxError: invalid syntax >>>2module
is not defined and will result in NameError.
Here is working example
>>> from importlib import import_module >>> my_module = import_module('csv') >>> my_attr = 'DictReader' >>> test = hasattr(my_module, my_attr) >>> test True >>> my_attr = 'NoExist' >>> test = hasattr(my_module, my_attr) >>> test False >>>
I had just written it wrong, on line 13 but the problem persists. The analysis you mentioned refers to checking the module and class. In my case it is to check if the class method exists and then I face the error ?