print 'in script2...'
from scripttools import dumpall
cinterface.setMessage('Pending')              # use module: set C text area 

dumpall(cvar)
for s in cvar.cc, cvar.dd:                    # print C's cc and dd
    print s
for c in cvar.cc:                             # iterate over C string
    print c
    cvar.dd = cvar.dd + c                     # concat to C string
dumpall(cvar)

    cvar.xx                                  # getattr error
except:
    print sys.exc_type, sys.exc_value

try:
    cvar.xx = 'bad'                          # setattr error
except:
    print sys.exc_type, sys.exc_value

try:
    cvar.aa = 'bad'                          # type error
except:
    print sys.exc_type, sys.exc_value

try:
    cinterface.xx                            # module error
except:
    print sys.exc_type, sys.exc_value

print 'dir(cvar)   =', dir(cvar)             # just stats: rest via getattr
print 'cvar.stats  =', cvar.stats()          # attribute gets, sets
print 'sys.modules =', sys.modules.keys()    # runpy, sripttools, cinterface

import cinterface                            # this would fail if CnameMapTable
mycvar = cinterface.Cvar()                   # can't be linked to cinterface.so
print 'cvar.aa, the hard way:', mycvar.aa    # from enclosing C layer or other

cinterface.setMessage("Finished.\n")
dumpall(cvar)

#####################################################
# C loads this file of Python code and runs it as
# a single code string, after setting globals 'cvar'
# (a type object) and 'cinterface' (a module object)
#####################################################

print 'in script1...'
from scripttools import dumpall  # import a Python module

dumpall(cvar)  # fetch/print exported C vars
print 'cvar.stats =', cvar.stats()  # #gets,#sets (includes .stats)
cvar.aa = cvar.bb  # fetch C's bb, assign to C's aa
cvar.bb = cvar.bb**2  # it's Python after fetch
cvar.cc, cvar.dd = 'spam', 'eggs'
cvar.ee = float(len(cvar.cc) + len(cvar.dd))  # len('spam') + len('eggs') = 8
print 'cvar.stats =', cvar.stats()
dumpall(cvar)