How to check a variable whether it is a class?

I created two different mini programs (simple and complex). The simple one does work well but the other not. Why not?

Simple program:
#------- File “Simple.py” ---------------------------------------------------
class ClassTest:
def init(self):
self.instanceTest = ‘abc’

varClassTest = ClassTest()
print(varClassTest.instanceTest)
print(isinstance(varClassTest, ClassTest))
#----------------------------------------------------------

Complex program has two files:
#------- File “Classes/ClassTest.py” ------------------------------------
class ClassTest:
def init(self):
self.instanceTest = ‘abc’
#------- File “Complex.py” ------------- ------------------------------------
import importlib
import inspect
import os
if os.path.isfile(‘Classes/ClassTest.py’):
workarea = importlib.import_module(‘Classes.ClassTest’)
print(workarea)
varClassTest = workarea.ClassTest()
print(varClassTest.instanceTest)
print(isinstance(varClassTest, ClassTest))

The last command gives the NameError:

name ‘ClassTest’ is not defined

#----------------------------------------------------------

I am looking for the solution of my complex program.

Try changing the last line to

print(isinstance(varClassTest, workarea.ClassTest))

Is your “complex” program trying to learn how to use importlib?

I ask because importlib is an advanced area of Python that beginners
shouldn’t need to touch.