The print_value method is provided in with the following signature:
def print_value(self, elem_name="<name>", indent=0):
The elem_name argument is used to specify the top-level variable name of the item being printed. In the generated code this is defaulted to the name of the item in the ASN.1, but in your call to print_value() you can specify a different value.
The indent argument is used to specify the indentation level for printing nested types. The generated code sets 0 as the default value for this argument, but you can specify a different value. Each indentation level results in an indentation of 3 spaces in the printed output. So for example specifying 1 for this argument means the outermost lines will be indented by 3 spaces, the next level 6 spaces, and so on. Allowing the value to default to 0 means the outermost lines will not be indented, the next level will be indented by 3 spaces, and so on.
For example, the simplest call to print the personnelRecord from the previous examples would be as follows:
personnelRecord.print_value ();
The output would be formatted as follows:
PersonnelRecord {
name {
givenName = 'John'
initial = 'P'
familyName = 'Smith'
}
number = 51
title = 'Director'
dateOfHire = '19710917'
nameOfSpouse {
givenName = 'Mary'
initial = 'T'
familyName = 'Smith'
}
children[0] {
name {
givenName = 'Ralph'
initial = 'T'
familyName = 'Smith'
}
dateOfBirth = '19571111'
}
children[1] {
name {
givenName = 'Susan'
initial = 'B'
familyName = 'Jones'
}
dateOfBirth = '19590717'
}
}