Hallöchen!
I have to generate a lot of data types (for ctypes by the way). An
example is
ViUInt32 = u_long
ViPUInt32 = POINTER(ViUInt3 2)
ViAUInt32 = ViPUInt32
Therefore, I defined functions that should make my life easier:
def generate_type_d ublett(visa_typ e, ctypes_type):
visa_type_name = visa_type.__nam e__
exec visa_type_name + "=" + ctypes_type.__n ame__
exec "ViP" + visa_type_name[2:] + "=POINTER(" + visa_type_name + ")"
def generate_type_t riplett(visa_ty pe, ctypes_type):
generate_type_d ublett(visa_typ e, ctypes_type)
visa_type_name = visa_type.__nam e__
exec "ViA" + visa_type_name[2:] + "=" + "ViP" + visa_type_name[2:]
generate_type_t riplett(ViUInt3 2, c_ulong)
However, this doesn't work, probably because the defined type exist
only locally within the function.
What is a better (and working) method for this task?
Thank you!
Tschö,
Torsten.
--
Torsten Bronger, aquisgrana, europa vetus
I have to generate a lot of data types (for ctypes by the way). An
example is
ViUInt32 = u_long
ViPUInt32 = POINTER(ViUInt3 2)
ViAUInt32 = ViPUInt32
Therefore, I defined functions that should make my life easier:
def generate_type_d ublett(visa_typ e, ctypes_type):
visa_type_name = visa_type.__nam e__
exec visa_type_name + "=" + ctypes_type.__n ame__
exec "ViP" + visa_type_name[2:] + "=POINTER(" + visa_type_name + ")"
def generate_type_t riplett(visa_ty pe, ctypes_type):
generate_type_d ublett(visa_typ e, ctypes_type)
visa_type_name = visa_type.__nam e__
exec "ViA" + visa_type_name[2:] + "=" + "ViP" + visa_type_name[2:]
generate_type_t riplett(ViUInt3 2, c_ulong)
However, this doesn't work, probably because the defined type exist
only locally within the function.
What is a better (and working) method for this task?
Thank you!
Tschö,
Torsten.
--
Torsten Bronger, aquisgrana, europa vetus
Comment