File: phonenumbers.util.html

package info (click to toggle)
python-phonenumbers 8.12.57-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 39,212 kB
  • sloc: python: 332,712; xml: 46,045; makefile: 143; java: 91
file content (151 lines) | stat: -rw-r--r-- 9,666 bytes parent folder | download | duplicates (2)
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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module phonenumbers.util</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>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="phonenumbers.html"><font color="#ffffff">phonenumbers</font></a>.util</strong></big></big></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/util.py">phonenumbers/util.py</a></font></td></tr></table>
    <p><tt>Python&nbsp;2.x/3.x&nbsp;compatibility&nbsp;utilities.<br>
&nbsp;<br>
This&nbsp;module&nbsp;defines&nbsp;a&nbsp;collection&nbsp;of&nbsp;functions&nbsp;that&nbsp;allow&nbsp;the&nbsp;same&nbsp;Python<br>
source&nbsp;code&nbsp;to&nbsp;be&nbsp;used&nbsp;in&nbsp;both&nbsp;Python&nbsp;2.x&nbsp;and&nbsp;Python&nbsp;3.x.<br>
&nbsp;<br>
&nbsp;-&nbsp;<a href="#-prnt">prnt</a>()&nbsp;prints&nbsp;its&nbsp;arguments&nbsp;to&nbsp;a&nbsp;file,&nbsp;with&nbsp;given&nbsp;separator&nbsp;and&nbsp;ending.<br>
&nbsp;-&nbsp;to_long()&nbsp;creates&nbsp;a&nbsp;(long)&nbsp;integer&nbsp;<a href="builtins.html#object">object</a>&nbsp;from&nbsp;its&nbsp;input&nbsp;parameter.<br>
&nbsp;-&nbsp;u()&nbsp;allows&nbsp;string&nbsp;literals&nbsp;involving&nbsp;non-ASCII&nbsp;characters&nbsp;to&nbsp;be<br>
&nbsp;&nbsp;&nbsp;used&nbsp;in&nbsp;both&nbsp;Python&nbsp;2.x&nbsp;/&nbsp;3.x,&nbsp;e.g.&nbsp;u("ā&nbsp;is&nbsp;a-with-macron")<br>
&nbsp;-&nbsp;unicod()&nbsp;forces&nbsp;its&nbsp;argument&nbsp;to&nbsp;a&nbsp;Unicode&nbsp;string.<br>
&nbsp;-&nbsp;<a href="#-rpr">rpr</a>()&nbsp;generates&nbsp;a&nbsp;representation&nbsp;of&nbsp;a&nbsp;string&nbsp;that&nbsp;can&nbsp;be&nbsp;parsed&nbsp;in&nbsp;either<br>
&nbsp;&nbsp;&nbsp;Python&nbsp;2.x&nbsp;or&nbsp;3.x,&nbsp;assuming&nbsp;use&nbsp;of&nbsp;the&nbsp;u()&nbsp;function&nbsp;above.<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;from&nbsp;.util&nbsp;import&nbsp;prnt,&nbsp;u,&nbsp;rpr<br>
&gt;&gt;&gt;&nbsp;<a href="#-prnt">prnt</a>("hello")<br>
hello<br>
&gt;&gt;&gt;&nbsp;<a href="#-prnt">prnt</a>("hello",&nbsp;"world")<br>
hello&nbsp;world<br>
&gt;&gt;&gt;&nbsp;<a href="#-prnt">prnt</a>("hello",&nbsp;"world",&nbsp;sep=":")<br>
hello:world<br>
&gt;&gt;&gt;&nbsp;<a href="#-prnt">prnt</a>("hello",&nbsp;"world",&nbsp;sep=":",&nbsp;end='!\n')<br>
hello:world!<br>
&gt;&gt;&gt;&nbsp;u('ā')&nbsp;==&nbsp;u('ā')<br>
True<br>
&gt;&gt;&gt;&nbsp;u('ā')&nbsp;==&nbsp;u('ā')<br>
True<br>
&gt;&gt;&gt;&nbsp;a_macron&nbsp;=&nbsp;u('ā')<br>
&gt;&gt;&gt;&nbsp;<a href="#-rpr">rpr</a>(a_macron)<br>
"u('\\u0101')"<br>
&gt;&gt;&gt;&nbsp;<a href="#-rpr">rpr</a>(u('abc'))&nbsp;==&nbsp;"'abc'"&nbsp;&nbsp;#&nbsp;In&nbsp;Python&nbsp;2,&nbsp;LHS&nbsp;is&nbsp;Unicode&nbsp;but&nbsp;RHS&nbsp;is&nbsp;string<br>
True<br>
&gt;&gt;&gt;&nbsp;<a href="#-rpr">rpr</a>("'")<br>
"'\\''"</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="builtins.html">builtins</a><br>
</td><td width="25%" valign=top><a href="sys.html">sys</a><br>
</td><td width="25%" valign=top></td><td width="25%" valign=top></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>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<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.util.html#ImmutableMixin">ImmutableMixin</a>
</font></dt><dt><font face="helvetica, arial"><a href="phonenumbers.util.html#UnicodeMixin">UnicodeMixin</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>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="ImmutableMixin">class <strong>ImmutableMixin</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Mixin&nbsp;class&nbsp;to&nbsp;make&nbsp;objects&nbsp;of&nbsp;subclasses&nbsp;immutable<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="ImmutableMixin-__delattr__"><strong>__delattr__</strong></a>(self, name)</dt><dd><tt>Implement&nbsp;delattr(self,&nbsp;name).</tt></dd></dl>

<dl><dt><a name="ImmutableMixin-__setattr__"><strong>__setattr__</strong></a>(self, name, value)</dt><dd><tt>Implement&nbsp;setattr(self,&nbsp;name,&nbsp;value).</tt></dd></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;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>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="UnicodeMixin">class <strong>UnicodeMixin</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Mixin&nbsp;class&nbsp;to&nbsp;define&nbsp;a&nbsp;__str__&nbsp;method&nbsp;in&nbsp;terms&nbsp;of&nbsp;__unicode__&nbsp;method<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="UnicodeMixin-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>Return&nbsp;str(self).</tt></dd></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</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>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
    
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-force_unicode"><strong>force_unicode</strong></a>(s)</dt><dd><tt>Force&nbsp;the&nbsp;argument&nbsp;to&nbsp;be&nbsp;a&nbsp;Unicode&nbsp;string,&nbsp;preserving&nbsp;None</tt></dd></dl>
 <dl><dt><a name="-mutating_method"><strong>mutating_method</strong></a>(func)</dt><dd><tt>Decorator&nbsp;for&nbsp;methods&nbsp;that&nbsp;are&nbsp;allowed&nbsp;to&nbsp;modify&nbsp;immutable&nbsp;objects</tt></dd></dl>
 <dl><dt><a name="-print3"><strong>print3</strong></a> = print(...)</dt><dd><tt>print(value,&nbsp;...,&nbsp;sep='&nbsp;',&nbsp;end='\n',&nbsp;file=sys.stdout,&nbsp;flush=False)<br>
&nbsp;<br>
Prints&nbsp;the&nbsp;values&nbsp;to&nbsp;a&nbsp;stream,&nbsp;or&nbsp;to&nbsp;sys.stdout&nbsp;by&nbsp;default.<br>
Optional&nbsp;keyword&nbsp;arguments:<br>
file:&nbsp;&nbsp;a&nbsp;file-like&nbsp;<a href="builtins.html#object">object</a>&nbsp;(stream);&nbsp;defaults&nbsp;to&nbsp;the&nbsp;current&nbsp;sys.stdout.<br>
sep:&nbsp;&nbsp;&nbsp;string&nbsp;inserted&nbsp;between&nbsp;values,&nbsp;default&nbsp;a&nbsp;space.<br>
end:&nbsp;&nbsp;&nbsp;string&nbsp;appended&nbsp;after&nbsp;the&nbsp;last&nbsp;value,&nbsp;default&nbsp;a&nbsp;newline.<br>
flush:&nbsp;whether&nbsp;to&nbsp;forcibly&nbsp;flush&nbsp;the&nbsp;stream.</tt></dd></dl>
 <dl><dt><a name="-prnt"><strong>prnt</strong></a>(*args, **kwargs)</dt></dl>
 <dl><dt><a name="-rpr"><strong>rpr</strong></a>(s)</dt><dd><tt>Create&nbsp;a&nbsp;representation&nbsp;of&nbsp;a&nbsp;Unicode&nbsp;string&nbsp;that&nbsp;can&nbsp;be&nbsp;used&nbsp;in&nbsp;both<br>
Python&nbsp;2&nbsp;and&nbsp;Python&nbsp;3k,&nbsp;allowing&nbsp;for&nbsp;use&nbsp;of&nbsp;the&nbsp;u()&nbsp;function</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>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
    
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>U_DASH</strong> = '-'<br>
<strong>U_EMPTY_STRING</strong> = ''<br>
<strong>U_PERCENT</strong> = '%'<br>
<strong>U_PLUS</strong> = '+'<br>
<strong>U_SEMICOLON</strong> = ';'<br>
<strong>U_SLASH</strong> = '/'<br>
<strong>U_SPACE</strong> = ' '<br>
<strong>U_STAR</strong> = '*'<br>
<strong>U_TILDE</strong> = '~'<br>
<strong>U_X_LOWER</strong> = 'x'<br>
<strong>U_X_UPPER</strong> = 'X'<br>
<strong>U_ZERO</strong> = '0'</td></tr></table>
</body></html>