poplar_isocc

This package implements a method to validate a string against a reference list of country codes.

poplar_isocc.is_valid_iso_cc(code)[source]

Is code a valid ISO-3166 code?

Parameters:code (str) – country code to validate
Return type:(bool, list)
Returns:(True, []) if code is valid, (False, [matches]) otherwise

New in version 0.3.0: Fuzzy matches returned on no match.

from poplar_isocc import is_valid_iso_cc

# Check if a code is valid.
is_valid_iso_cc("CA")
    # returns True
is_valid_iso_cc("ZZ")
    # returns False