|
18 | 18 |
|
19 | 19 | .. autodata:: localflavor.us.us_states.CONTIGUOUS_STATES |
20 | 20 |
|
21 | | -.. autodata:: localflavor.us.us_states.US_STATES |
| 21 | +.. autodata:: localflavor.us.us_states.NON_CONTIGUOUS_STATES |
22 | 22 |
|
23 | 23 | .. autodata:: localflavor.us.us_states.US_TERRITORIES |
24 | 24 |
|
|
28 | 28 |
|
29 | 29 | .. autodata:: localflavor.us.us_states.OBSOLETE_STATES |
30 | 30 |
|
31 | | -.. autodata:: localflavor.us.us_states.STATE_CHOICES |
| 31 | +.. data:: localflavor.us.us_states.US_STATES |
| 32 | + :annotation: = CONTIGUOUS_STATES + NON_CONTIGUOUS_STATES |
32 | 33 |
|
33 | | -.. autodata:: localflavor.us.us_states.USPS_CHOICES |
| 34 | + All US states. |
| 35 | + |
| 36 | + This tuple is lazily generated and may not work as expected in all cases due |
| 37 | + to tuple optimizations in the Python interpreter which do not account for |
| 38 | + lazily generated tuples. For example:: |
| 39 | + |
| 40 | + US_STATES + ('XX', _('Select a State')) |
| 41 | + |
| 42 | + should work as expected, but:: |
| 43 | + |
| 44 | + ('XX', _('Select a State')) + US_STATES |
| 45 | + |
| 46 | + may throw: |
| 47 | + |
| 48 | + ``TypeError: can only concatenate tuple (not "proxy") to tuple`` |
| 49 | + |
| 50 | + due to a Python optimization that causes the concatenation to occur before |
| 51 | + US_STATES has been lazily generated. To work around these issues, you |
| 52 | + can use a slice index (``[:]``) to force the generation of US_STATES |
| 53 | + before any other operations are processed by the Python interpreter:: |
| 54 | + |
| 55 | + ('XX', _('Select a State')) + US_STATES[:] |
| 56 | + |
| 57 | +.. data:: localflavor.us.us_states.STATE_CHOICES |
| 58 | + :annotation: = CONTIGUOUS_STATES + NON_CONTIGUOUS_STATES + US_TERRITORIES + ARMED_FORCES_STATES |
| 59 | + |
| 60 | + All US states and territories plus DC and military mail. |
| 61 | + |
| 62 | + This tuple is lazily generated and may not work as expected in all cases due |
| 63 | + to tuple optimizations in the Python interpreter which do not account for |
| 64 | + lazily generated tuples. For example:: |
| 65 | + |
| 66 | + STATE_CHOICES + ('XX', _('Select a State')) |
| 67 | + |
| 68 | + should work as expected, but:: |
| 69 | + |
| 70 | + ('XX', _('Select a State')) + STATE_CHOICES |
| 71 | + |
| 72 | + may throw: |
| 73 | + |
| 74 | + ``TypeError: can only concatenate tuple (not "proxy") to tuple`` |
| 75 | + |
| 76 | + due to a Python optimization that causes the concatenation to occur before |
| 77 | + STATE_CHOICES has been lazily generated. To work around these issues, you |
| 78 | + can use a slice index (``[:]``) to force the generation of STATE_CHOICES |
| 79 | + before any other operations are processed by the Python interpreter:: |
| 80 | + |
| 81 | + ('XX', _('Select a State')) + STATE_CHOICES[:] |
| 82 | + |
| 83 | +.. data:: localflavor.us.us_states.USPS_CHOICES |
| 84 | + :annotation: = CONTIGUOUS_STATES + NON_CONTIGUOUS_STATES + US_TERRITORIES + ARMED_FORCES_STATES + COFA_STATES |
| 85 | + |
| 86 | + All US Postal Service locations. |
| 87 | + |
| 88 | + This tuple is lazily generated and may not work as expected in all cases due |
| 89 | + to tuple optimizations in the Python interpreter which do not account for |
| 90 | + lazily generated tuples. For example:: |
| 91 | + |
| 92 | + USPS_CHOICES + ('XX', _('Select a State')) |
| 93 | + |
| 94 | + should work as expected, but:: |
| 95 | + |
| 96 | + ('XX', _('Select a State')) + USPS_CHOICES |
| 97 | + |
| 98 | + may throw: |
| 99 | + |
| 100 | + ``TypeError: can only concatenate tuple (not "proxy") to tuple`` |
| 101 | + |
| 102 | + due to a Python optimization that causes the concatenation to occur before |
| 103 | + USPS_CHOICES has been lazily generated. To work around these issues, you |
| 104 | + can use a slice index (``[:]``) to force the generation of USPS_CHOICES |
| 105 | + before any other operations are processed by the Python interpreter:: |
| 106 | + |
| 107 | + ('XX', _('Select a State')) + USPS_CHOICES[:] |
34 | 108 |
|
35 | 109 | .. autodata:: localflavor.us.us_states.STATES_NORMALIZED |
0 commit comments