Search zipcode by exact 5 digits zipcode. No zero padding is needed. :param zipcode: int or str, the zipcode will be automatically zero padding to 5 digits. :param zipcode_type: str or :class`~uszipcode.model.ZipcodeType` attribute. by default, it re
(self,
zipcode,
zipcode_type=None,
zero_padding=True)
| 565 | return q.all() |
| 566 | |
| 567 | def by_zipcode(self, |
| 568 | zipcode, |
| 569 | zipcode_type=None, |
| 570 | zero_padding=True): |
| 571 | """ |
| 572 | Search zipcode by exact 5 digits zipcode. No zero padding is needed. |
| 573 | |
| 574 | :param zipcode: int or str, the zipcode will be automatically |
| 575 | zero padding to 5 digits. |
| 576 | :param zipcode_type: str or :class`~uszipcode.model.ZipcodeType` attribute. |
| 577 | by default, it returns any zipcode type. |
| 578 | :param zero_padding: bool, toggle on and off automatic zero padding. |
| 579 | """ |
| 580 | if zero_padding: |
| 581 | zipcode = str(zipcode).zfill(5) |
| 582 | else: # pragma: no cover |
| 583 | zipcode = str(zipcode) |
| 584 | |
| 585 | res = self.query( |
| 586 | zipcode=zipcode, |
| 587 | sort_by=None, |
| 588 | returns=1, |
| 589 | zipcode_type=zipcode_type, |
| 590 | ) |
| 591 | if len(res): |
| 592 | return res[0] |
| 593 | else: |
| 594 | return self.zip_klass() |
| 595 | |
| 596 | def by_prefix(self, |
| 597 | prefix, |