Menu

Optional field

Patricia
2010-10-08
2013-05-20
  • Patricia

    Patricia - 2010-10-08

    I couldn't find a way to make an optional field with pyasn1.
    For example, I have a field "name" that is optional:

    Person ::= SEQUENCE {
    name    OCTET STRING OPTIONAL
    }

    How can I make it in pyasn1?

    class Person(univ.Sequence):
        componentType = namedtype.NamedTypes(
                namedtype.NamedType('name', univ.OctetString()),
           )

    Any help would be really appreciated.

     
  • Othmane

    Othmane - 2010-10-08

    Hi,

    try

    class Person(univ.Sequence):
        componentType = namedtype.NamedTypes(
                namedtype.OptionalNamedType('name', univ.OctetString()),
           )

     
  • Patricia

    Patricia - 2010-10-08

    Thank you very much!
    It worked =)

     

Log in to post a comment.