<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="http://www.pythonblogs.com/styles/rss.css" type="text/css"?>
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>
 <channel>
  <title>PythonBlogs</title>
  <link>http://pythonblogs.pythonblogs.com/1_pythonblogs</link>
  <description></description>
  <pubDate>Thu, 29 Jul 2010 12:11:41 -0700</pubDate>
  <generator>http://www.lifetype.net</generator>
    <item>
   <title>PythonBlogs.com features Python syntax highlighting</title>
   <description>
    &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;http://pythonblogs.pythonblogs.com/plugins/plogeshi/styles/plogeshi.css&quot; /&gt;&lt;p&gt;
&lt;meta content=&quot;text/html; charset=utf-8&quot; http-equiv=&quot;CONTENT-TYPE&quot; /&gt;
&lt;title&gt;&lt;/title&gt;
&lt;meta content=&quot;OpenOffice.org 2.2  (Linux)&quot; name=&quot;GENERATOR&quot; /&gt;
&lt;meta content=&quot;20080603;18093100&quot; name=&quot;CREATED&quot; /&gt;
&lt;meta content=&quot;16010101;0&quot; name=&quot;CHANGED&quot; /&gt;
&lt;style type=&quot;text/css&quot;&gt;
&lt;/style&gt;
&lt;/p&gt;
&lt;p style=&quot;margin-bottom: 0in&quot;&gt;
Syntax highlighting for Python is now
available  at PythonBlogs. 
&lt;/p&gt;
&lt;p style=&quot;margin-bottom: 0in&quot;&gt;
To highlight a piece of code simply
enclose it by &amp;#91;code python&amp;#93; and &amp;#91;/code&amp;#93; tags:
&lt;/p&gt;
&lt;p style=&quot;margin-bottom: 0in&quot;&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style=&quot;margin-bottom: 0in&quot;&gt;
&lt;strong&gt;&amp;#91;code python&amp;#93;&lt;br /&gt;
// your Python code goes here&lt;br /&gt;
&amp;#91;/code&amp;#93;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style=&quot;margin-bottom: 0in&quot;&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style=&quot;margin-bottom: 0in&quot;&gt;
For example here is
Demo/pdist/client.py file from the standard Python distribution:
&lt;/p&gt;
&lt;p style=&quot;margin-bottom: 0in&quot;&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;RPC Client module.&quot;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw1&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;sys&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;import&lt;/span&gt; socket
&lt;span class=&quot;kw1&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;pickle&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;import&lt;/span&gt; __builtin__
&lt;span class=&quot;kw1&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;os&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;co1&quot;&gt;# Default verbosity (0 = silent, 1 = print connections, 2 = print requests too)&lt;/span&gt;
VERBOSE = &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw1&quot;&gt;class&lt;/span&gt; Client:
    &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;RPC Client class.  No need to derive a class -- it&#039;s fully generic.&quot;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;, address, verbose = VERBOSE&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._pre_init&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;address, verbose&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._post_init&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; _pre_init&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;, address, verbose = VERBOSE&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;address&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; == &lt;span class=&quot;kw1&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
            address = &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&#039;&#039;, address&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._address = address
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._verbose = verbose
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._verbose: &lt;span class=&quot;kw1&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&quot;Connecting to %s ...&quot;&lt;/span&gt; % &lt;span class=&quot;kw1&quot;&gt;repr&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;address&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._socket = socket.&lt;span class=&quot;me1&quot;&gt;socket&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;socket.&lt;span class=&quot;me1&quot;&gt;AF_INET&lt;/span&gt;, socket.&lt;span class=&quot;me1&quot;&gt;SOCK_STREAM&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._socket.&lt;span class=&quot;me1&quot;&gt;connect&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;address&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._verbose: &lt;span class=&quot;kw1&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&quot;Connected.&quot;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._lastid = &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;# Last id for which a reply has been received&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._nextid = &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;# Id of next request&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._replies = &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;# Unprocessed replies&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._rf = &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._socket.&lt;span class=&quot;me1&quot;&gt;makefile&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&#039;r&#039;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._wf = &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._socket.&lt;span class=&quot;me1&quot;&gt;makefile&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&#039;w&#039;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; _post_init&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._methods = &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._call&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&#039;.&lt;span class=&quot;me1&quot;&gt;methods&lt;/span&gt;&#039;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;__del__&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._close&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; _close&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._rf: &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._rf.&lt;span class=&quot;me1&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._rf = &lt;span class=&quot;kw1&quot;&gt;None&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._wf: &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._wf.&lt;span class=&quot;me1&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._wf = &lt;span class=&quot;kw1&quot;&gt;None&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._socket: &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._socket.&lt;span class=&quot;me1&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._socket = &lt;span class=&quot;kw1&quot;&gt;None&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;__getattr__&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;, name&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; name &lt;span class=&quot;kw1&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._methods:
            method = _stub&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;, name&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;setattr&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;, name, method&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;# XXX circular reference&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; method
        &lt;span class=&quot;kw1&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;AttributeError&lt;/span&gt;, name
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; _setverbose&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;, verbose&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._verbose = verbose
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; _call&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;, name, *args&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
        &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._vcall&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;name, args&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; _vcall&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;, name, args&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
        &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._recv&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._vsend&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;name, args&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; _send&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;, name, *args&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
        &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._vsend&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;name, args&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; _send_noreply&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;, name, *args&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
        &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._vsend&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;name, args, &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; _vsend_noreply&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;, name, args&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
        &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._vsend&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;name, args, &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; _vsend&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;, name, args, wantreply = &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
        &lt;span class=&quot;kw1&quot;&gt;id&lt;/span&gt; = &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._nextid
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._nextid = &lt;span class=&quot;kw1&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;not&lt;/span&gt; wantreply: &lt;span class=&quot;kw1&quot;&gt;id&lt;/span&gt; = -&lt;span class=&quot;kw1&quot;&gt;id&lt;/span&gt;
        request = &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;name, args, &lt;span class=&quot;kw1&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._verbose &amp;gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;: &lt;span class=&quot;kw1&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&quot;sending request: %s&quot;&lt;/span&gt; % &lt;span class=&quot;kw1&quot;&gt;repr&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;request&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        wp = &lt;span class=&quot;kw1&quot;&gt;pickle&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Pickler&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._wf&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        wp.&lt;span class=&quot;me1&quot;&gt;dump&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;request&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;id&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; _recv&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;, &lt;span class=&quot;kw1&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
        exception, value, rid = &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._vrecv&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; rid != &lt;span class=&quot;kw1&quot;&gt;id&lt;/span&gt;:
            &lt;span class=&quot;kw1&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;RuntimeError&lt;/span&gt;, &lt;span class=&quot;st0&quot;&gt;&quot;request/reply id mismatch: %d/%d&quot;&lt;/span&gt; % &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;id&lt;/span&gt;, rid&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; exception &lt;span class=&quot;kw1&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;None&lt;/span&gt;:
            &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; value
        x = exception
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;hasattr&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;__builtin__, exception&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
            x = &lt;span class=&quot;kw1&quot;&gt;getattr&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;__builtin__, exception&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;elif&lt;/span&gt; exception &lt;span class=&quot;kw1&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&#039;posix.&lt;span class=&quot;me1&quot;&gt;error&lt;/span&gt;&#039;, &#039;mac.&lt;span class=&quot;me1&quot;&gt;error&lt;/span&gt;&#039;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
            x = &lt;span class=&quot;kw1&quot;&gt;os&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;error&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; x == exception:
            exception = x
        &lt;span class=&quot;kw1&quot;&gt;raise&lt;/span&gt; exception, value
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; _vrecv&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;, &lt;span class=&quot;kw1&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._flush&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._replies.&lt;span class=&quot;me1&quot;&gt;has_key&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
            &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._verbose &amp;gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;: &lt;span class=&quot;kw1&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&quot;retrieving previous reply, id = %d&quot;&lt;/span&gt; % &lt;span class=&quot;kw1&quot;&gt;id&lt;/span&gt;
            reply = &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._replies&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;del&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._replies&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; reply
        aid = &lt;span class=&quot;kw1&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;:
            &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._verbose &amp;gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;: &lt;span class=&quot;kw1&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&quot;waiting for reply, id = %d&quot;&lt;/span&gt; % &lt;span class=&quot;kw1&quot;&gt;id&lt;/span&gt;
            rp = &lt;span class=&quot;kw1&quot;&gt;pickle&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Unpickler&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._rf&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
            reply = rp.&lt;span class=&quot;me1&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;del&lt;/span&gt; rp
            &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._verbose &amp;gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;: &lt;span class=&quot;kw1&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&quot;got reply: %s&quot;&lt;/span&gt; % &lt;span class=&quot;kw1&quot;&gt;repr&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;reply&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
            rid = reply&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;
            arid = &lt;span class=&quot;kw1&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;rid&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; arid == aid:
                &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._verbose &amp;gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;: &lt;span class=&quot;kw1&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&quot;got it&quot;&lt;/span&gt;
                &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; reply
            &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._replies&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;rid&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; = reply
            &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; arid &amp;gt; aid:
                &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._verbose &amp;gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;: &lt;span class=&quot;kw1&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&quot;got higher id, assume all ok&quot;&lt;/span&gt;
                &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;None&lt;/span&gt;, &lt;span class=&quot;kw1&quot;&gt;None&lt;/span&gt;, &lt;span class=&quot;kw1&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; _flush&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._wf.&lt;span class=&quot;me1&quot;&gt;flush&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&lt;span class=&quot;kw1&quot;&gt;from&lt;/span&gt; security &lt;span class=&quot;kw1&quot;&gt;import&lt;/span&gt; Security
&amp;nbsp;
&lt;span class=&quot;kw1&quot;&gt;class&lt;/span&gt; SecureClient&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Client, Security&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;, *args&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
        &lt;span class=&quot;kw1&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;string&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;apply&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._pre_init, args&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        Security.__init__&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._wf.&lt;span class=&quot;me1&quot;&gt;flush&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        line = &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._rf.&lt;span class=&quot;me1&quot;&gt;readline&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        challenge = &lt;span class=&quot;kw1&quot;&gt;string&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;atoi&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;string&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;strip&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;line&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        response = &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._encode_challenge&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;challenge&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        line = &lt;span class=&quot;kw1&quot;&gt;repr&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;long&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;response&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; line&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;-&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;in&lt;/span&gt; &#039;Ll&#039;: line = line&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;:-&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._wf.&lt;span class=&quot;me1&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;line   &#039;\n&#039;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._wf.&lt;span class=&quot;me1&quot;&gt;flush&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._post_init&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw1&quot;&gt;class&lt;/span&gt; _stub:
    &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Helper class for Client -- each instance serves as a method of the client.&quot;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;, client, name&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._client = client
        &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._name = name
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;__call__&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;, *args&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
        &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._client._vcall&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;._name, args&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;
&lt;/p&gt;
   </description>
   <link>http://pythonblogs.pythonblogs.com/1_pythonblogs/archive/19_pythonblogscom_features_python_syntax_highlighting.html</link>
   <comments>http://pythonblogs.pythonblogs.com/1_pythonblogs/archive/19_pythonblogscom_features_python_syntax_highlighting.html</comments>
   <guid>http://pythonblogs.pythonblogs.com/1_pythonblogs/archive/19_pythonblogscom_features_python_syntax_highlighting.html</guid>
      <dc:creator>pythonblogs</dc:creator>
      
    <category>General</category>
         <pubDate>Tue, 03 Jun 2008 16:54:48 -0700</pubDate>
   <source url="http://pythonblogs.pythonblogs.com/1_pythonblogs/feeds/rss20">PythonBlogs</source>
     </item>
    <item>
   <title>PythonBlogs.com Grand Opening!</title>
   <description>
    &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;http://pythonblogs.pythonblogs.com/plugins/plogeshi/styles/plogeshi.css&quot; /&gt;&lt;p&gt;
PythonBlogs.com is open for free registration!
&lt;/p&gt;
&lt;p&gt;
Get your space at PythonBlogs.com today!
&lt;/p&gt;
&lt;p&gt;
&lt;a href=&quot;http://www.pythonblogs.com/summary.php?op=Register&amp;amp;start=1&quot; title=&quot;Python Blogs Registration&quot;&gt;Register&lt;/a&gt;&amp;nbsp; &amp;nbsp;
&lt;/p&gt;
   </description>
   <link>http://pythonblogs.pythonblogs.com/1_pythonblogs/archive/1_pythonblogscom_grand_opening.html</link>
   <comments>http://pythonblogs.pythonblogs.com/1_pythonblogs/archive/1_pythonblogscom_grand_opening.html</comments>
   <guid>http://pythonblogs.pythonblogs.com/1_pythonblogs/archive/1_pythonblogscom_grand_opening.html</guid>
      <dc:creator>pythonblogs</dc:creator>
      
    <category>General</category>
         <pubDate>Fri, 30 May 2008 21:21:40 -0700</pubDate>
   <source url="http://pythonblogs.pythonblogs.com/1_pythonblogs/feeds/rss20">PythonBlogs</source>
     </item>
   </channel>
</rss>