|
LINK="#0000bb" VLINK="#551a8b" ALINK="#ff0000">
Example of Sequence usage
>>> from pysnmp.asn1 import univ
>>> class MySequence(univ.Sequence):
... fixedNames = [ 'myint', 'mystr' ]
... fixedComponents = [ univ.Integer, univ.OctetString ]
...
>>> s = MySequence()
>>> s
MySequence('myint'=Integer(0L), 'mystr'=OctetString(''))
>>> s['myint'].set(10)
>>> s['mystr'].set('foobar')
>>> s.items()
[('myint', Integer(10)), ('mystr', OctetString('foobar'))]
>>> len(s)
2
>>> s['myint'] = univ.Boolean()
Traceback (innermost last):
...
pysnmp.asn1.error.BadArgumentError: Component type mismatch: Integer vs Boolean
>>>
ilya@glas.net
|