I am using a builtin SNMP library to get some data off a server. Now when I get it back it shows up in a list as
.>>> [ObjectName(1.2.6.1.4.1.111.1.4.1.7), Integer(21)]
When I print out x[0] (pretend x is that response^) I see 1.2.6.1.4.1.111.1.4.1.7 and 21 for x[1] but when I do type(x[0]) I get <type 'instance'>.
Now my question is that is there a way to find the type of x[1] and convert it to that? (x[0] will always be a string but x[1] can be integer, string or float etc.
Is there a way to read that “Integer” (in this case)?
Thanks
Edit:
I dont think I described it clearly. I really done care about x[0] at all, I want to convert the x[1] to what it is without modifying anything from the class that I am getting the SNMP data from. In this example its an int but it can be a float or a string. I am looking for a way to determine what the type of that instance is and then convert it to that
You get
<type 'instance'>because the library is using old-style classes. You can get at the class name by usingx.__class__. In your examplex[0].__class__.__name__would beObjectName.