1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: package phonenumbers</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>phonenumbers</strong></big></big> (version 8.12.40)</font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="https://github.com/daviddrysdale/python-phonenumbers/blob/dev/python/phonenumbers/__init__.py">phonenumbers/__init__.py</a></font></td></tr></table>
<p><tt>Python phone number parsing and formatting library<br>
<br>
Examples of use:<br>
<br>
>>> import phonenumbers<br>
>>> from phonenumbers.util import prnt # equivalent to Py3k print()<br>
>>> x = phonenumbers.<a href="#-parse">parse</a>("+442083661177", None)<br>
>>> prnt(x)<br>
Country Code: 44 National Number: 2083661177<br>
>>> type(x)<br>
<class 'phonenumbers.phonenumber.<a href="#PhoneNumber">PhoneNumber</a>'><br>
>>> str(phonenumbers.<a href="#-format_number">format_number</a>(x, phonenumbers.<a href="#PhoneNumberFormat">PhoneNumberFormat</a>.NATIONAL))<br>
'020 8366 1177'<br>
>>> str(phonenumbers.<a href="#-format_number">format_number</a>(x, phonenumbers.<a href="#PhoneNumberFormat">PhoneNumberFormat</a>.INTERNATIONAL))<br>
'+44 20 8366 1177'<br>
>>> str(phonenumbers.<a href="#-format_number">format_number</a>(x, phonenumbers.<a href="#PhoneNumberFormat">PhoneNumberFormat</a>.E164))<br>
'+442083661177'<br>
>>> y = phonenumbers.<a href="#-parse">parse</a>("020 8366 1177", "GB")<br>
>>> prnt(y)<br>
Country Code: 44 National Number: 2083661177<br>
>>> x == y<br>
True<br>
>>><br>
>>> formatter = phonenumbers.<a href="#AsYouTypeFormatter">AsYouTypeFormatter</a>("US")<br>
>>> prnt(formatter.input_digit("6"))<br>
6<br>
>>> prnt(formatter.input_digit("5"))<br>
65<br>
>>> prnt(formatter.input_digit("0"))<br>
650<br>
>>> prnt(formatter.input_digit("2"))<br>
650-2<br>
>>> prnt(formatter.input_digit("5"))<br>
650-25<br>
>>> prnt(formatter.input_digit("3"))<br>
650-253<br>
>>> prnt(formatter.input_digit("2"))<br>
650-2532<br>
>>> prnt(formatter.input_digit("2"))<br>
(650) 253-22<br>
>>> prnt(formatter.input_digit("2"))<br>
(650) 253-222<br>
>>> prnt(formatter.input_digit("2"))<br>
(650) 253-2222<br>
>>><br>
>>> text = "Call me at 510-748-8230 if it's before 9:30, or on 703-4800500 after 10am."<br>
>>> for match in phonenumbers.<a href="#PhoneNumberMatcher">PhoneNumberMatcher</a>(text, "US"):<br>
... prnt(match)<br>
...<br>
<a href="#PhoneNumberMatch">PhoneNumberMatch</a> [11,23) 510-748-8230<br>
<a href="#PhoneNumberMatch">PhoneNumberMatch</a> [51,62) 703-4800500<br>
>>> for match in phonenumbers.<a href="#PhoneNumberMatcher">PhoneNumberMatcher</a>(text, "US"):<br>
... prnt(phonenumbers.<a href="#-format_number">format_number</a>(match.number, phonenumbers.<a href="#PhoneNumberFormat">PhoneNumberFormat</a>.E164))<br>
...<br>
+15107488230<br>
+17034800500<br>
>>></tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Package Contents</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="phonenumbers.asyoutypeformatter.html">asyoutypeformatter</a><br>
<a href="phonenumbers.carrier.html">carrier</a><br>
<a href="phonenumbers.carrierdata.html"><strong>carrierdata</strong> (package)</a><br>
<a href="phonenumbers.data.html"><strong>data</strong> (package)</a><br>
<a href="phonenumbers.geocoder.html">geocoder</a><br>
</td><td width="25%" valign=top><a href="phonenumbers.geodata.html"><strong>geodata</strong> (package)</a><br>
<a href="phonenumbers.pb2.html"><strong>pb2</strong> (package)</a><br>
<a href="phonenumbers.phonemetadata.html">phonemetadata</a><br>
<a href="phonenumbers.phonenumber.html">phonenumber</a><br>
<a href="phonenumbers.phonenumbermatcher.html">phonenumbermatcher</a><br>
</td><td width="25%" valign=top><a href="phonenumbers.phonenumberutil.html">phonenumberutil</a><br>
<a href="phonenumbers.prefix.html">prefix</a><br>
<a href="phonenumbers.re_util.html">re_util</a><br>
<a href="phonenumbers.shortdata.html"><strong>shortdata</strong> (package)</a><br>
<a href="phonenumbers.shortnumberinfo.html">shortnumberinfo</a><br>
</td><td width="25%" valign=top><a href="phonenumbers.timezone.html">timezone</a><br>
<a href="phonenumbers.tzdata.html"><strong>tzdata</strong> (package)</a><br>
<a href="phonenumbers.unicode_util.html">unicode_util</a><br>
<a href="phonenumbers.util.html">util</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="builtins.html#Exception">builtins.Exception</a>(<a href="builtins.html#BaseException">builtins.BaseException</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="phonenumbers.phonenumberutil.html#NumberParseException">phonenumbers.phonenumberutil.NumberParseException</a>(<a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>, <a href="builtins.html#Exception">builtins.Exception</a>)
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="phonenumbers.asyoutypeformatter.html#AsYouTypeFormatter">phonenumbers.asyoutypeformatter.AsYouTypeFormatter</a>
</font></dt><dt><font face="helvetica, arial"><a href="phonenumbers.phonenumber.html#CountryCodeSource">phonenumbers.phonenumber.CountryCodeSource</a>
</font></dt><dt><font face="helvetica, arial"><a href="phonenumbers.phonenumbermatcher.html#Leniency">phonenumbers.phonenumbermatcher.Leniency</a>
</font></dt><dt><font face="helvetica, arial"><a href="phonenumbers.phonenumbermatcher.html#PhoneNumberMatcher">phonenumbers.phonenumbermatcher.PhoneNumberMatcher</a>
</font></dt><dt><font face="helvetica, arial"><a href="phonenumbers.phonenumberutil.html#MatchType">phonenumbers.phonenumberutil.MatchType</a>
</font></dt><dt><font face="helvetica, arial"><a href="phonenumbers.phonenumberutil.html#PhoneNumberFormat">phonenumbers.phonenumberutil.PhoneNumberFormat</a>
</font></dt><dt><font face="helvetica, arial"><a href="phonenumbers.phonenumberutil.html#PhoneNumberType">phonenumbers.phonenumberutil.PhoneNumberType</a>
</font></dt><dt><font face="helvetica, arial"><a href="phonenumbers.phonenumberutil.html#ValidationResult">phonenumbers.phonenumberutil.ValidationResult</a>
</font></dt><dt><font face="helvetica, arial"><a href="phonenumbers.shortnumberinfo.html#ShortNumberCost">phonenumbers.shortnumberinfo.ShortNumberCost</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a>(<a href="builtins.html#object">builtins.object</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="phonenumbers.phonemetadata.html#NumberFormat">phonenumbers.phonemetadata.NumberFormat</a>(<a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>, <a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a>)
</font></dt><dt><font face="helvetica, arial"><a href="phonenumbers.phonemetadata.html#PhoneMetadata">phonenumbers.phonemetadata.PhoneMetadata</a>(<a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>, <a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a>)
</font></dt><dt><font face="helvetica, arial"><a href="phonenumbers.phonemetadata.html#PhoneNumberDesc">phonenumbers.phonemetadata.PhoneNumberDesc</a>(<a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>, <a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a>)
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>(<a href="builtins.html#object">builtins.object</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="phonenumbers.phonemetadata.html#NumberFormat">phonenumbers.phonemetadata.NumberFormat</a>(<a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>, <a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a>)
</font></dt><dt><font face="helvetica, arial"><a href="phonenumbers.phonemetadata.html#PhoneMetadata">phonenumbers.phonemetadata.PhoneMetadata</a>(<a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>, <a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a>)
</font></dt><dt><font face="helvetica, arial"><a href="phonenumbers.phonemetadata.html#PhoneNumberDesc">phonenumbers.phonemetadata.PhoneNumberDesc</a>(<a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>, <a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a>)
</font></dt><dt><font face="helvetica, arial"><a href="phonenumbers.phonenumber.html#PhoneNumber">phonenumbers.phonenumber.PhoneNumber</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="phonenumbers.phonenumber.html#FrozenPhoneNumber">phonenumbers.phonenumber.FrozenPhoneNumber</a>(<a href="phonenumbers.phonenumber.html#PhoneNumber">phonenumbers.phonenumber.PhoneNumber</a>, <a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a>)
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="phonenumbers.phonenumbermatcher.html#PhoneNumberMatch">phonenumbers.phonenumbermatcher.PhoneNumberMatch</a>
</font></dt><dt><font face="helvetica, arial"><a href="phonenumbers.phonenumberutil.html#NumberParseException">phonenumbers.phonenumberutil.NumberParseException</a>(<a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>, <a href="builtins.html#Exception">builtins.Exception</a>)
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="AsYouTypeFormatter">class <strong>AsYouTypeFormatter</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#AsYouTypeFormatter">AsYouTypeFormatter</a>(region_code)<br>
<br>
<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="AsYouTypeFormatter-__init__"><strong>__init__</strong></a>(self, region_code)</dt><dd><tt>Gets an <a href="#AsYouTypeFormatter">AsYouTypeFormatter</a> for the specific region.<br>
<br>
Arguments:<br>
region_code -- The region where the phone number is being entered<br>
<br>
Return an <a href="#AsYouTypeFormatter">AsYouTypeFormatter</a>} <a href="builtins.html#object">object</a>, which could be used to format<br>
phone numbers in the specific region "as you type"</tt></dd></dl>
<dl><dt><a name="AsYouTypeFormatter-clear"><strong>clear</strong></a>(self)</dt><dd><tt>Clears the internal state of the formatter, so it can be reused.</tt></dd></dl>
<dl><dt><a name="AsYouTypeFormatter-get_remembered_position"><strong>get_remembered_position</strong></a>(self)</dt><dd><tt>Returns the current position in the partially formatted phone<br>
number of the character which was previously passed in as the<br>
parameter of <a href="#AsYouTypeFormatter-input_digit">input_digit</a>(remember_position=True).</tt></dd></dl>
<dl><dt><a name="AsYouTypeFormatter-input_digit"><strong>input_digit</strong></a>(self, next_char, remember_position=False)</dt><dd><tt>Formats a phone number on-the-fly as each digit is entered.<br>
<br>
If remember_position is set, remembers the position where next_char is<br>
inserted, so that it can be retrieved later by using<br>
get_remembered_position. The remembered position will be automatically<br>
adjusted if additional formatting characters are later<br>
inserted/removed in front of next_char.<br>
<br>
Arguments:<br>
<br>
next_char -- The most recently entered digit of a phone<br>
number. Formatting characters are allowed, but as soon as they<br>
are encountered this method formats the number as entered and<br>
not "as you type" anymore. Full width digits and Arabic-indic<br>
digits are allowed, and will be shown as they are.<br>
remember_position -- Whether to track the position where next_char is<br>
inserted.<br>
<br>
Returns the partially formatted phone number.</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="CountryCodeSource">class <strong>CountryCodeSource</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>The source from which a country code is derived.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>FROM_DEFAULT_COUNTRY</strong> = 20</dl>
<dl><dt><strong>FROM_NUMBER_WITHOUT_PLUS_SIGN</strong> = 10</dl>
<dl><dt><strong>FROM_NUMBER_WITH_IDD</strong> = 5</dl>
<dl><dt><strong>FROM_NUMBER_WITH_PLUS_SIGN</strong> = 1</dl>
<dl><dt><strong>UNSPECIFIED</strong> = 0</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="FrozenPhoneNumber">class <strong>FrozenPhoneNumber</strong></a>(<a href="phonenumbers.phonenumber.html#PhoneNumber">PhoneNumber</a>, <a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#FrozenPhoneNumber">FrozenPhoneNumber</a>(*__args, **__kwargs)<br>
<br>
Immutable version of <a href="#PhoneNumber">PhoneNumber</a><br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="phonenumbers.phonenumber.html#FrozenPhoneNumber">FrozenPhoneNumber</a></dd>
<dd><a href="phonenumbers.phonenumber.html#PhoneNumber">PhoneNumber</a></dd>
<dd><a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a></dd>
<dd><a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="FrozenPhoneNumber-__hash__"><strong>__hash__</strong></a>(self)</dt><dd><tt>Return hash(self).</tt></dd></dl>
<dl><dt><a name="FrozenPhoneNumber-__init__"><strong>__init__</strong></a> = wrapper(self, *__args, **__kwargs)</dt></dl>
<hr>
Methods inherited from <a href="phonenumbers.phonenumber.html#PhoneNumber">PhoneNumber</a>:<br>
<dl><dt><a name="FrozenPhoneNumber-__eq__"><strong>__eq__</strong></a>(self, other)</dt><dd><tt>Return self==value.</tt></dd></dl>
<dl><dt><a name="FrozenPhoneNumber-__ne__"><strong>__ne__</strong></a>(self, other)</dt><dd><tt>Return self!=value.</tt></dd></dl>
<dl><dt><a name="FrozenPhoneNumber-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return repr(self).</tt></dd></dl>
<dl><dt><a name="FrozenPhoneNumber-__unicode__"><strong>__unicode__</strong></a>(self)</dt></dl>
<dl><dt><a name="FrozenPhoneNumber-clear"><strong>clear</strong></a>(self)</dt><dd><tt>Erase the contents of the <a href="builtins.html#object">object</a></tt></dd></dl>
<dl><dt><a name="FrozenPhoneNumber-merge_from"><strong>merge_from</strong></a>(self, other)</dt><dd><tt>Merge information from another <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a> into this one.</tt></dd></dl>
<hr>
Methods inherited from <a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>:<br>
<dl><dt><a name="FrozenPhoneNumber-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>Return str(self).</tt></dd></dl>
<hr>
Data descriptors inherited from <a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Methods inherited from <a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a>:<br>
<dl><dt><a name="FrozenPhoneNumber-__delattr__"><strong>__delattr__</strong></a>(self, name)</dt><dd><tt>Implement delattr(self, name).</tt></dd></dl>
<dl><dt><a name="FrozenPhoneNumber-__setattr__"><strong>__setattr__</strong></a>(self, name, value)</dt><dd><tt>Implement setattr(self, name, value).</tt></dd></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="Leniency">class <strong>Leniency</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#Leniency">Leniency</a> when finding potential phone numbers in text segments.<br>
<br>
The levels here are ordered in increasing strictness.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>EXACT_GROUPING</strong> = 3</dl>
<dl><dt><strong>POSSIBLE</strong> = 0</dl>
<dl><dt><strong>STRICT_GROUPING</strong> = 2</dl>
<dl><dt><strong>VALID</strong> = 1</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="MatchType">class <strong>MatchType</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Types of phone number matches.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Class methods defined here:<br>
<dl><dt><a name="MatchType-to_string"><strong>to_string</strong></a>(val)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Return a string representation of a <a href="#MatchType">MatchType</a> value</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>EXACT_MATCH</strong> = 4</dl>
<dl><dt><strong>NOT_A_NUMBER</strong> = 0</dl>
<dl><dt><strong>NO_MATCH</strong> = 1</dl>
<dl><dt><strong>NSN_MATCH</strong> = 3</dl>
<dl><dt><strong>SHORT_NSN_MATCH</strong> = 2</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="NumberFormat">class <strong>NumberFormat</strong></a>(<a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>, <a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#NumberFormat">NumberFormat</a>(*__args, **__kwargs)<br>
<br>
Representation of way that a phone number can be formatted for output<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="phonenumbers.phonemetadata.html#NumberFormat">NumberFormat</a></dd>
<dd><a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a></dd>
<dd><a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="NumberFormat-__eq__"><strong>__eq__</strong></a>(self, other)</dt><dd><tt>Return self==value.</tt></dd></dl>
<dl><dt><a name="NumberFormat-__init__"><strong>__init__</strong></a> = wrapper(self, *__args, **__kwargs)</dt></dl>
<dl><dt><a name="NumberFormat-__ne__"><strong>__ne__</strong></a>(self, other)</dt><dd><tt>Return self!=value.</tt></dd></dl>
<dl><dt><a name="NumberFormat-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return repr(self).</tt></dd></dl>
<dl><dt><a name="NumberFormat-__unicode__"><strong>__unicode__</strong></a>(self)</dt></dl>
<dl><dt><a name="NumberFormat-merge_from"><strong>merge_from</strong></a>(self, other)</dt><dd><tt>Merge information from another <a href="#NumberFormat">NumberFormat</a> <a href="builtins.html#object">object</a> into this one.</tt></dd></dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>__hash__</strong> = None</dl>
<hr>
Methods inherited from <a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>:<br>
<dl><dt><a name="NumberFormat-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>Return str(self).</tt></dd></dl>
<hr>
Data descriptors inherited from <a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Methods inherited from <a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a>:<br>
<dl><dt><a name="NumberFormat-__delattr__"><strong>__delattr__</strong></a>(self, name)</dt><dd><tt>Implement delattr(self, name).</tt></dd></dl>
<dl><dt><a name="NumberFormat-__setattr__"><strong>__setattr__</strong></a>(self, name, value)</dt><dd><tt>Implement setattr(self, name, value).</tt></dd></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="NumberParseException">class <strong>NumberParseException</strong></a>(<a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>, <a href="builtins.html#Exception">builtins.Exception</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#NumberParseException">NumberParseException</a>(error_type, msg)<br>
<br>
<a href="builtins.html#Exception">Exception</a> when attempting to parse a putative phone number<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="phonenumbers.phonenumberutil.html#NumberParseException">NumberParseException</a></dd>
<dd><a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a></dd>
<dd><a href="builtins.html#Exception">builtins.Exception</a></dd>
<dd><a href="builtins.html#BaseException">builtins.BaseException</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="NumberParseException-__init__"><strong>__init__</strong></a>(self, error_type, msg)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
<dl><dt><a name="NumberParseException-__reduce__"><strong>__reduce__</strong></a>(self)</dt><dd><tt>Helper for pickle.</tt></dd></dl>
<dl><dt><a name="NumberParseException-__unicode__"><strong>__unicode__</strong></a>(self)</dt></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>INVALID_COUNTRY_CODE</strong> = 0</dl>
<dl><dt><strong>NOT_A_NUMBER</strong> = 1</dl>
<dl><dt><strong>TOO_LONG</strong> = 4</dl>
<dl><dt><strong>TOO_SHORT_AFTER_IDD</strong> = 2</dl>
<dl><dt><strong>TOO_SHORT_NSN</strong> = 3</dl>
<hr>
Methods inherited from <a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>:<br>
<dl><dt><a name="NumberParseException-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>Return str(self).</tt></dd></dl>
<hr>
Data descriptors inherited from <a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<hr>
Static methods inherited from <a href="builtins.html#Exception">builtins.Exception</a>:<br>
<dl><dt><a name="NumberParseException-__new__"><strong>__new__</strong></a>(*args, **kwargs)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Create and return a new <a href="builtins.html#object">object</a>. See help(type) for accurate signature.</tt></dd></dl>
<hr>
Methods inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
<dl><dt><a name="NumberParseException-__delattr__"><strong>__delattr__</strong></a>(self, name, /)</dt><dd><tt>Implement delattr(self, name).</tt></dd></dl>
<dl><dt><a name="NumberParseException-__getattribute__"><strong>__getattribute__</strong></a>(self, name, /)</dt><dd><tt>Return getattr(self, name).</tt></dd></dl>
<dl><dt><a name="NumberParseException-__repr__"><strong>__repr__</strong></a>(self, /)</dt><dd><tt>Return repr(self).</tt></dd></dl>
<dl><dt><a name="NumberParseException-__setattr__"><strong>__setattr__</strong></a>(self, name, value, /)</dt><dd><tt>Implement setattr(self, name, value).</tt></dd></dl>
<dl><dt><a name="NumberParseException-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl>
<dl><dt><a name="NumberParseException-with_traceback"><strong>with_traceback</strong></a>(...)</dt><dd><tt><a href="builtins.html#Exception">Exception</a>.<a href="#NumberParseException-with_traceback">with_traceback</a>(tb) --<br>
set self.<strong>__traceback__</strong> to tb and return self.</tt></dd></dl>
<hr>
Data descriptors inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
<dl><dt><strong>__cause__</strong></dt>
<dd><tt>exception cause</tt></dd>
</dl>
<dl><dt><strong>__context__</strong></dt>
<dd><tt>exception context</tt></dd>
</dl>
<dl><dt><strong>__suppress_context__</strong></dt>
</dl>
<dl><dt><strong>__traceback__</strong></dt>
</dl>
<dl><dt><strong>args</strong></dt>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="PhoneMetadata">class <strong>PhoneMetadata</strong></a>(<a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>, <a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#PhoneMetadata">PhoneMetadata</a>(*__args, **__kwargs)<br>
<br>
Class representing metadata for international telephone numbers for a region.<br>
<br>
This class is hand created based on phonemetadata.proto. Please refer to that file<br>
for detailed descriptions of the meaning of each field.<br>
<br>
WARNING: This API isn't stable. It is considered libphonenumber-internal<br>
and can change at any time. We only declare it as public for easy<br>
inclusion in our build tools not in this package. Clients should not<br>
refer to this file, we do not commit to support backwards-compatibility or<br>
to warn about breaking changes.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="phonenumbers.phonemetadata.html#PhoneMetadata">PhoneMetadata</a></dd>
<dd><a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a></dd>
<dd><a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="PhoneMetadata-__eq__"><strong>__eq__</strong></a>(self, other)</dt><dd><tt>Return self==value.</tt></dd></dl>
<dl><dt><a name="PhoneMetadata-__init__"><strong>__init__</strong></a> = wrapper(self, *__args, **__kwargs)</dt></dl>
<dl><dt><a name="PhoneMetadata-__ne__"><strong>__ne__</strong></a>(self, other)</dt><dd><tt>Return self!=value.</tt></dd></dl>
<dl><dt><a name="PhoneMetadata-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return repr(self).</tt></dd></dl>
<dl><dt><a name="PhoneMetadata-__unicode__"><strong>__unicode__</strong></a>(self)</dt></dl>
<hr>
Class methods defined here:<br>
<dl><dt><a name="PhoneMetadata-load_all"><strong>load_all</strong></a>()<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Force immediate load of all metadata</tt></dd></dl>
<dl><dt><a name="PhoneMetadata-metadata_for_nongeo_region"><strong>metadata_for_nongeo_region</strong></a>(country_code, default=None)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt></dl>
<dl><dt><a name="PhoneMetadata-metadata_for_region"><strong>metadata_for_region</strong></a>(region_code, default=None)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt></dl>
<dl><dt><a name="PhoneMetadata-metadata_for_region_or_calling_code"><strong>metadata_for_region_or_calling_code</strong></a>(country_calling_code, region_code)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt></dl>
<dl><dt><a name="PhoneMetadata-register_nongeo_region_loader"><strong>register_nongeo_region_loader</strong></a>(country_code, loader)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt></dl>
<dl><dt><a name="PhoneMetadata-register_region_loader"><strong>register_region_loader</strong></a>(region_code, loader)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt></dl>
<dl><dt><a name="PhoneMetadata-register_short_region_loader"><strong>register_short_region_loader</strong></a>(region_code, loader)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt></dl>
<dl><dt><a name="PhoneMetadata-short_metadata_for_region"><strong>short_metadata_for_region</strong></a>(region_code, default=None)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt></dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>__hash__</strong> = None</dl>
<hr>
Methods inherited from <a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>:<br>
<dl><dt><a name="PhoneMetadata-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>Return str(self).</tt></dd></dl>
<hr>
Data descriptors inherited from <a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Methods inherited from <a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a>:<br>
<dl><dt><a name="PhoneMetadata-__delattr__"><strong>__delattr__</strong></a>(self, name)</dt><dd><tt>Implement delattr(self, name).</tt></dd></dl>
<dl><dt><a name="PhoneMetadata-__setattr__"><strong>__setattr__</strong></a>(self, name, value)</dt><dd><tt>Implement setattr(self, name, value).</tt></dd></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="PhoneNumber">class <strong>PhoneNumber</strong></a>(<a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#PhoneNumber">PhoneNumber</a>(country_code=None, national_number=None, extension=None, italian_leading_zero=None, number_of_leading_zeros=None, raw_input=None, country_code_source=0, preferred_domestic_carrier_code=None)<br>
<br>
Class representing international telephone numbers.<br>
<br>
This class is hand-created based on phonenumber.proto. Please refer<br>
to that file for detailed descriptions of the meaning of each field.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="phonenumbers.phonenumber.html#PhoneNumber">PhoneNumber</a></dd>
<dd><a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="PhoneNumber-__eq__"><strong>__eq__</strong></a>(self, other)</dt><dd><tt>Return self==value.</tt></dd></dl>
<dl><dt><a name="PhoneNumber-__init__"><strong>__init__</strong></a>(self, country_code=None, national_number=None, extension=None, italian_leading_zero=None, number_of_leading_zeros=None, raw_input=None, country_code_source=0, preferred_domestic_carrier_code=None)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
<dl><dt><a name="PhoneNumber-__ne__"><strong>__ne__</strong></a>(self, other)</dt><dd><tt>Return self!=value.</tt></dd></dl>
<dl><dt><a name="PhoneNumber-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return repr(self).</tt></dd></dl>
<dl><dt><a name="PhoneNumber-__unicode__"><strong>__unicode__</strong></a>(self)</dt></dl>
<dl><dt><a name="PhoneNumber-clear"><strong>clear</strong></a>(self)</dt><dd><tt>Erase the contents of the <a href="builtins.html#object">object</a></tt></dd></dl>
<dl><dt><a name="PhoneNumber-merge_from"><strong>merge_from</strong></a>(self, other)</dt><dd><tt>Merge information from another <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a> into this one.</tt></dd></dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>__hash__</strong> = None</dl>
<hr>
Methods inherited from <a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>:<br>
<dl><dt><a name="PhoneNumber-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>Return str(self).</tt></dd></dl>
<hr>
Data descriptors inherited from <a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="PhoneNumberDesc">class <strong>PhoneNumberDesc</strong></a>(<a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>, <a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#PhoneNumberDesc">PhoneNumberDesc</a>(*__args, **__kwargs)<br>
<br>
Class representing the description of a set of phone numbers.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="phonenumbers.phonemetadata.html#PhoneNumberDesc">PhoneNumberDesc</a></dd>
<dd><a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a></dd>
<dd><a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="PhoneNumberDesc-__eq__"><strong>__eq__</strong></a>(self, other)</dt><dd><tt>Return self==value.</tt></dd></dl>
<dl><dt><a name="PhoneNumberDesc-__init__"><strong>__init__</strong></a> = wrapper(self, *__args, **__kwargs)</dt></dl>
<dl><dt><a name="PhoneNumberDesc-__ne__"><strong>__ne__</strong></a>(self, other)</dt><dd><tt>Return self!=value.</tt></dd></dl>
<dl><dt><a name="PhoneNumberDesc-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return repr(self).</tt></dd></dl>
<dl><dt><a name="PhoneNumberDesc-__unicode__"><strong>__unicode__</strong></a>(self)</dt></dl>
<dl><dt><a name="PhoneNumberDesc-merge_from"><strong>merge_from</strong></a>(self, other)</dt><dd><tt>Merge information from another <a href="#PhoneNumberDesc">PhoneNumberDesc</a> <a href="builtins.html#object">object</a> into this one.</tt></dd></dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>__hash__</strong> = None</dl>
<hr>
Methods inherited from <a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>:<br>
<dl><dt><a name="PhoneNumberDesc-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>Return str(self).</tt></dd></dl>
<hr>
Data descriptors inherited from <a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Methods inherited from <a href="phonenumbers.util.html#ImmutableMixin">phonenumbers.util.ImmutableMixin</a>:<br>
<dl><dt><a name="PhoneNumberDesc-__delattr__"><strong>__delattr__</strong></a>(self, name)</dt><dd><tt>Implement delattr(self, name).</tt></dd></dl>
<dl><dt><a name="PhoneNumberDesc-__setattr__"><strong>__setattr__</strong></a>(self, name, value)</dt><dd><tt>Implement setattr(self, name, value).</tt></dd></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="PhoneNumberFormat">class <strong>PhoneNumberFormat</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Phone number format.<br>
<br>
INTERNATIONAL and NATIONAL formats are consistent with the definition in<br>
ITU-T Recommendation E123. However we follow local conventions such as using<br>
'-' instead of whitespace as separators. For example, the number of the<br>
Google Switzerland office will be written as "+41 44 668 1800" in<br>
INTERNATIONAL format, and as "044 668 1800" in NATIONAL format. E164 format<br>
is as per INTERNATIONAL format but with no formatting applied,<br>
e.g. "+41446681800". <a href="http://www.rfc-editor.org/rfc/rfc3966.txt">RFC3966</a> is as per INTERNATIONAL format, but with all<br>
spaces and other separating symbols replaced with a hyphen, and with any<br>
phone number extension appended with ";ext=". It also will have a prefix of<br>
"tel:" added, e.g. "tel:+41-44-668-1800".<br>
<br>
Note: If you are considering storing the number in a neutral format, you<br>
are highly advised to use the <a href="#PhoneNumber">PhoneNumber</a> class.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Class methods defined here:<br>
<dl><dt><a name="PhoneNumberFormat-to_string"><strong>to_string</strong></a>(val)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Return a string representation of a <a href="#PhoneNumberFormat">PhoneNumberFormat</a> value</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>E164</strong> = 0</dl>
<dl><dt><strong>INTERNATIONAL</strong> = 1</dl>
<dl><dt><strong>NATIONAL</strong> = 2</dl>
<dl><dt><strong>RFC3966</strong> = 3</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="PhoneNumberMatch">class <strong>PhoneNumberMatch</strong></a>(<a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#PhoneNumberMatch">PhoneNumberMatch</a>(start, raw_string, numobj)<br>
<br>
The immutable match of a phone number within a piece of text.<br>
<br>
Matches may be found using the find() method of <a href="#PhoneNumberMatcher">PhoneNumberMatcher</a>.<br>
<br>
A match consists of the phone number (in .number) as well as the .start<br>
and .end offsets of the corresponding subsequence of the searched<br>
text. Use .raw_string to obtain a copy of the matched subsequence.<br>
<br>
The following annotated example clarifies the relationship between the<br>
searched text, the match offsets, and the parsed number:<br>
<br>
>>> text = "Call me at +1 425 882-8080 for details."<br>
>>> country = "US"<br>
>>> import phonenumbers<br>
>>> matcher = phonenumbers.<a href="#PhoneNumberMatcher">PhoneNumberMatcher</a>(text, country)<br>
>>> matcher.has_next()<br>
True<br>
>>> m = matcher.next() # Find the first phone number match<br>
>>> m.raw_string # contains the phone number as it appears in the text.<br>
"+1 425 882-8080"<br>
>>> (m.start, m.end) # define the range of the matched subsequence.<br>
(11, 26)<br>
>>> text[m.start, m.end]<br>
"+1 425 882-8080"<br>
>>> phonenumberutil.<a href="#-parse">parse</a>("+1 425 882-8080", "US") == m.number<br>
True<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="phonenumbers.phonenumbermatcher.html#PhoneNumberMatch">PhoneNumberMatch</a></dd>
<dd><a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="PhoneNumberMatch-__eq__"><strong>__eq__</strong></a>(self, other)</dt><dd><tt>Return self==value.</tt></dd></dl>
<dl><dt><a name="PhoneNumberMatch-__init__"><strong>__init__</strong></a>(self, start, raw_string, numobj)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
<dl><dt><a name="PhoneNumberMatch-__ne__"><strong>__ne__</strong></a>(self, other)</dt><dd><tt>Return self!=value.</tt></dd></dl>
<dl><dt><a name="PhoneNumberMatch-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return repr(self).</tt></dd></dl>
<dl><dt><a name="PhoneNumberMatch-__unicode__"><strong>__unicode__</strong></a>(self)</dt></dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>__hash__</strong> = None</dl>
<hr>
Methods inherited from <a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>:<br>
<dl><dt><a name="PhoneNumberMatch-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>Return str(self).</tt></dd></dl>
<hr>
Data descriptors inherited from <a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="PhoneNumberMatcher">class <strong>PhoneNumberMatcher</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#PhoneNumberMatcher">PhoneNumberMatcher</a>(text, region, leniency=1, max_tries=65535)<br>
<br>
A stateful class that finds and extracts telephone numbers from text.<br>
<br>
Vanity numbers (phone numbers using alphabetic digits such as '1-800-SIX-FLAGS' are<br>
not found.<br>
<br>
This class is not thread-safe.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="PhoneNumberMatcher-__init__"><strong>__init__</strong></a>(self, text, region, leniency=1, max_tries=65535)</dt><dd><tt>Creates a new instance.<br>
<br>
Arguments:<br>
text -- The character sequence that we will search, None for no text.<br>
country -- The country to assume for phone numbers not written in<br>
international format (with a leading plus, or with the<br>
international dialing prefix of the specified region). May be<br>
None or "ZZ" if only numbers with a leading plus should be<br>
considered.<br>
leniency -- The leniency to use when evaluating candidate phone<br>
numbers.<br>
max_tries -- The maximum number of invalid numbers to try before<br>
giving up on the text. This is to cover degenerate cases where<br>
the text has a lot of false positives in it. Must be >= 0.</tt></dd></dl>
<dl><dt><a name="PhoneNumberMatcher-__iter__"><strong>__iter__</strong></a>(self)</dt></dl>
<dl><dt><a name="PhoneNumberMatcher-has_next"><strong>has_next</strong></a>(self)</dt><dd><tt>Indicates whether there is another match available</tt></dd></dl>
<dl><dt><a name="PhoneNumberMatcher-next"><strong>next</strong></a>(self)</dt><dd><tt>Return the next match; raises <a href="builtins.html#Exception">Exception</a> if no next match available</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="PhoneNumberType">class <strong>PhoneNumberType</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Type of phone numbers.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Class methods defined here:<br>
<dl><dt><a name="PhoneNumberType-to_string"><strong>to_string</strong></a>(val)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Return a string representation of a <a href="#PhoneNumberType">PhoneNumberType</a> value</tt></dd></dl>
<dl><dt><a name="PhoneNumberType-values"><strong>values</strong></a>()<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>FIXED_LINE</strong> = 0</dl>
<dl><dt><strong>FIXED_LINE_OR_MOBILE</strong> = 2</dl>
<dl><dt><strong>MOBILE</strong> = 1</dl>
<dl><dt><strong>PAGER</strong> = 8</dl>
<dl><dt><strong>PERSONAL_NUMBER</strong> = 7</dl>
<dl><dt><strong>PREMIUM_RATE</strong> = 4</dl>
<dl><dt><strong>SHARED_COST</strong> = 5</dl>
<dl><dt><strong>TOLL_FREE</strong> = 3</dl>
<dl><dt><strong>UAN</strong> = 9</dl>
<dl><dt><strong>UNKNOWN</strong> = 99</dl>
<dl><dt><strong>VOICEMAIL</strong> = 10</dl>
<dl><dt><strong>VOIP</strong> = 6</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="ShortNumberCost">class <strong>ShortNumberCost</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Cost categories of short numbers.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>PREMIUM_RATE</strong> = 2</dl>
<dl><dt><strong>STANDARD_RATE</strong> = 1</dl>
<dl><dt><strong>TOLL_FREE</strong> = 0</dl>
<dl><dt><strong>UNKNOWN_COST</strong> = 3</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="ValidationResult">class <strong>ValidationResult</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Possible outcomes when testing if a <a href="#PhoneNumber">PhoneNumber</a> is a possible number.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Class methods defined here:<br>
<dl><dt><a name="ValidationResult-to_string"><strong>to_string</strong></a>(val)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Return a string representation of a <a href="#ValidationResult">ValidationResult</a> value</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>INVALID_COUNTRY_CODE</strong> = 1</dl>
<dl><dt><strong>INVALID_LENGTH</strong> = 5</dl>
<dl><dt><strong>IS_POSSIBLE</strong> = 0</dl>
<dl><dt><strong>IS_POSSIBLE_LOCAL_ONLY</strong> = 4</dl>
<dl><dt><strong>TOO_LONG</strong> = 3</dl>
<dl><dt><strong>TOO_SHORT</strong> = 2</dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-can_be_internationally_dialled"><strong>can_be_internationally_dialled</strong></a>(numobj)</dt><dd><tt>Returns True if the number can only be dialled from outside the region,<br>
or unknown.<br>
<br>
If the number can only be dialled from within the region<br>
as well, returns False. Does not check the number is a valid number.<br>
Note that, at the moment, this method does not handle short numbers (which<br>
are currently all presumed to not be diallable from outside their country).<br>
<br>
Arguments:<br>
numobj -- the phone number objectfor which we want to know whether it is<br>
diallable from outside the region.</tt></dd></dl>
<dl><dt><a name="-connects_to_emergency_number"><strong>connects_to_emergency_number</strong></a>(number, region_code)</dt><dd><tt>Returns whether the given number, exactly as dialled, might be used to<br>
connect to an emergency service in the given region.<br>
<br>
This function accepts a string, rather than a <a href="#PhoneNumber">PhoneNumber</a>, because it<br>
needs to distinguish cases such as "+1 911" and "911", where the former<br>
may not connect to an emergency service in all cases but the latter would.<br>
<br>
This function takes into account cases where the number might contain<br>
formatting, or might have additional digits appended (when it is okay to<br>
do that in the specified region).<br>
<br>
Arguments:<br>
number -- The phone number to test.<br>
region_code -- The region where the phone number is being dialed.<br>
<br>
Returns whether the number might be used to connect to an emergency<br>
service in the given region.</tt></dd></dl>
<dl><dt><a name="-convert_alpha_characters_in_number"><strong>convert_alpha_characters_in_number</strong></a>(number)</dt><dd><tt>Convert alpha chars in a number to their respective digits on a keypad,<br>
but retains existing formatting.</tt></dd></dl>
<dl><dt><a name="-country_code_for_region"><strong>country_code_for_region</strong></a>(region_code)</dt><dd><tt>Returns the country calling code for a specific region.<br>
<br>
For example, this would be 1 for the United States, and 64 for New<br>
Zealand.<br>
<br>
Arguments:<br>
region_code -- The region that we want to get the country calling code for.<br>
<br>
Returns the country calling code for the region denoted by region_code.</tt></dd></dl>
<dl><dt><a name="-country_code_for_valid_region"><strong>country_code_for_valid_region</strong></a>(region_code)</dt><dd><tt>Returns the country calling code for a specific region.<br>
<br>
For example, this would be 1 for the United States, and 64 for New<br>
Zealand. Assumes the region is already valid.<br>
<br>
Arguments:<br>
region_code -- The region that we want to get the country calling code for.<br>
<br>
Returns the country calling code for the region denoted by region_code.</tt></dd></dl>
<dl><dt><a name="-country_mobile_token"><strong>country_mobile_token</strong></a>(country_code)</dt><dd><tt>Returns the mobile token for the provided country calling code if it has one, otherwise<br>
returns an empty string. A mobile token is a number inserted before the area code when dialing<br>
a mobile number from that country from abroad.<br>
<br>
Arguments:<br>
country_code -- the country calling code for which we want the mobile token<br>
Returns the mobile token, as a string, for the given country calling code.</tt></dd></dl>
<dl><dt><a name="-example_number"><strong>example_number</strong></a>(region_code)</dt><dd><tt>Gets a valid number for the specified region.<br>
<br>
Arguments:<br>
region_code -- The region for which an example number is needed.<br>
<br>
Returns a valid fixed-line number for the specified region. Returns None<br>
when the metadata does not contain such information, or the region 001 is<br>
passed in. For 001 (representing non-geographical numbers), call<br>
example_number_for_non_geo_entity instead.</tt></dd></dl>
<dl><dt><a name="-example_number_for_non_geo_entity"><strong>example_number_for_non_geo_entity</strong></a>(country_calling_code)</dt><dd><tt>Gets a valid number for the specified country calling code for a non-geographical entity.<br>
<br>
Arguments:<br>
country_calling_code -- The country calling code for a non-geographical entity.<br>
<br>
Returns a valid number for the non-geographical entity. Returns None when<br>
the metadata does not contain such information, or the country calling<br>
code passed in does not belong to a non-geographical entity.</tt></dd></dl>
<dl><dt><a name="-example_number_for_type"><strong>example_number_for_type</strong></a>(region_code, num_type)</dt><dd><tt>Gets a valid number for the specified region and number type.<br>
<br>
If None is given as the region_code, then the returned number <a href="builtins.html#object">object</a><br>
may belong to any country.<br>
<br>
Arguments:<br>
region_code -- The region for which an example number is needed, or None.<br>
num_type -- The type of number that is needed.<br>
<br>
Returns a valid number for the specified region and type. Returns None<br>
when the metadata does not contain such information or if an invalid<br>
region or region 001 was specified. For 001 (representing<br>
non-geographical numbers), call example_number_for_non_geo_entity instead.</tt></dd></dl>
<dl><dt><a name="-expected_cost"><strong>expected_cost</strong></a>(numobj)</dt><dd><tt>Gets the expected cost category of a short number (however, nothing is<br>
implied about its validity). If the country calling code is unique to a<br>
region, this method behaves exactly the same as<br>
expected_cost_for_region. However, if the country calling code is<br>
shared by multiple regions, then it returns the highest cost in the<br>
sequence PREMIUM_RATE, UNKNOWN_COST, STANDARD_RATE, TOLL_FREE. The reason<br>
for the position of UNKNOWN_COST in this order is that if a number is<br>
UNKNOWN_COST in one region but STANDARD_RATE or TOLL_FREE in another, its<br>
expected cost cannot be estimated as one of the latter since it might be a<br>
PREMIUM_RATE number.<br>
<br>
For example, if a number is STANDARD_RATE in the US, but TOLL_FREE in<br>
Canada, the expected cost returned by this method will be STANDARD_RATE,<br>
since the NANPA countries share the same country calling code.<br>
<br>
Note: If the region from which the number is dialed is known, it is highly preferable to call<br>
expected_cost_for_region instead.<br>
<br>
Arguments:<br>
numobj -- the short number for which we want to know the expected cost category<br>
<br>
Return the highest expected cost category of the short number in the<br>
region(s) with the given country calling code</tt></dd></dl>
<dl><dt><a name="-expected_cost_for_region"><strong>expected_cost_for_region</strong></a>(short_numobj, region_dialing_from)</dt><dd><tt>Gets the expected cost category of a short number when dialled from a<br>
region (however, nothing is implied about its validity). If it is<br>
important that the number is valid, then its validity must first be<br>
checked using is_valid_short_number_for_region. Note that emergency<br>
numbers are always considered toll-free.<br>
<br>
Example usage:<br>
short_number = "110"<br>
region_code = "FR"<br>
if phonenumbers.<a href="#-is_valid_short_number_for_region">is_valid_short_number_for_region</a>(short_number, region_code):<br>
cost = phonenumbers.<a href="#-expected_cost">expected_cost</a>(short_number, region_code) # <a href="#ShortNumberCost">ShortNumberCost</a><br>
# Do something with the cost information here.<br>
<br>
Arguments:<br>
short_numobj -- the short number for which we want to know the expected cost category<br>
as a <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a>.<br>
region_dialing_from -- the region from which the number is dialed<br>
<br>
Return the expected cost category for that region of the short<br>
number. Returns UNKNOWN_COST if the number does not match a cost<br>
category. Note that an invalid number may match any cost category.</tt></dd></dl>
<dl><dt><a name="-format_by_pattern"><strong>format_by_pattern</strong></a>(numobj, number_format, user_defined_formats)</dt><dd><tt>Formats a phone number using client-defined formatting rules.<br>
<br>
Note that if the phone number has a country calling code of zero or an<br>
otherwise invalid country calling code, we cannot work out things like<br>
whether there should be a national prefix applied, or how to format<br>
extensions, so we return the national significant number with no<br>
formatting applied.<br>
<br>
Arguments:<br>
numobj -- The phone number to be formatted<br>
number_format -- The format the phone number should be formatted into,<br>
as a <a href="#PhoneNumberFormat">PhoneNumberFormat</a> value.<br>
user_defined_formats -- formatting rules specified by clients, as a list<br>
of <a href="#NumberFormat">NumberFormat</a> objects.<br>
<br>
Returns the formatted phone number.</tt></dd></dl>
<dl><dt><a name="-format_in_original_format"><strong>format_in_original_format</strong></a>(numobj, region_calling_from)</dt><dd><tt>Format a number using the original format that the number was parsed from.<br>
<br>
The original format is embedded in the country_code_source field of the<br>
<a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a> passed in. If such information is missing, the number<br>
will be formatted into the NATIONAL format by default.<br>
<br>
When we don't have a formatting pattern for the number, the method<br>
returns the raw input when it is available.<br>
<br>
Note this method guarantees no digit will be inserted, removed or modified<br>
as a result of formatting.<br>
<br>
Arguments:<br>
number -- The phone number that needs to be formatted in its original<br>
number format<br>
region_calling_from -- The region whose IDD needs to be prefixed if the<br>
original number has one.<br>
<br>
Returns the formatted phone number in its original number format.</tt></dd></dl>
<dl><dt><a name="-format_national_number_with_carrier_code"><strong>format_national_number_with_carrier_code</strong></a>(numobj, carrier_code)</dt><dd><tt>Format a number in national format for dialing using the specified carrier.<br>
<br>
The carrier-code will always be used regardless of whether the phone<br>
number already has a preferred domestic carrier code stored. If<br>
carrier_code contains an empty string, returns the number in national<br>
format without any carrier code.<br>
<br>
Arguments:<br>
numobj -- The phone number to be formatted<br>
carrier_code -- The carrier selection code to be used<br>
<br>
Returns the formatted phone number in national format for dialing using<br>
the carrier as specified in the carrier_code.</tt></dd></dl>
<dl><dt><a name="-format_national_number_with_preferred_carrier_code"><strong>format_national_number_with_preferred_carrier_code</strong></a>(numobj, fallback_carrier_code)</dt><dd><tt>Formats a phone number in national format for dialing using the carrier<br>
as specified in the preferred_domestic_carrier_code field of the<br>
<a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a> passed in. If that is missing, use the<br>
fallback_carrier_code passed in instead. If there is no<br>
preferred_domestic_carrier_code, and the fallback_carrier_code contains an<br>
empty string, return the number in national format without any carrier<br>
code.<br>
<br>
Use format_national_number_with_carrier_code instead if the carrier code<br>
passed in should take precedence over the number's<br>
preferred_domestic_carrier_code when formatting.<br>
<br>
Arguments:<br>
numobj -- The phone number to be formatted<br>
carrier_code -- The carrier selection code to be used, if none is found in the<br>
phone number itself.<br>
<br>
Returns the formatted phone number in national format for dialing using<br>
the number's preferred_domestic_carrier_code, or the fallback_carrier_code<br>
pass in if none is found.</tt></dd></dl>
<dl><dt><a name="-format_number"><strong>format_number</strong></a>(numobj, num_format)</dt><dd><tt>Formats a phone number in the specified format using default rules.<br>
<br>
Note that this does not promise to produce a phone number that the user<br>
can dial from where they are - although we do format in either 'national'<br>
or 'international' format depending on what the client asks for, we do not<br>
currently support a more abbreviated format, such as for users in the same<br>
"area" who could potentially dial the number without area code. Note that<br>
if the phone number has a country calling code of 0 or an otherwise<br>
invalid country calling code, we cannot work out which formatting rules to<br>
apply so we return the national significant number with no formatting<br>
applied.<br>
<br>
Arguments:<br>
numobj -- The phone number to be formatted.<br>
num_format -- The format the phone number should be formatted into<br>
<br>
Returns the formatted phone number.</tt></dd></dl>
<dl><dt><a name="-format_number_for_mobile_dialing"><strong>format_number_for_mobile_dialing</strong></a>(numobj, region_calling_from, with_formatting)</dt><dd><tt>Returns a number formatted in such a way that it can be dialed from a<br>
mobile phone in a specific region.<br>
<br>
If the number cannot be reached from the region (e.g. some countries block<br>
toll-free numbers from being called outside of the country), the method<br>
returns an empty string.<br>
<br>
Arguments:<br>
numobj -- The phone number to be formatted<br>
region_calling_from -- The region where the call is being placed.<br>
<br>
with_formatting -- whether the number should be returned with formatting<br>
symbols, such as spaces and dashes.<br>
<br>
Returns the formatted phone number.</tt></dd></dl>
<dl><dt><a name="-format_out_of_country_calling_number"><strong>format_out_of_country_calling_number</strong></a>(numobj, region_calling_from)</dt><dd><tt>Formats a phone number for out-of-country dialing purposes.<br>
<br>
If no region_calling_from is supplied, we format the number in its<br>
INTERNATIONAL format. If the country calling code is the same as that of<br>
the region where the number is from, then NATIONAL formatting will be<br>
applied.<br>
<br>
If the number itself has a country calling code of zero or an otherwise<br>
invalid country calling code, then we return the number with no formatting<br>
applied.<br>
<br>
Note this function takes care of the case for calling inside of NANPA and<br>
between Russia and Kazakhstan (who share the same country calling<br>
code). In those cases, no international prefix is used. For regions which<br>
have multiple international prefixes, the number in its INTERNATIONAL<br>
format will be returned instead.<br>
<br>
Arguments:<br>
numobj -- The phone number to be formatted<br>
region_calling_from -- The region where the call is being placed<br>
<br>
Returns the formatted phone number</tt></dd></dl>
<dl><dt><a name="-format_out_of_country_keeping_alpha_chars"><strong>format_out_of_country_keeping_alpha_chars</strong></a>(numobj, region_calling_from)</dt><dd><tt>Formats a phone number for out-of-country dialing purposes.<br>
<br>
Note that in this version, if the number was entered originally using<br>
alpha characters and this version of the number is stored in raw_input,<br>
this representation of the number will be used rather than the digit<br>
representation. Grouping information, as specified by characters such as<br>
"-" and " ", will be retained.<br>
<br>
Caveats:<br>
<br>
- This will not produce good results if the country calling code is both<br>
present in the raw input _and_ is the start of the national<br>
number. This is not a problem in the regions which typically use alpha<br>
numbers.<br>
<br>
- This will also not produce good results if the raw input has any<br>
grouping information within the first three digits of the national<br>
number, and if the function needs to strip preceding digits/words in<br>
the raw input before these digits. Normally people group the first<br>
three digits together so this is not a huge problem - and will be fixed<br>
if it proves to be so.<br>
<br>
Arguments:<br>
numobj -- The phone number that needs to be formatted.<br>
region_calling_from -- The region where the call is being placed.<br>
<br>
Returns the formatted phone number</tt></dd></dl>
<dl><dt><a name="-invalid_example_number"><strong>invalid_example_number</strong></a>(region_code)</dt><dd><tt>Gets an invalid number for the specified region.<br>
<br>
This is useful for unit-testing purposes, where you want to test what<br>
will happen with an invalid number. Note that the number that is<br>
returned will always be able to be parsed and will have the correct<br>
country code. It may also be a valid *short* number/code for this<br>
region. Validity checking such numbers is handled with shortnumberinfo.<br>
<br>
Arguments:<br>
region_code -- The region for which an example number is needed.<br>
<br>
<br>
Returns an invalid number for the specified region. Returns None when an<br>
unsupported region or the region 001 (Earth) is passed in.</tt></dd></dl>
<dl><dt><a name="-is_alpha_number"><strong>is_alpha_number</strong></a>(number)</dt><dd><tt>Checks if the number is a valid vanity (alpha) number such as 800<br>
MICROSOFT. A valid vanity number will start with at least 3 digits and<br>
will have three or more alpha characters. This does not do region-specific<br>
checks - to work out if this number is actually valid for a region, it<br>
should be parsed and methods such as <a href="#-is_possible_number_with_reason">is_possible_number_with_reason</a>() and<br>
<a href="#-is_valid_number">is_valid_number</a>() should be used.<br>
<br>
Arguments:<br>
number -- the number that needs to be checked<br>
<br>
Returns True if the number is a valid vanity number</tt></dd></dl>
<dl><dt><a name="-is_carrier_specific"><strong>is_carrier_specific</strong></a>(numobj)</dt><dd><tt>Given a valid short number, determines whether it is carrier-specific<br>
(however, nothing is implied about its validity). Carrier-specific numbers<br>
may connect to a different end-point, or not connect at all, depending<br>
on the user's carrier. If it is important that the number is valid, then<br>
its validity must first be checked using is_valid_short_number or<br>
is_valid_short_number_for_region.<br>
<br>
Arguments:<br>
numobj -- the valid short number to check<br>
<br>
Returns whether the short number is carrier-specific, assuming the input<br>
was a valid short number.</tt></dd></dl>
<dl><dt><a name="-is_carrier_specific_for_region"><strong>is_carrier_specific_for_region</strong></a>(numobj, region_dialing_from)</dt><dd><tt>Given a valid short number, determines whether it is carrier-specific when<br>
dialed from the given region (however, nothing is implied about its<br>
validity). Carrier-specific numbers may connect to a different end-point,<br>
or not connect at all, depending on the user's carrier. If it is important<br>
that the number is valid, then its validity must first be checked using<br>
isValidShortNumber or isValidShortNumberForRegion. Returns false if the<br>
number doesn't match the region provided.<br>
<br>
Arguments:<br>
numobj -- the valid short number to check<br>
region_dialing_from -- the region from which the number is dialed<br>
<br>
Returns whether the short number is carrier-specific, assuming the input<br>
was a valid short number.</tt></dd></dl>
<dl><dt><a name="-is_emergency_number"><strong>is_emergency_number</strong></a>(number, region_code)</dt><dd><tt>Returns true if the given number exactly matches an emergency service<br>
number in the given region.<br>
<br>
This method takes into account cases where the number might contain<br>
formatting, but doesn't allow additional digits to be appended. Note that<br>
<a href="#-is_emergency_number">is_emergency_number</a>(number, region) implies<br>
<a href="#-connects_to_emergency_number">connects_to_emergency_number</a>(number, region).<br>
<br>
Arguments:<br>
number -- The phone number to test.<br>
region_code -- The region where the phone number is being dialed.<br>
<br>
Returns if the number exactly matches an emergency services number in the<br>
given region.</tt></dd></dl>
<dl><dt><a name="-is_mobile_number_portable_region"><strong>is_mobile_number_portable_region</strong></a>(region_code)</dt><dd><tt>Returns true if the supplied region supports mobile number portability.<br>
Returns false for invalid, unknown or regions that don't support mobile<br>
number portability.<br>
<br>
Arguments:<br>
region_code -- the region for which we want to know whether it supports mobile number<br>
portability or not.</tt></dd></dl>
<dl><dt><a name="-is_nanpa_country"><strong>is_nanpa_country</strong></a>(region_code)</dt><dd><tt>Checks if this region is a NANPA region.<br>
<br>
Returns True if region_code is one of the regions under the North American<br>
Numbering Plan Administration (NANPA).</tt></dd></dl>
<dl><dt><a name="-is_number_geographical"><strong>is_number_geographical</strong></a>(numobj)</dt><dd><tt>Tests whether a phone number has a geographical association.<br>
<br>
It checks if the number is associated with a certain region in the country<br>
to which it belongs. Note that this doesn't verify if the number is<br>
actually in use.<br>
country_code -- the country calling code for which we want the mobile token</tt></dd></dl>
<dl><dt><a name="-is_number_match"><strong>is_number_match</strong></a>(num1, num2)</dt><dd><tt>Takes two phone numbers and compares them for equality.<br>
<br>
For example, the numbers +1 345 657 1234 and 657 1234 are a SHORT_NSN_MATCH.<br>
The numbers +1 345 657 1234 and 345 657 are a NO_MATCH.<br>
<br>
Arguments<br>
num1 -- First number <a href="builtins.html#object">object</a> or string to compare. Can contain formatting,<br>
and can have country calling code specified with + at the start.<br>
num2 -- Second number <a href="builtins.html#object">object</a> or string to compare. Can contain formatting,<br>
and can have country calling code specified with + at the start.<br>
<br>
Returns:<br>
- EXACT_MATCH if the country_code, NSN, presence of a leading zero for<br>
Italian numbers and any extension present are the same.<br>
- NSN_MATCH if either or both has no region specified, and the NSNs and<br>
extensions are the same.<br>
- SHORT_NSN_MATCH if either or both has no region specified, or the<br>
region specified is the same, and one NSN could be a shorter version of<br>
the other number. This includes the case where one has an extension<br>
specified, and the other does not.<br>
- NO_MATCH otherwise.</tt></dd></dl>
<dl><dt><a name="-is_number_type_geographical"><strong>is_number_type_geographical</strong></a>(num_type, country_code)</dt><dd><tt>Tests whether a phone number has a geographical association,<br>
as represented by its type and the country it belongs to.<br>
<br>
This version of isNumberGeographical exists since calculating the phone<br>
number type is expensive; if we have already done this, we don't want to<br>
do it again.</tt></dd></dl>
<dl><dt><a name="-is_possible_number"><strong>is_possible_number</strong></a>(numobj)</dt><dd><tt>Convenience wrapper around is_possible_number_with_reason.<br>
<br>
Instead of returning the reason for failure, this method returns true if<br>
the number is either a possible fully-qualified number (containing the area<br>
code and country code), or if the number could be a possible local number<br>
(with a country code, but missing an area code). Local numbers are<br>
considered possible if they could be possibly dialled in this format: if<br>
the area code is needed for a call to connect, the number is not considered<br>
possible without it.<br>
<br>
Arguments:<br>
numobj -- the number <a href="builtins.html#object">object</a> that needs to be checked<br>
<br>
Returns True if the number is possible</tt></dd></dl>
<dl><dt><a name="-is_possible_number_for_type"><strong>is_possible_number_for_type</strong></a>(numobj, numtype)</dt><dd><tt>Convenience wrapper around is_possible_number_for_type_with_reason.<br>
<br>
Instead of returning the reason for failure, this method returns true if<br>
the number is either a possible fully-qualified number (containing the area<br>
code and country code), or if the number could be a possible local number<br>
(with a country code, but missing an area code). Local numbers are<br>
considered possible if they could be possibly dialled in this format: if<br>
the area code is needed for a call to connect, the number is not considered<br>
possible without it.<br>
<br>
Arguments:<br>
numobj -- the number <a href="builtins.html#object">object</a> that needs to be checked<br>
numtype -- the type we are interested in<br>
<br>
Returns True if the number is possible</tt></dd></dl>
<dl><dt><a name="-is_possible_number_for_type_with_reason"><strong>is_possible_number_for_type_with_reason</strong></a>(numobj, numtype)</dt><dd><tt>Check whether a phone number is a possible number of a particular type.<br>
<br>
For types that don't exist in a particular region, this will return a result<br>
that isn't so useful; it is recommended that you use<br>
supported_types_for_region or supported_types_for_non_geo_entity<br>
respectively before calling this method to determine whether you should call<br>
it for this number at all.<br>
<br>
This provides a more lenient check than is_valid_number in the following sense:<br>
<br>
- It only checks the length of phone numbers. In particular, it doesn't<br>
check starting digits of the number.<br>
<br>
- For some numbers (particularly fixed-line), many regions have the<br>
concept of area code, which together with subscriber number constitute<br>
the national significant number. It is sometimes okay to dial only the<br>
subscriber number when dialing in the same area. This function will<br>
return IS_POSSIBLE_LOCAL_ONLY if the subscriber-number-only version is<br>
passed in. On the other hand, because is_valid_number validates using<br>
information on both starting digits (for fixed line numbers, that would<br>
most likely be area codes) and length (obviously includes the length of<br>
area codes for fixed line numbers), it will return false for the<br>
subscriber-number-only version.<br>
<br>
Arguments:<br>
numobj -- The number <a href="builtins.html#object">object</a> that needs to be checked<br>
numtype -- The type we are interested in<br>
<br>
Returns a value from <a href="#ValidationResult">ValidationResult</a> which indicates whether the number<br>
is possible</tt></dd></dl>
<dl><dt><a name="-is_possible_number_string"><strong>is_possible_number_string</strong></a>(number, region_dialing_from)</dt><dd><tt>Check whether a phone number string is a possible number.<br>
<br>
Takes a number in the form of a string, and the region where the number<br>
could be dialed from. It provides a more lenient check than<br>
is_valid_number; see <a href="#-is_possible_number_with_reason">is_possible_number_with_reason</a>() for details.<br>
<br>
This method first parses the number, then invokes is_possible_number with<br>
the resultant <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a>.<br>
<br>
Arguments:<br>
number -- The number that needs to be checked, in the form of a string.<br>
region_dialling_from -- The region that we are expecting the number to be<br>
dialed from. Note this is different from the region where the<br>
number belongs. For example, the number +1 650 253 0000 is a<br>
number that belongs to US. When written in this form, it can be<br>
dialed from any region. When it is written as 00 1 650 253 0000,<br>
it can be dialed from any region which uses an international<br>
dialling prefix of 00. When it is written as 650 253 0000, it<br>
can only be dialed from within the US, and when written as 253<br>
0000, it can only be dialed from within a smaller area in the US<br>
(Mountain View, CA, to be more specific).<br>
<br>
Returns True if the number is possible</tt></dd></dl>
<dl><dt><a name="-is_possible_number_with_reason"><strong>is_possible_number_with_reason</strong></a>(numobj)</dt></dl>
<dl><dt><a name="-is_possible_short_number"><strong>is_possible_short_number</strong></a>(numobj)</dt><dd><tt>Check whether a short number is a possible number.<br>
<br>
If a country calling code is shared by multiple regions, this returns True<br>
if it's possible in any of them. This provides a more lenient check than<br>
is_valid_short_number.<br>
<br>
Arguments:<br>
numobj -- the short number to check<br>
<br>
Return whether the number is a possible short number.</tt></dd></dl>
<dl><dt><a name="-is_possible_short_number_for_region"><strong>is_possible_short_number_for_region</strong></a>(short_numobj, region_dialing_from)</dt><dd><tt>Check whether a short number is a possible number when dialled from a<br>
region. This provides a more lenient check than<br>
is_valid_short_number_for_region.<br>
<br>
Arguments:<br>
short_numobj -- the short number to check as a <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a>.<br>
region_dialing_from -- the region from which the number is dialed<br>
<br>
Return whether the number is a possible short number.</tt></dd></dl>
<dl><dt><a name="-is_sms_service_for_region"><strong>is_sms_service_for_region</strong></a>(numobj, region_dialing_from)</dt><dd><tt>Given a valid short number, determines whether it is an SMS service<br>
(however, nothing is implied about its validity). An SMS service is where<br>
the primary or only intended usage is to receive and/or send text messages<br>
(SMSs). This includes MMS as MMS numbers downgrade to SMS if the other<br>
party isn't MMS-capable. If it is important that the number is valid, then<br>
its validity must first be checked using is_valid_short_number or<br>
is_valid_short_number_for_region. Returns False if the number doesn't<br>
match the region provided.<br>
<br>
Arguments:<br>
numobj -- the valid short number to check<br>
region_dialing_from -- the region from which the number is dialed<br>
<br>
Returns whether the short number is an SMS service in the provided region,<br>
assuming the input was a valid short number.</tt></dd></dl>
<dl><dt><a name="-is_valid_number"><strong>is_valid_number</strong></a>(numobj)</dt><dd><tt>Tests whether a phone number matches a valid pattern.<br>
<br>
Note this doesn't verify the number is actually in use, which is<br>
impossible to tell by just looking at a number itself. It only verifies<br>
whether the parsed, canonicalised number is valid: not whether a<br>
particular series of digits entered by the user is diallable from the<br>
region provided when parsing. For example, the number +41 (0) 78 927 2696<br>
can be parsed into a number with country code "41" and national<br>
significant number "789272696". This is valid, while the original string<br>
is not diallable.<br>
<br>
Arguments:<br>
numobj -- The phone number <a href="builtins.html#object">object</a> that we want to validate<br>
<br>
Returns a boolean that indicates whether the number is of a valid pattern.</tt></dd></dl>
<dl><dt><a name="-is_valid_number_for_region"><strong>is_valid_number_for_region</strong></a>(numobj, region_code)</dt><dd><tt>Tests whether a phone number is valid for a certain region.<br>
<br>
Note this doesn't verify the number is actually in use, which is<br>
impossible to tell by just looking at a number itself. If the country<br>
calling code is not the same as the country calling code for the region,<br>
this immediately exits with false. After this, the specific number pattern<br>
rules for the region are examined. This is useful for determining for<br>
example whether a particular number is valid for Canada, rather than just<br>
a valid NANPA number.<br>
<br>
Warning: In most cases, you want to use is_valid_number instead. For<br>
example, this method will mark numbers from British Crown dependencies<br>
such as the Isle of Man as invalid for the region "GB" (United Kingdom),<br>
since it has its own region code, "IM", which may be undesirable.<br>
<br>
Arguments:<br>
numobj -- The phone number <a href="builtins.html#object">object</a> that we want to validate.<br>
region_code -- The region that we want to validate the phone number for.<br>
<br>
Returns a boolean that indicates whether the number is of a valid pattern.</tt></dd></dl>
<dl><dt><a name="-is_valid_short_number"><strong>is_valid_short_number</strong></a>(numobj)</dt><dd><tt>Tests whether a short number matches a valid pattern.<br>
<br>
If a country calling code is shared by multiple regions, this returns True<br>
if it's valid in any of them. Note that this doesn't verify the number is<br>
actually in use, which is impossible to tell by just looking at the number<br>
itself. See is_valid_short_number_for_region for details.<br>
<br>
Arguments:<br>
numobj - the short number for which we want to test the validity<br>
<br>
Return whether the short number matches a valid pattern</tt></dd></dl>
<dl><dt><a name="-is_valid_short_number_for_region"><strong>is_valid_short_number_for_region</strong></a>(short_numobj, region_dialing_from)</dt><dd><tt>Tests whether a short number matches a valid pattern in a region.<br>
<br>
Note that this doesn't verify the number is actually in use, which is<br>
impossible to tell by just looking at the number itself.<br>
<br>
Arguments:<br>
short_numobj -- the short number to check as a <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a>.<br>
region_dialing_from -- the region from which the number is dialed<br>
<br>
Return whether the short number matches a valid pattern</tt></dd></dl>
<dl><dt><a name="-length_of_geographical_area_code"><strong>length_of_geographical_area_code</strong></a>(numobj)</dt><dd><tt>Return length of the geographical area code for a number.<br>
<br>
Gets the length of the geographical area code from the <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a><br>
passed in, so that clients could use it to split a national significant<br>
number into geographical area code and subscriber number. It works in such<br>
a way that the resultant subscriber number should be diallable, at least<br>
on some devices. An example of how this could be used:<br>
<br>
>>> import phonenumbers<br>
>>> numobj = phonenumbers.<a href="#-parse">parse</a>("16502530000", "US")<br>
>>> nsn = phonenumbers.<a href="#-national_significant_number">national_significant_number</a>(numobj)<br>
>>> ac_len = phonenumbers.<a href="#-length_of_geographical_area_code">length_of_geographical_area_code</a>(numobj)<br>
>>> if ac_len > 0:<br>
... area_code = nsn[:ac_len]<br>
... subscriber_number = nsn[ac_len:]<br>
... else:<br>
... area_code = ""<br>
... subscriber_number = nsn<br>
<br>
N.B.: area code is a very ambiguous concept, so the I18N team generally<br>
recommends against using it for most purposes, but recommends using the<br>
more general national_number instead. Read the following carefully before<br>
deciding to use this method:<br>
<br>
- geographical area codes change over time, and this method honors those<br>
changes; therefore, it doesn't guarantee the stability of the result it<br>
produces.<br>
- subscriber numbers may not be diallable from all devices (notably<br>
mobile devices, which typically require the full national_number to be<br>
dialled in most countries).<br>
- most non-geographical numbers have no area codes, including numbers<br>
from non-geographical entities.<br>
- some geographical numbers have no area codes.<br>
<br>
Arguments:<br>
numobj -- The <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a> to find the length of the area code form.<br>
<br>
Returns the length of area code of the <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a> passed in.</tt></dd></dl>
<dl><dt><a name="-length_of_national_destination_code"><strong>length_of_national_destination_code</strong></a>(numobj)</dt><dd><tt>Return length of the national destination code code for a number.<br>
<br>
Gets the length of the national destination code (NDC) from the<br>
<a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a> passed in, so that clients could use it to split a<br>
national significant number into NDC and subscriber number. The NDC of a<br>
phone number is normally the first group of digit(s) right after the<br>
country calling code when the number is formatted in the international<br>
format, if there is a subscriber number part that follows.<br>
<br>
N.B.: similar to an area code, not all numbers have an NDC!<br>
<br>
An example of how this could be used:<br>
<br>
>>> import phonenumbers<br>
>>> numobj = phonenumbers.<a href="#-parse">parse</a>("18002530000", "US")<br>
>>> nsn = phonenumbers.<a href="#-national_significant_number">national_significant_number</a>(numobj)<br>
>>> ndc_len = phonenumbers.<a href="#-length_of_national_destination_code">length_of_national_destination_code</a>(numobj)<br>
>>> if ndc_len > 0:<br>
... national_destination_code = nsn[:ndc_len]<br>
... subscriber_number = nsn[ndc_len:]<br>
... else:<br>
... national_destination_code = ""<br>
... subscriber_number = nsn<br>
<br>
Refer to the unittests to see the difference between this function and<br>
length_of_geographical_area_code.<br>
<br>
Arguments:<br>
numobj -- The <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a> to find the length of the NDC from.<br>
<br>
Returns the length of NDC of the <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a> passed in, which<br>
could be zero.</tt></dd></dl>
<dl><dt><a name="-national_significant_number"><strong>national_significant_number</strong></a>(numobj)</dt><dd><tt>Gets the national significant number of a phone number.<br>
<br>
Note that a national significant number doesn't contain a national prefix<br>
or any formatting.<br>
<br>
Arguments:<br>
numobj -- The <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a> for which the national significant number<br>
is needed.<br>
<br>
Returns the national significant number of the <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a> passed<br>
in.</tt></dd></dl>
<dl><dt><a name="-ndd_prefix_for_region"><strong>ndd_prefix_for_region</strong></a>(region_code, strip_non_digits)</dt><dd><tt>Returns the national dialling prefix for a specific region.<br>
<br>
For example, this would be 1 for the United States, and 0 for New<br>
Zealand. Set strip_non_digits to True to strip symbols like "~" (which<br>
indicates a wait for a dialling tone) from the prefix returned. If no<br>
national prefix is present, we return None.<br>
<br>
Warning: Do not use this method for do-your-own formatting - for some<br>
regions, the national dialling prefix is used only for certain types of<br>
numbers. Use the library's formatting functions to prefix the national<br>
prefix when required.<br>
<br>
Arguments:<br>
region_code -- The region that we want to get the dialling prefix for.<br>
strip_non_digits -- whether to strip non-digits from the national<br>
dialling prefix.<br>
<br>
Returns the dialling prefix for the region denoted by region_code.</tt></dd></dl>
<dl><dt><a name="-normalize_diallable_chars_only"><strong>normalize_diallable_chars_only</strong></a>(number)</dt><dd><tt>Normalizes a string of characters representing a phone number.<br>
<br>
This strips all characters which are not diallable on a mobile phone<br>
keypad (including all non-ASCII digits).<br>
<br>
Arguments:<br>
number -- a string of characters representing a phone number<br>
<br>
Returns the normalized string version of the phone number.</tt></dd></dl>
<dl><dt><a name="-normalize_digits_only"><strong>normalize_digits_only</strong></a>(number, keep_non_digits=False)</dt><dd><tt>Normalizes a string of characters representing a phone number.<br>
<br>
This converts wide-ascii and arabic-indic numerals to European numerals,<br>
and strips punctuation and alpha characters (optional).<br>
<br>
Arguments:<br>
number -- a string representing a phone number<br>
keep_non_digits -- whether to keep non-digits<br>
<br>
Returns the normalized string version of the phone number.</tt></dd></dl>
<dl><dt><a name="-number_type"><strong>number_type</strong></a>(numobj)</dt><dd><tt>Gets the type of a valid phone number.<br>
<br>
Arguments:<br>
numobj -- The <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a> that we want to know the type of.<br>
<br>
Returns the type of the phone number, as a <a href="#PhoneNumberType">PhoneNumberType</a> value;<br>
returns <a href="#PhoneNumberType">PhoneNumberType</a>.UNKNOWN if it is invalid.</tt></dd></dl>
<dl><dt><a name="-parse"><strong>parse</strong></a>(number, region=None, keep_raw_input=False, numobj=None, _check_region=True)</dt><dd><tt>Parse a string and return a corresponding <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a>.<br>
<br>
The method is quite lenient and looks for a number in the input text<br>
(raw input) and does not check whether the string is definitely only a<br>
phone number. To do this, it ignores punctuation and white-space, as<br>
well as any text before the number (e.g. a leading "Tel: ") and trims<br>
the non-number bits. It will accept a number in any format (E164,<br>
national, international etc), assuming it can be interpreted with the<br>
defaultRegion supplied. It also attempts to convert any alpha characters<br>
into digits if it thinks this is a vanity number of the type "1800<br>
MICROSOFT".<br>
<br>
This method will throw a <a href="#NumberParseException">NumberParseException</a> if the number is not<br>
considered to be a possible number. Note that validation of whether the<br>
number is actually a valid number for a particular region is not<br>
performed. This can be done separately with is_valid_number.<br>
<br>
Note this method canonicalizes the phone number such that different<br>
representations can be easily compared, no matter what form it was<br>
originally entered in (e.g. national, international). If you want to<br>
record context about the number being parsed, such as the raw input that<br>
was entered, how the country code was derived etc. then ensure<br>
keep_raw_input is set.<br>
<br>
Note if any new field is added to this method that should always be filled<br>
in, even when keep_raw_input is False, it should also be handled in the<br>
_copy_core_fields_only() function.<br>
<br>
Arguments:<br>
number -- The number that we are attempting to parse. This can<br>
contain formatting such as +, ( and -, as well as a phone<br>
number extension. It can also be provided in <a href="http://www.rfc-editor.org/rfc/rfc3966.txt">RFC3966</a> format.<br>
region -- The region that we are expecting the number to be from. This<br>
is only used if the number being parsed is not written in<br>
international format. The country_code for the number in<br>
this case would be stored as that of the default region<br>
supplied. If the number is guaranteed to start with a '+'<br>
followed by the country calling code, then None or<br>
UNKNOWN_REGION can be supplied.<br>
keep_raw_input -- Whether to populate the raw_input field of the<br>
<a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a> with number (as well as the<br>
country_code_source field).<br>
numobj -- An optional existing <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a> to receive the<br>
parsing results<br>
_check_region -- Whether to check the supplied region parameter;<br>
should always be True for external callers.<br>
<br>
Returns a <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a> filled with the parse number.<br>
<br>
Raises:<br>
<a href="#NumberParseException">NumberParseException</a> if the string is not considered to be a viable<br>
phone number (e.g. too few or too many digits) or if no default<br>
region was supplied and the number is not in international format<br>
(does not start with +).</tt></dd></dl>
<dl><dt><a name="-region_code_for_country_code"><strong>region_code_for_country_code</strong></a>(country_code)</dt><dd><tt>Returns the region code that matches a specific country calling code.<br>
<br>
In the case of no region code being found, UNKNOWN_REGION ('ZZ') will be<br>
returned. In the case of multiple regions, the one designated in the<br>
metadata as the "main" region for this calling code will be returned. If<br>
the country_code entered is valid but doesn't match a specific region<br>
(such as in the case of non-geographical calling codes like 800) the value<br>
"001" will be returned (corresponding to the value for World in the UN<br>
M.49 schema).</tt></dd></dl>
<dl><dt><a name="-region_code_for_number"><strong>region_code_for_number</strong></a>(numobj)</dt><dd><tt>Returns the region where a phone number is from.<br>
<br>
This could be used for geocoding at the region level. Only guarantees<br>
correct results for valid, full numbers (not short-codes, or invalid<br>
numbers).<br>
<br>
Arguments:<br>
numobj -- The phone number <a href="builtins.html#object">object</a> whose origin we want to know<br>
<br>
Returns the region where the phone number is from, or None if no region<br>
matches this calling code.</tt></dd></dl>
<dl><dt><a name="-region_codes_for_country_code"><strong>region_codes_for_country_code</strong></a>(country_code)</dt><dd><tt>Returns a list with the region codes that match the specific country calling code.<br>
<br>
For non-geographical country calling codes, the region code 001 is<br>
returned. Also, in the case of no region code being found, an empty<br>
list is returned.</tt></dd></dl>
<dl><dt><a name="-supported_calling_codes"><strong>supported_calling_codes</strong></a>()</dt><dd><tt>Returns all country calling codes the library has metadata for, covering<br>
both non-geographical entities (global network calling codes) and those<br>
used for geographical entities. This could be used to populate a drop-down<br>
box of country calling codes for a phone-number widget, for instance.<br>
<br>
Returns an unordered set of the country calling codes for every geographica<br>
and non-geographical entity the library supports.</tt></dd></dl>
<dl><dt><a name="-supported_types_for_non_geo_entity"><strong>supported_types_for_non_geo_entity</strong></a>(country_code)</dt><dd><tt>Returns the types for a country-code belonging to a non-geographical entity<br>
which the library has metadata for. Will not include FIXED_LINE_OR_MOBILE<br>
(if numbers for this non-geographical entity could be classified as<br>
FIXED_LINE_OR_MOBILE, both FIXED_LINE and MOBILE would be present) and<br>
UNKNOWN.<br>
<br>
No types will be returned for country calling codes that do not map to a<br>
known non-geographical entity.</tt></dd></dl>
<dl><dt><a name="-supported_types_for_region"><strong>supported_types_for_region</strong></a>(region_code)</dt><dd><tt>Returns the types for a given region which the library has metadata for.<br>
<br>
Will not include FIXED_LINE_OR_MOBILE (if numbers in this region could<br>
be classified as FIXED_LINE_OR_MOBILE, both FIXED_LINE and MOBILE would<br>
be present) and UNKNOWN.<br>
<br>
No types will be returned for invalid or unknown region codes.</tt></dd></dl>
<dl><dt><a name="-truncate_too_long_number"><strong>truncate_too_long_number</strong></a>(numobj)</dt><dd><tt>Truncate a number <a href="builtins.html#object">object</a> that is too long.<br>
<br>
Attempts to extract a valid number from a phone number that is too long<br>
to be valid, and resets the <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a> passed in to that valid<br>
version. If no valid number could be extracted, the <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a><br>
passed in will not be modified.<br>
<br>
Arguments:<br>
numobj -- A <a href="#PhoneNumber">PhoneNumber</a> <a href="builtins.html#object">object</a> which contains a number that is too long to<br>
be valid.<br>
<br>
Returns True if a valid phone number can be successfully extracted.</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>COUNTRY_CODES_FOR_NON_GEO_REGIONS</strong> = {800, 808, 870, 878, 881, 882, ...}<br>
<strong>COUNTRY_CODE_TO_REGION_CODE</strong> = {1: ('US', 'AG', 'AI', 'AS', 'BB', 'BM', 'BS', 'CA', 'DM', 'DO', 'GD', 'GU', 'JM', 'KN', 'KY', 'LC', 'MP', 'MS', 'PR', 'SX', ...), 7: ('RU', 'KZ'), 20: ('EG',), 27: ('ZA',), 30: ('GR',), 31: ('NL',), 32: ('BE',), 33: ('FR',), 34: ('ES',), 36: ('HU',), ...}<br>
<strong>NON_DIGITS_PATTERN</strong> = re.compile('(?:\\D+)')<br>
<strong>REGION_CODE_FOR_NON_GEO_ENTITY</strong> = '001'<br>
<strong>SUPPORTED_REGIONS</strong> = {'AC', 'AD', 'AE', 'AF', 'AG', 'AI', ...}<br>
<strong>SUPPORTED_SHORT_REGIONS</strong> = ['AC', 'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', ...]<br>
<strong>UNKNOWN_REGION</strong> = 'ZZ'<br>
<strong>__all__</strong> = ['PhoneNumber', 'CountryCodeSource', 'FrozenPhoneNumber', 'REGION_CODE_FOR_NON_GEO_ENTITY', 'NumberFormat', 'PhoneNumberDesc', 'PhoneMetadata', 'AsYouTypeFormatter', 'COUNTRY_CODE_TO_REGION_CODE', 'SUPPORTED_REGIONS', 'UNKNOWN_REGION', 'COUNTRY_CODES_FOR_NON_GEO_REGIONS', 'NON_DIGITS_PATTERN', 'MatchType', 'NumberParseException', 'PhoneNumberFormat', 'PhoneNumberType', 'ValidationResult', 'can_be_internationally_dialled', 'convert_alpha_characters_in_number', ...]</td></tr></table>
</body></html>
|