Skip to main content

docassemble.us

A docassemble extension that provides helper functions specific to the United States.

The built-in docassemble functions states_list() and state_name() are based on the ISO 3166-2 standard. For the United States, that standard covers the 50 states, the District of Columbia, and the territories, but it does not include everything that can appear in the "state" part of a U.S. mailing address. An interview that asks for an address using states_list() cannot accept the address of a servicemember with an APO, FPO, or DPO address, for example.

This package provides two functions, us_states_list() and us_state_name(), that work like states_list() and state_name() but are based on the two-letter abbreviations used by the U.S. Postal Service. They cover:

  • The 50 states
  • The District of Columbia (DC)
  • The territories: American Samoa (AS), Guam (GU), the Northern Mariana Islands (MP), Puerto Rico (PR), and the Virgin Islands (VI)
  • The "states" used for military and diplomatic mail: Armed Forces Americas (AA), Armed Forces Europe (AE), and Armed Forces Pacific (AP)
  • The freely associated states, which are served by the U.S. Postal Service: the Federated States of Micronesia (FM), the Marshall Islands (MH), and Palau (PW)

The list does not include the United States Minor Outlying Islands (UM), which is part of the ISO standard but is not a USPS abbreviation.

Installation

Install the docassemble.us package on your server using Package Management.

Usage

To make the functions available in an interview, include the module in a modules block:

modules:
  - docassemble.us.functions

us_states_list()

us_states_list() returns a dictionary in which the keys are USPS abbreviations and the values are names, sorted by name. It can be used with code to populate the choices of a multiple-choice field:

question: |
  What is your address?
fields:
  - Address: user.address.address
  - Unit: user.address.unit
    required: False
  - City: user.address.city
  - State: user.address.state
    code: |
      us_states_list()
  - Zip: user.address.zip

The variable user.address.state will be set to the abbreviation (e.g., 'PA'), and the user will see the name (e.g., Pennsylvania).

If you call us_states_list(abbreviate=True), the values of the dictionary will be the abbreviations instead of the names, so that the user chooses from a list of abbreviations.

Unlike states_list(), us_states_list() does not accept a country_code parameter.

us_state_name()

us_state_name() returns the name that goes with a USPS abbreviation.

question: |
  You live in ${ us_state_name(user.address.state) }.
  • us_state_name('PA') returns 'Pennsylvania'.
  • us_state_name('AE') returns 'Armed Forces Europe'.

If the abbreviation is not recognized, the function returns the abbreviation itself.

Unlike state_name(), us_state_name() does not accept a country_code parameter.

Translation

The names returned by both functions are passed through the word() function, so they can be translated into other languages using the docassemble words system.

Metadata

Release files for docassemble.us 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for docassemble.us 0.0.2
File Size Uploaded Provenance Actions
docassemble_us-0.0.2.tar.gz 4.5 kB Without provenance Details for docassemble_us-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for docassemble.us 0.0.2
File Interpreter ABI Platform Actions
docassemble_us-0.0.2-py3-none-any.whl Python 3 none any Details for docassemble_us-0.0.2-py3-none-any.whl

Total release size: 9.3 kB

Release files / docassemble_us-0.0.2.tar.gz

Download URL docassemble_us-0.0.2.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9373d36cbd9728c94dfcc6bb978c8d286d8f181f283aa9fccbeb213de293f016
BLAKE2b-256 checksum
How to use checksums
f274f721dd121ca15311d2e24aa41658303bfcc95903265b9401837155b01f8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.7

Release files / docassemble_us-0.0.2-py3-none-any.whl

Download URL docassemble_us-0.0.2-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ea848c74d9606839505312aca562a0d99dc24ce97b1aeea5615fcdaa15023af
BLAKE2b-256 checksum
How to use checksums
2fc0dc8132bc3c7c995184cb14285d65c58a4888a5913fef18a4c4a3b94df12a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.7

Security for docassemble.us 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page