stdnum.gb.upn

UPN (English Unique Pupil Number).

The Unique Pupil Number (UPN) is a 13-character code that identifies pupils in English state schools and is designed to aid tracking pupil progress through the school system.

The number consists of a check letter, a 3-digit LA (Local Authority) number for the issuing school, a 4-digit DfE number (School Establishment Number), 2 digits for the issue year and 3 digits for a serial number. Temporary numbers have a 2-digit serial and a letter.

More information:

>>> validate('B801200005001')
'B801200005001'
>>> validate('A801200005001')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> validate('X80120000A001')  # middle part must be numeric
Traceback (most recent call last):
    ...
InvalidFormat: ...
>>> validate('E000200005001')  # LA number must be known
Traceback (most recent call last):
    ...
InvalidComponent: ...
stdnum.gb.upn.calc_check_digit(number)

Calculate the check digit for the number.

stdnum.gb.upn.compact(number)

Convert the number to the minimal representation. This strips the number of any valid separators and removes surrounding whitespace.

stdnum.gb.upn.is_valid(number)

Check if the number is a valid UPN.

stdnum.gb.upn.validate(number)

Check if the number is a valid UPN. This checks length, formatting and check digits.