I am confronted to a python problem. I want to use
type() to find out what type of variable I am using. The code looks similar to this one:
class Foo(): array=[ myField(23),myField(42),myField("foo"), myField("bar")] def returnArr(self): for i in self.array: print type(i) if __name__ == "__main__": a=Foo() a.returnArr()
Edit: myField() is a class I defined.
When I ask for the type() I get:
<type 'instance'> Now according to 1 this is due to the fact that I use a class element and ask for
type() on that. Now what I need is:
<type 'int'> for the example:
<type 'str'> for
myField(foo). How could I acheive that?
def __init__(self, name, default, fmt="H"): self.name = name if fmt in "@=<>!": self.fmt = fmt else: self.fmt = "!"+fmt self.default = self.any2i(None,default) self.sz = struct.calcsize(self.fmt) self.owners = 
The code is taken from scapy and I try to adapt it.