1
$\begingroup$

I try to make a tuple of the classes loaded from a module

I get this error:

TypeError: can only concatenate tuple (not "type") to tuple

Here is the function causing the issue

def addModuleClasses(classes,name,prefix):
    for name, obj in inspect.getmembers(sys.modules[name]):
        if inspect.isclass(obj) and name.startswith(prefix):
            classes=classes+(obj.__class__) <------------------ error
    return classes

The idea behind this is to call that function per imported module

import bpy
import somemodulename

classes=()
classes = addModuleClasses(classes,"somemodulename","prefix")
register,unregister = bpy.utils.register_classes_factory(classes)

which would allow me to import modules without caring about new classes.

Thanks for your help

$\endgroup$
2
  • 2
    $\begingroup$ (x,) is a one element tuple, (x) is just x. $\endgroup$
    – scurest
    Commented May 12, 2022 at 18:25
  • $\begingroup$ still it gives me error : RuntimeError: register_class(...):, missing bl_rna attribute from 'type' instance (may not be registered) $\endgroup$
    – Phil
    Commented May 12, 2022 at 23:04

0

You must log in to answer this question.

Browse other questions tagged .