Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="whatsnew24.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="whatsnew24.html" title='What's New in Python 2.4' /> | |
8 | <link rel='contents' href='contents.html' title="Contents" /> | |
9 | <link rel='last' href='about.html' title='About this document...' /> | |
10 | <link rel='help' href='about.html' title='About this document...' /> | |
11 | <link rel="next" href="node11.html" /> | |
12 | <link rel="prev" href="node9.html" /> | |
13 | <link rel="parent" href="whatsnew24.html" /> | |
14 | <link rel="next" href="node11.html" /> | |
15 | <meta name='aesop' content='information' /> | |
16 | <title>9 PEP 328: Multi-line Imports</title> | |
17 | </head> | |
18 | <body> | |
19 | <DIV CLASS="navigation"> | |
20 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
21 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
22 | <tr> | |
23 | <td class='online-navigation'><a rel="prev" title="8 PEP 327: Decimal" | |
24 | href="node9.html"><img src='../icons/previous.png' | |
25 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
26 | <td class='online-navigation'><a rel="parent" title="What's New in Python" | |
27 | href="whatsnew24.html"><img src='../icons/up.png' | |
28 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
29 | <td class='online-navigation'><a rel="next" title="10 PEP 331: Locale-Independent" | |
30 | href="node11.html"><img src='../icons/next.png' | |
31 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
32 | <td align="center" width="100%">What's New in Python 2.4</td> | |
33 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
34 | href="contents.html"><img src='../icons/contents.png' | |
35 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
36 | <td class='online-navigation'><img src='../icons/blank.png' | |
37 | border='0' height='32' alt='' width='32' /></td> | |
38 | <td class='online-navigation'><img src='../icons/blank.png' | |
39 | border='0' height='32' alt='' width='32' /></td> | |
40 | </tr></table> | |
41 | <div class='online-navigation'> | |
42 | <b class="navlabel">Previous:</b> | |
43 | <a class="sectref" rel="prev" href="node9.html">8 PEP 327: Decimal</A> | |
44 | <b class="navlabel">Up:</b> | |
45 | <a class="sectref" rel="parent" href="whatsnew24.html">What's New in Python</A> | |
46 | <b class="navlabel">Next:</b> | |
47 | <a class="sectref" rel="next" href="node11.html">10 PEP 331: Locale-Independent</A> | |
48 | </div> | |
49 | <hr /></div> | |
50 | </DIV> | |
51 | <!--End of Navigation Panel--> | |
52 | ||
53 | <H1><A NAME="SECTION0001000000000000000000"> | |
54 | 9 PEP 328: Multi-line Imports</A> | |
55 | </H1> | |
56 | ||
57 | <P> | |
58 | One language change is a small syntactic tweak aimed at making it | |
59 | easier to import many names from a module. In a | |
60 | <code>from <var>module</var> import <var>names</var></code> statement, | |
61 | <var>names</var> is a sequence of names separated by commas. If the sequence is | |
62 | very long, you can either write multiple imports from the same module, | |
63 | or you can use backslashes to escape the line endings like this: | |
64 | ||
65 | <P> | |
66 | <div class="verbatim"><pre> | |
67 | from SimpleXMLRPCServer import SimpleXMLRPCServer,\ | |
68 | SimpleXMLRPCRequestHandler,\ | |
69 | CGIXMLRPCRequestHandler,\ | |
70 | resolve_dotted_attribute | |
71 | </pre></div> | |
72 | ||
73 | <P> | |
74 | The syntactic change in Python 2.4 simply allows putting the names | |
75 | within parentheses. Python ignores newlines within a parenthesized | |
76 | expression, so the backslashes are no longer needed: | |
77 | ||
78 | <P> | |
79 | <div class="verbatim"><pre> | |
80 | from SimpleXMLRPCServer import (SimpleXMLRPCServer, | |
81 | SimpleXMLRPCRequestHandler, | |
82 | CGIXMLRPCRequestHandler, | |
83 | resolve_dotted_attribute) | |
84 | </pre></div> | |
85 | ||
86 | <P> | |
87 | The PEP also proposes that all <tt class="keyword">import</tt> statements be absolute | |
88 | imports, with a leading "<tt class="samp">.</tt>" character to indicate a relative | |
89 | import. This part of the PEP is not yet implemented, and will have to | |
90 | wait for Python 2.5 or some other future version. | |
91 | ||
92 | <P> | |
93 | <div class="seealso"> | |
94 | <p class="heading">See Also:</p> | |
95 | ||
96 | <dl compact="compact" class="seerfc"> | |
97 | <dt><a href="http://www.python.org/peps/pep-0328.html" | |
98 | title="Imports: Multi-Line and Absolute/Relative" | |
99 | >PEP 328, <em>Imports: Multi-Line and Absolute/Relative</em></a> | |
100 | <dd>Written by Aahz. Multi-line imports were implemented by | |
101 | Dima Dorfman. | |
102 | </dl> | |
103 | </div> | |
104 | ||
105 | <P> | |
106 | ||
107 | <DIV CLASS="navigation"> | |
108 | <div class='online-navigation'> | |
109 | <p></p><hr /> | |
110 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
111 | <tr> | |
112 | <td class='online-navigation'><a rel="prev" title="8 PEP 327: Decimal" | |
113 | href="node9.html"><img src='../icons/previous.png' | |
114 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
115 | <td class='online-navigation'><a rel="parent" title="What's New in Python" | |
116 | href="whatsnew24.html"><img src='../icons/up.png' | |
117 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
118 | <td class='online-navigation'><a rel="next" title="10 PEP 331: Locale-Independent" | |
119 | href="node11.html"><img src='../icons/next.png' | |
120 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
121 | <td align="center" width="100%">What's New in Python 2.4</td> | |
122 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
123 | href="contents.html"><img src='../icons/contents.png' | |
124 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
125 | <td class='online-navigation'><img src='../icons/blank.png' | |
126 | border='0' height='32' alt='' width='32' /></td> | |
127 | <td class='online-navigation'><img src='../icons/blank.png' | |
128 | border='0' height='32' alt='' width='32' /></td> | |
129 | </tr></table> | |
130 | <div class='online-navigation'> | |
131 | <b class="navlabel">Previous:</b> | |
132 | <a class="sectref" rel="prev" href="node9.html">8 PEP 327: Decimal</A> | |
133 | <b class="navlabel">Up:</b> | |
134 | <a class="sectref" rel="parent" href="whatsnew24.html">What's New in Python</A> | |
135 | <b class="navlabel">Next:</b> | |
136 | <a class="sectref" rel="next" href="node11.html">10 PEP 331: Locale-Independent</A> | |
137 | </div> | |
138 | </div> | |
139 | <hr /> | |
140 | <span class="release-info">Release 1.01.</span> | |
141 | </DIV> | |
142 | <!--End of Navigation Panel--> | |
143 | <ADDRESS> | |
144 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
145 | </ADDRESS> | |
146 | </BODY> | |
147 | </HTML> |