title
stringlengths
10
172
question_id
int64
469
40.1M
question_body
stringlengths
22
48.2k
question_score
int64
-44
5.52k
question_date
stringlengths
20
20
answer_id
int64
497
40.1M
answer_body
stringlengths
18
33.9k
answer_score
int64
-38
8.38k
answer_date
stringlengths
20
20
tags
list
python postgres cursor timestamp issue
655,125
<p>I am somewhat new to transactional databases and have come across an issue I am trying to understand. </p> <p>I have created a simple demonstration where a database connection is stored inside each of the 5 threads created by cherrypy. I have a method that displays a table of timestamps stored in the database and a button to add a new record of time stamps.</p> <p>the table has 2 fields, one for the datetime.datetime.now() timestamp passed by python and one for the database timestamp set to default NOW().</p> <pre><code> CREATE TABLE test (given_time timestamp, default_time timestamp DEFAULT NOW()); </code></pre> I have 2 methods that interact with the database. The first will create a new cursor, insert a new given_timestamp, commit the cursor, and return to the index page. The second method will create a new cursor, select the 10 most recent timestamps and return those to the caller. <pre><code> import sys import datetime import psycopg2 import cherrypy def connect(thread_index): # Create a connection and store it in the current thread cherrypy.thread_data.db = psycopg2.connect('dbname=timestamps') # Tell CherryPy to call "connect" for each thread, when it starts up cherrypy.engine.subscribe('start_thread', connect) class Root: @cherrypy.expose def index(self): html = [] html.append("&lt;html>&lt;body>") html.append("&lt;table border=1>&lt;thead>") html.append("&lt;tr>&lt;td>Given Time&lt;/td>&lt;td>Default Time&lt;/td>&lt;/tr>") html.append("&lt;/thead>&lt;tbody>") for given, default in self.get_timestamps(): html.append("&lt;tr>&lt;td>%s&lt;td>%s" % (given, default)) html.append("&lt;/tbody>") html.append("&lt;/table>") html.append("&lt;form action='add_timestamp' method='post'>") html.append("&lt;input type='submit' value='Add Timestamp'/>") html.append("&lt;/form>") html.append("&lt;/body>&lt;/html>") return "\n".join(html) @cherrypy.expose def add_timestamp(self): c = cherrypy.thread_data.db.cursor() now = datetime.datetime.now() c.execute("insert into test (given_time) values ('%s')" % now) c.connection.commit() c.close() raise cherrypy.HTTPRedirect('/') def get_timestamps(self): c = cherrypy.thread_data.db.cursor() c.execute("select * from test order by given_time desc limit 10") records = c.fetchall() c.close() return records if __name__ == '__main__': cherrypy.config.update({'server.socket_host': '0.0.0.0', 'server.socket_port': 8081, 'server.thread_pool': 5, 'tools.log_headers.on': False, }) cherrypy.quickstart(Root()) </code></pre> I would expect the given_time and default_time timestamps to be only a few microseconds off from each other. However I am getting some strange behavior. If I add timestamps every few seconds, the default_time is not a few microseconds off from the given_time, but is usually a few microseconds off from the *previous* given_time. <pre> Given Time Default Time 2009-03-18 09:31:30.725017 2009-03-18 09:31:25.218871 2009-03-18 09:31:25.198022 2009-03-18 09:31:17.642010 2009-03-18 09:31:17.622439 2009-03-18 09:31:08.266720 2009-03-18 09:31:08.246084 2009-03-18 09:31:01.970120 2009-03-18 09:31:01.950780 2009-03-18 09:30:53.571090 2009-03-18 09:30:53.550952 2009-03-18 09:30:47.260795 2009-03-18 09:30:47.239150 2009-03-18 09:30:41.177318 2009-03-18 09:30:41.151950 2009-03-18 09:30:36.005037 2009-03-18 09:30:35.983541 2009-03-18 09:30:31.666679 2009-03-18 09:30:31.649717 2009-03-18 09:30:28.319693 </pre> <p>Yet, if I add a new timestamp about once a minute, both the given_time and default_time are only a few microseconds off as expected. However, after submitting the 6th timestamp (the number of threads + 1) the default_time is a few microseconds off from the first given_time timestamp.</p> <pre> Given Time Default Time 2009-03-18 09:38:15.906788 2009-03-18 09:33:58.839075 2009-03-18 09:37:19.520227 2009-03-18 09:37:19.520293 2009-03-18 09:36:04.744987 2009-03-18 09:36:04.745039 2009-03-18 09:35:05.958962 2009-03-18 09:35:05.959053 2009-03-18 09:34:10.961227 2009-03-18 09:34:10.961298 2009-03-18 09:33:58.822138 2009-03-18 09:33:55.423485 </pre> <p>Even though I am explicitly closing the cursor after each use, it appears that the previous cursor is still being reused. How is that possible if I am closing the cursor after I'm done with it and creating a new cursor each time? Can someone please explain what is going on here?</p> <p><strong>Closer to an answer:</strong></p> <p>I've added a cursor.connection.commit() to the get_timestamps method and that now gives me accurate data with the timestamps. Can anyone explain why I could need to call cursor.connection.commit() when all I am doing is a select? I am guessing that every time I get a cursor, a transaction begins (or continues with an existing transaction unit it gets committed). Is there a better way to do this or am I stuck committing every time I get a cursor regardless of what I do with that cursor?</p>
5
2009-03-17T16:57:23Z
655,193
<p>Try calling c.close() as described in the module documentation: <a href="http://tools.cherrypy.org/wiki/Databases" rel="nofollow">http://tools.cherrypy.org/wiki/Databases</a></p> <pre><code>def add_timestamp(self): c = cherrypy.thread_data.db.cursor() now = datetime.datetime.now() c.execute("insert into test (given_time) values ('%s')" % now) c.connection.commit() c.close() raise cherrypy.HTTPRedirect('/') def get_timestamps(self): c = cherrypy.thread_data.db.cursor() c.execute("select * from test order by given_time desc limit 10") records = c.fetchall() c.close() return records </code></pre>
3
2009-03-17T17:12:27Z
[ "python", "postgresql", "cherrypy" ]
python postgres cursor timestamp issue
655,125
<p>I am somewhat new to transactional databases and have come across an issue I am trying to understand. </p> <p>I have created a simple demonstration where a database connection is stored inside each of the 5 threads created by cherrypy. I have a method that displays a table of timestamps stored in the database and a button to add a new record of time stamps.</p> <p>the table has 2 fields, one for the datetime.datetime.now() timestamp passed by python and one for the database timestamp set to default NOW().</p> <pre><code> CREATE TABLE test (given_time timestamp, default_time timestamp DEFAULT NOW()); </code></pre> I have 2 methods that interact with the database. The first will create a new cursor, insert a new given_timestamp, commit the cursor, and return to the index page. The second method will create a new cursor, select the 10 most recent timestamps and return those to the caller. <pre><code> import sys import datetime import psycopg2 import cherrypy def connect(thread_index): # Create a connection and store it in the current thread cherrypy.thread_data.db = psycopg2.connect('dbname=timestamps') # Tell CherryPy to call "connect" for each thread, when it starts up cherrypy.engine.subscribe('start_thread', connect) class Root: @cherrypy.expose def index(self): html = [] html.append("&lt;html>&lt;body>") html.append("&lt;table border=1>&lt;thead>") html.append("&lt;tr>&lt;td>Given Time&lt;/td>&lt;td>Default Time&lt;/td>&lt;/tr>") html.append("&lt;/thead>&lt;tbody>") for given, default in self.get_timestamps(): html.append("&lt;tr>&lt;td>%s&lt;td>%s" % (given, default)) html.append("&lt;/tbody>") html.append("&lt;/table>") html.append("&lt;form action='add_timestamp' method='post'>") html.append("&lt;input type='submit' value='Add Timestamp'/>") html.append("&lt;/form>") html.append("&lt;/body>&lt;/html>") return "\n".join(html) @cherrypy.expose def add_timestamp(self): c = cherrypy.thread_data.db.cursor() now = datetime.datetime.now() c.execute("insert into test (given_time) values ('%s')" % now) c.connection.commit() c.close() raise cherrypy.HTTPRedirect('/') def get_timestamps(self): c = cherrypy.thread_data.db.cursor() c.execute("select * from test order by given_time desc limit 10") records = c.fetchall() c.close() return records if __name__ == '__main__': cherrypy.config.update({'server.socket_host': '0.0.0.0', 'server.socket_port': 8081, 'server.thread_pool': 5, 'tools.log_headers.on': False, }) cherrypy.quickstart(Root()) </code></pre> I would expect the given_time and default_time timestamps to be only a few microseconds off from each other. However I am getting some strange behavior. If I add timestamps every few seconds, the default_time is not a few microseconds off from the given_time, but is usually a few microseconds off from the *previous* given_time. <pre> Given Time Default Time 2009-03-18 09:31:30.725017 2009-03-18 09:31:25.218871 2009-03-18 09:31:25.198022 2009-03-18 09:31:17.642010 2009-03-18 09:31:17.622439 2009-03-18 09:31:08.266720 2009-03-18 09:31:08.246084 2009-03-18 09:31:01.970120 2009-03-18 09:31:01.950780 2009-03-18 09:30:53.571090 2009-03-18 09:30:53.550952 2009-03-18 09:30:47.260795 2009-03-18 09:30:47.239150 2009-03-18 09:30:41.177318 2009-03-18 09:30:41.151950 2009-03-18 09:30:36.005037 2009-03-18 09:30:35.983541 2009-03-18 09:30:31.666679 2009-03-18 09:30:31.649717 2009-03-18 09:30:28.319693 </pre> <p>Yet, if I add a new timestamp about once a minute, both the given_time and default_time are only a few microseconds off as expected. However, after submitting the 6th timestamp (the number of threads + 1) the default_time is a few microseconds off from the first given_time timestamp.</p> <pre> Given Time Default Time 2009-03-18 09:38:15.906788 2009-03-18 09:33:58.839075 2009-03-18 09:37:19.520227 2009-03-18 09:37:19.520293 2009-03-18 09:36:04.744987 2009-03-18 09:36:04.745039 2009-03-18 09:35:05.958962 2009-03-18 09:35:05.959053 2009-03-18 09:34:10.961227 2009-03-18 09:34:10.961298 2009-03-18 09:33:58.822138 2009-03-18 09:33:55.423485 </pre> <p>Even though I am explicitly closing the cursor after each use, it appears that the previous cursor is still being reused. How is that possible if I am closing the cursor after I'm done with it and creating a new cursor each time? Can someone please explain what is going on here?</p> <p><strong>Closer to an answer:</strong></p> <p>I've added a cursor.connection.commit() to the get_timestamps method and that now gives me accurate data with the timestamps. Can anyone explain why I could need to call cursor.connection.commit() when all I am doing is a select? I am guessing that every time I get a cursor, a transaction begins (or continues with an existing transaction unit it gets committed). Is there a better way to do this or am I stuck committing every time I get a cursor regardless of what I do with that cursor?</p>
5
2009-03-17T16:57:23Z
663,239
<p>I have added a commit to the method that selects the timestamps and that has solved the problem. </p> <pre><code> def get_timestamps(self): c = cherrypy.thread_data.db.cursor() c.execute("select * from test order by given_time desc limit 10") records = c.fetchall() c.connection.commit() # Adding this line fixes the timestamp issue c.close() return records </code></pre> <p>Can anyone explain why I would need to call cursor.connection.commit() when all I'm doing is a select?</p>
0
2009-03-19T17:43:58Z
[ "python", "postgresql", "cherrypy" ]
python postgres cursor timestamp issue
655,125
<p>I am somewhat new to transactional databases and have come across an issue I am trying to understand. </p> <p>I have created a simple demonstration where a database connection is stored inside each of the 5 threads created by cherrypy. I have a method that displays a table of timestamps stored in the database and a button to add a new record of time stamps.</p> <p>the table has 2 fields, one for the datetime.datetime.now() timestamp passed by python and one for the database timestamp set to default NOW().</p> <pre><code> CREATE TABLE test (given_time timestamp, default_time timestamp DEFAULT NOW()); </code></pre> I have 2 methods that interact with the database. The first will create a new cursor, insert a new given_timestamp, commit the cursor, and return to the index page. The second method will create a new cursor, select the 10 most recent timestamps and return those to the caller. <pre><code> import sys import datetime import psycopg2 import cherrypy def connect(thread_index): # Create a connection and store it in the current thread cherrypy.thread_data.db = psycopg2.connect('dbname=timestamps') # Tell CherryPy to call "connect" for each thread, when it starts up cherrypy.engine.subscribe('start_thread', connect) class Root: @cherrypy.expose def index(self): html = [] html.append("&lt;html>&lt;body>") html.append("&lt;table border=1>&lt;thead>") html.append("&lt;tr>&lt;td>Given Time&lt;/td>&lt;td>Default Time&lt;/td>&lt;/tr>") html.append("&lt;/thead>&lt;tbody>") for given, default in self.get_timestamps(): html.append("&lt;tr>&lt;td>%s&lt;td>%s" % (given, default)) html.append("&lt;/tbody>") html.append("&lt;/table>") html.append("&lt;form action='add_timestamp' method='post'>") html.append("&lt;input type='submit' value='Add Timestamp'/>") html.append("&lt;/form>") html.append("&lt;/body>&lt;/html>") return "\n".join(html) @cherrypy.expose def add_timestamp(self): c = cherrypy.thread_data.db.cursor() now = datetime.datetime.now() c.execute("insert into test (given_time) values ('%s')" % now) c.connection.commit() c.close() raise cherrypy.HTTPRedirect('/') def get_timestamps(self): c = cherrypy.thread_data.db.cursor() c.execute("select * from test order by given_time desc limit 10") records = c.fetchall() c.close() return records if __name__ == '__main__': cherrypy.config.update({'server.socket_host': '0.0.0.0', 'server.socket_port': 8081, 'server.thread_pool': 5, 'tools.log_headers.on': False, }) cherrypy.quickstart(Root()) </code></pre> I would expect the given_time and default_time timestamps to be only a few microseconds off from each other. However I am getting some strange behavior. If I add timestamps every few seconds, the default_time is not a few microseconds off from the given_time, but is usually a few microseconds off from the *previous* given_time. <pre> Given Time Default Time 2009-03-18 09:31:30.725017 2009-03-18 09:31:25.218871 2009-03-18 09:31:25.198022 2009-03-18 09:31:17.642010 2009-03-18 09:31:17.622439 2009-03-18 09:31:08.266720 2009-03-18 09:31:08.246084 2009-03-18 09:31:01.970120 2009-03-18 09:31:01.950780 2009-03-18 09:30:53.571090 2009-03-18 09:30:53.550952 2009-03-18 09:30:47.260795 2009-03-18 09:30:47.239150 2009-03-18 09:30:41.177318 2009-03-18 09:30:41.151950 2009-03-18 09:30:36.005037 2009-03-18 09:30:35.983541 2009-03-18 09:30:31.666679 2009-03-18 09:30:31.649717 2009-03-18 09:30:28.319693 </pre> <p>Yet, if I add a new timestamp about once a minute, both the given_time and default_time are only a few microseconds off as expected. However, after submitting the 6th timestamp (the number of threads + 1) the default_time is a few microseconds off from the first given_time timestamp.</p> <pre> Given Time Default Time 2009-03-18 09:38:15.906788 2009-03-18 09:33:58.839075 2009-03-18 09:37:19.520227 2009-03-18 09:37:19.520293 2009-03-18 09:36:04.744987 2009-03-18 09:36:04.745039 2009-03-18 09:35:05.958962 2009-03-18 09:35:05.959053 2009-03-18 09:34:10.961227 2009-03-18 09:34:10.961298 2009-03-18 09:33:58.822138 2009-03-18 09:33:55.423485 </pre> <p>Even though I am explicitly closing the cursor after each use, it appears that the previous cursor is still being reused. How is that possible if I am closing the cursor after I'm done with it and creating a new cursor each time? Can someone please explain what is going on here?</p> <p><strong>Closer to an answer:</strong></p> <p>I've added a cursor.connection.commit() to the get_timestamps method and that now gives me accurate data with the timestamps. Can anyone explain why I could need to call cursor.connection.commit() when all I am doing is a select? I am guessing that every time I get a cursor, a transaction begins (or continues with an existing transaction unit it gets committed). Is there a better way to do this or am I stuck committing every time I get a cursor regardless of what I do with that cursor?</p>
5
2009-03-17T16:57:23Z
665,236
<p>To address the question posed by your most recent edits:</p> <p>In PostgreSQL, <code>NOW()</code> is <em>not</em> the current time, but the time <em>at the start of the current transaction</em>. Psycopg2 is probably starting a transaction implicitly for you, and since the transaction is never closed (by a commit or otherwise), the timestamp gets 'stuck' and becomes stale.</p> <p>Possible fixes:</p> <ul> <li>Commit frequently (silly if you're only doing SELECTs)</li> <li>Set up Psycopg2 to use different behavior for automatically creating transactions (probably tricky to get right, and <em>will</em> affect other parts of your app)</li> <li>Use a different timestamp function, like <code>statement_timestamp()</code> (not SQL-standard-compliant, but otherwise perfect for this scenario)</li> </ul> <p>From <a href="http://www.postgresql.org/docs/8.3/static/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT" rel="nofollow">the manual, section 9.9.4</a>, emphasis added:</p> <blockquote> <p>PostgreSQL provides a number of functions that return values related to the current date and time. These SQL-standard functions all return values based on the start time of the current transaction:</p> <ul> <li><code>CURRENT_DATE</code></li> <li><code>CURRENT_TIME</code></li> <li><code>CURRENT_TIMESTAMP</code></li> <li><code>CURRENT_TIME(precision)</code></li> <li><code>CURRENT_TIMESTAMP(precision)</code></li> <li><code>LOCALTIME</code> <code>LOCALTIMESTAMP</code></li> <li><code>LOCALTIME(precision)</code></li> <li><code>LOCALTIMESTAMP(precision)</code></li> </ul> <p><code>CURRENT_TIME</code> and <code>CURRENT_TIMESTAMP</code> deliver values with time zone; <code>LOCALTIME</code> and <code>LOCALTIMESTAMP</code> deliver values without time zone. </p> <p><code>CURRENT_TIME</code>, <code>CURRENT_TIMESTAMP</code>, <code>LOCALTIME</code>, and <code>LOCALTIMESTAMP</code> can optionally be given a precision parameter, which causes the result to be rounded to that many fractional digits in the seconds field. Without a precision parameter, the result is given to the full available precision.</p> <p>...</p> <p>Since <strong>these functions return the start time of the current transaction, their values do not change during the transaction</strong>. This is considered a feature: the intent is to allow a single transaction to have a consistent notion of the "current" time, so that multiple modifications within the same transaction bear the same time stamp. </p> <p><em>Note:</em> Other database systems might advance these values more frequently. </p> <p>PostgreSQL also provides functions that return the start time of the current statement, as well as the actual current time at the instant the function is called. The complete list of non-SQL-standard time functions is:</p> <ul> <li><code>now()</code></li> <li><code>transaction_timestamp()</code></li> <li><code>statement_timestamp()</code></li> <li><code>clock_timestamp()</code></li> <li><code>timeofday()</code></li> </ul> <p><code>now()</code> is a traditional PostgreSQL equivalent to <code>CURRENT_TIMESTAMP</code>. <code>transaction_timestamp()</code> is likewise equivalent to <code>CURRENT_TIMESTAMP</code>, but is named to clearly reflect what it returns. <code>statement_timestamp()</code> returns the start time of the current statement (more specifically, the time of receipt of the latest command message from the client). <code>statement_timestamp()</code> and <code>transaction_timestamp()</code> return the same value during the first command of a transaction, but might differ during subsequent commands. <code>clock_timestamp()</code> returns the actual current time, and therefore its value changes even within a single SQL command. <code>timeofday()</code> is a historical PostgreSQL function. Like <code>clock_timestamp()</code>, it returns the actual current time, but as a formatted text string rather than a timestamp with time zone value.</p> </blockquote>
1
2009-03-20T07:24:44Z
[ "python", "postgresql", "cherrypy" ]
Sending Rich Text Format email using Outlook 2003
655,180
<p>I am trying to send a Rich Text Format email message using Outlook 2003. The following code results the RTF HTML source code to be dumped into the mail message body.</p> <p>What should I do in order to fix that, and make Outlook display the formatted data and not the source HTML ?</p> <pre><code>import win32com.client RTFTEMPLATE = """&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"&gt; &lt;HTML&gt; &lt;HEAD&gt; &lt;META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3Dus-ascii"&gt; &lt;META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version = 08.00.0681.000"&gt; &lt;TITLE&gt;%s&lt;/TITLE&gt; &lt;/HEAD&gt; &lt;BODY&gt; &lt;!-- Converted from text/rtf format --&gt; &lt;P DIR=3DLTR&gt;&lt;SPAN LANG=3D"en-us"&gt;&lt;FONT = FACE=3D"Calibri"&gt;%s&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN = LANG=3D"en-us"&gt;&lt;/SPAN&gt;&lt;/P&gt; &lt;/BODY&gt; &lt;/HTML&gt;""" Format = { 'UNSPECIFIED' : 0, 'PLAIN' : 1, 'HTML' : 2, 'RTF' : 3} profile = "Outlook" subject="Subject" body = "Test Message" session = win32com.client.Dispatch("Mapi.Session") outlook = win32com.client.Dispatch("Outlook.Application") session.Logon(profile) mainMsg = outlook.CreateItem(0) mainMsg.To = "test@test.test" mainMsg.Subject = subject mainMsg.BodyFormat = Format['RTF'] mainMsg.Body = RTFTEMPLATE % (subject,body) mainMsg.Send() </code></pre> <p>EDIT: When using HTMLBody instead of Body, Outlook detects the message as HTML and not as RTF.</p>
1
2009-03-17T17:09:27Z
655,239
<p>If you must use RTF, you will need to convert your HTML to RTF format. Check out the <a href="http://pypi.python.org/pypi/zopyx.convert/1.1.9" rel="nofollow">zopyx package</a>.</p> <p>To use HTML, change the line:</p> <pre><code>mainMsg.Body = RTFTEMPLATE % (subject,body) </code></pre> <p>to:</p> <pre><code>mainMsg.HTMLBody = RTFTEMPLATE % (subject,body) </code></pre>
0
2009-03-17T17:25:18Z
[ "python", "email", "outlook" ]
How to configure IPython to use gvim on Windows?
655,530
<p>This really looks like something I should be able to find on Google, but for some reason I can't make heads or tails of it. There's the EDITOR environment variable, the ipy_user_conf.py file, the ipythonrc file, some weird thing about running gvim in server mode and a bunch of other stuff I can't wrap my head around (probably because of lack of sleep).</p> <p>Is there a guide somewhere I can follow, or maybe someone can just outline the steps I need to take?</p>
7
2009-03-17T18:33:24Z
655,642
<p>Setting the EDITOR environment variable to 'gvim -f' seems to work.</p> <pre><code>set EDITOR=gvim -f </code></pre>
8
2009-03-17T19:14:33Z
[ "python", "windows", "vim", "ipython" ]
How to configure IPython to use gvim on Windows?
655,530
<p>This really looks like something I should be able to find on Google, but for some reason I can't make heads or tails of it. There's the EDITOR environment variable, the ipy_user_conf.py file, the ipythonrc file, some weird thing about running gvim in server mode and a bunch of other stuff I can't wrap my head around (probably because of lack of sleep).</p> <p>Is there a guide somewhere I can follow, or maybe someone can just outline the steps I need to take?</p>
7
2009-03-17T18:33:24Z
6,022,505
<p>I found something which may help you out: <a href="http://selinap.com/2010/08/integrate-vim-and-ipython-in-windows/" rel="nofollow">http://selinap.com/2010/08/integrate-vim-and-ipython-in-windows/</a></p> <p>Summary:</p> <ol> <li><p>edit file - C:\Users\your username_ipython\ipythonrc.ini</p></li> <li><p>replace line: <code>editor 0</code> to <code>editor gvim –f</code> (or <code>editor whatever_editor_you_want_to_use</code>)</p></li> <li><p>save file :)</p></li> </ol> <p>You may have problem that your Win doesn't recongize gvim as a command, you can fix it like this:</p> <p>Control Panel -> System -> Advances system settings (System properties - Advanced tab) -> Enviroment Variables</p> <p>In system variables edit Path and add something like this: <code>;C:\Program Files\Vim\vim73\</code> or path which leads to your <code>gvim.exe</code></p>
4
2011-05-16T19:46:26Z
[ "python", "windows", "vim", "ipython" ]
How to configure IPython to use gvim on Windows?
655,530
<p>This really looks like something I should be able to find on Google, but for some reason I can't make heads or tails of it. There's the EDITOR environment variable, the ipy_user_conf.py file, the ipythonrc file, some weird thing about running gvim in server mode and a bunch of other stuff I can't wrap my head around (probably because of lack of sleep).</p> <p>Is there a guide somewhere I can follow, or maybe someone can just outline the steps I need to take?</p>
7
2009-03-17T18:33:24Z
7,523,508
<p><a href="http://superuser.com/questions/284342/how-do-i-set-path-and-other-environment-variables/284351#284351">Create a new Environment Variable in Windows</a> named <code>EDITOR</code>:</p> <ol> <li><code>Win XP: Start -&gt; Control Panel -&gt; System -&gt; Advanced -&gt; Environment Variables -&gt; New</code></li> <li><code>Win 7: Start -&gt; Type in Search Programs and Files: "environment variables" -&gt; select 'Edit environment variables for your account' -&gt; New...</code></li> </ol> <p>Variable name will be <code>EDITOR</code> and the Variable value will be the file path of where the <code>gvim.exe</code> file is installed (ex. <code>"C:\Program Files\Vim\vim73\gvim.exe"</code>)</p>
3
2011-09-23T02:00:01Z
[ "python", "windows", "vim", "ipython" ]
How to configure IPython to use gvim on Windows?
655,530
<p>This really looks like something I should be able to find on Google, but for some reason I can't make heads or tails of it. There's the EDITOR environment variable, the ipy_user_conf.py file, the ipythonrc file, some weird thing about running gvim in server mode and a bunch of other stuff I can't wrap my head around (probably because of lack of sleep).</p> <p>Is there a guide somewhere I can follow, or maybe someone can just outline the steps I need to take?</p>
7
2009-03-17T18:33:24Z
17,690,449
<p>To get this to work with qtconsole I had to enter</p> <pre><code>ipython qtconsole --ConsoleWidget.editor=gvim.bat </code></pre> <p>gvim.bat having been created and installed in my execution path when gvim was installed under windows. Hence, to make it permanent, the </p> <pre><code>c.IPythonWidget.editor = 'gvim.bat' </code></pre> <p>line needs to be entered in <code>ipython_qtconsole_config.py</code>.</p>
0
2013-07-17T03:12:30Z
[ "python", "windows", "vim", "ipython" ]
Why is wx.SingleChoiceDialog not subclassing properly
655,662
<p>I'm trying to subclass the wxpython SingleChoiceDialog class. I have a TableChoiceDialog class that inherits from SingleChoiceDialog adding generic functionality, and I have 2 sub classes for that add more refined functionality. Basically I'm O.O.P'ing</p> <p>In my TableChoiceDialog class I have a line which calls the superclass's <code>__init__</code>, i.e.</p> <pre><code>class TableChoiceDialog(wx.SingleChoiceDialog): def __init__(self, parent, message, caption, list, ...other args...): wx.SingleChoiceDialog.__init__(self, parent, message, caption, list) </code></pre> <p>The problem I'm having is that according to the <code>SingleChoiceDialog.__init__</code> docstring (and the wxPython API), SingleChoiceDialog does not have the self argument as part of it's <code>__init__</code> method.</p> <pre><code> __init__(Window parent, String message, String caption, List choices=EmptyList, long style=CHOICEDLG_STYLE, Point pos=DefaultPosition) -&gt; SingleChoiceDialog </code></pre> <p>As I have it above, the program prints the error:</p> <pre><code>swig/python detected a memory leak of type 'wxSingleChoiceDialog *', no destructor found. </code></pre> <p>If I take out the self parameter the system complains that it was expecting a <code>SingleChoiceDialog</code> object as a first argument, which seems to point to it actually wanting a reference to self.</p> <p>When I take out the parent argument, leaving self (and the other 3 which I'm pretty sure are fine) the system complains that it only recieved 3 arguments, when it needed 4. I'm pretty certain I'm passing 4.</p> <p>So. What blatantly obvious mistake have I made? Have I totally misunderstood how python handles objects (and hence pretty much misunderstood python)? Have I misunderstood OOP as a whole?</p> <p>Please help. Thanks in advance</p>
4
2009-03-17T19:21:40Z
655,835
<ol> <li>The call to <code>__init__</code> seems alright (the first argument to <code>__init__</code> is always <code>self</code>).</li> <li>You might have a wrong build of <code>wx</code>. The swig's warning message indicates that there is no desctructor was generated for <code>wxSingleChoiceDialog</code>, see <a href="http://lists.osafoundation.org/pipermail/pyicu-dev/2006-March/000040.html" rel="nofollow">this memory leak discussion</a>.</li> </ol> <p>The message may be unrelated to the <code>__init__</code> call.</p>
0
2009-03-17T20:10:21Z
[ "python", "oop", "wxpython", "subclass" ]
Why is wx.SingleChoiceDialog not subclassing properly
655,662
<p>I'm trying to subclass the wxpython SingleChoiceDialog class. I have a TableChoiceDialog class that inherits from SingleChoiceDialog adding generic functionality, and I have 2 sub classes for that add more refined functionality. Basically I'm O.O.P'ing</p> <p>In my TableChoiceDialog class I have a line which calls the superclass's <code>__init__</code>, i.e.</p> <pre><code>class TableChoiceDialog(wx.SingleChoiceDialog): def __init__(self, parent, message, caption, list, ...other args...): wx.SingleChoiceDialog.__init__(self, parent, message, caption, list) </code></pre> <p>The problem I'm having is that according to the <code>SingleChoiceDialog.__init__</code> docstring (and the wxPython API), SingleChoiceDialog does not have the self argument as part of it's <code>__init__</code> method.</p> <pre><code> __init__(Window parent, String message, String caption, List choices=EmptyList, long style=CHOICEDLG_STYLE, Point pos=DefaultPosition) -&gt; SingleChoiceDialog </code></pre> <p>As I have it above, the program prints the error:</p> <pre><code>swig/python detected a memory leak of type 'wxSingleChoiceDialog *', no destructor found. </code></pre> <p>If I take out the self parameter the system complains that it was expecting a <code>SingleChoiceDialog</code> object as a first argument, which seems to point to it actually wanting a reference to self.</p> <p>When I take out the parent argument, leaving self (and the other 3 which I'm pretty sure are fine) the system complains that it only recieved 3 arguments, when it needed 4. I'm pretty certain I'm passing 4.</p> <p>So. What blatantly obvious mistake have I made? Have I totally misunderstood how python handles objects (and hence pretty much misunderstood python)? Have I misunderstood OOP as a whole?</p> <p>Please help. Thanks in advance</p>
4
2009-03-17T19:21:40Z
1,737,336
<p>Some of the dialogs in wxPython are not subclassable because they are not real classes, but instead wrappers around the platform API method for displaying the dialog. I know this is the case for <code>wx.MessageDialog</code>, it might also be the case for <code>wx.SingleChoiceDialog</code>.</p>
0
2009-11-15T11:48:01Z
[ "python", "oop", "wxpython", "subclass" ]
python regular expression for retweets
655,903
<p>i'm working on a regex that will extract retweet keywords and user names from tweets. here's an example, with a rather terrible regex to do the job:</p> <pre><code>tweet='foobar RT@one, @two: @three barfoo' m=re.search(r'(RT|retweet|from|via)\b\W*@(\w+)\b\W*@(\w+)\b\W*@(\w+)\b\W*',tweet) m.groups() ('RT', 'one', 'two', 'three') </code></pre> <p>what i'd like is to condense the repeated <code>\b\W*@(\w+)\b\W*</code> patterns and make them of a variable number, so that if @four were added after @three, it would also be extracted. i've tried many permutations to repeat this with a <code>+</code> unsuccessfully.</p> <p>i'd also like this to work for something like</p> <pre><code>tweet='foobar RT@one, RT @two: RT @three barfoo'; </code></pre> <p>which can be achieved with a re.finditer <em>if</em> the patterns don't overlap. (i have a version where the patterns do overlap, and so only the first RT gets picked up.)</p> <p>any help is greatly appreciated. thanks.</p>
1
2009-03-17T20:28:08Z
655,927
<p>Try</p> <pre><code>(RT|retweet|from|via)(?:\b\W*@(\w+))+' </code></pre> <p>Enclosing the <code>\b\W*@(\w+)</code> in '(?:...)` allows you to group the terms for repetition without capturing the aggregate.</p> <p>I'm not sure I'm following the second part of your question, but I think you may be looking for something involving a construct like:</p> <pre><code>(?:(?!RT|@).) </code></pre> <p>which will match any character that isn't an "@" or the start of "RT", again without capturing it.</p> <p>In that case, how about:</p> <pre><code>(RT|retweet|from|via)((?:\b\W*@\w+)+) </code></pre> <p>and then post process</p> <pre><code>re.split(r'@(\w+)' ,m.groups()[1]) </code></pre> <p>To get the individual handles?</p>
3
2009-03-17T20:35:38Z
[ "python", "regex", "twitter" ]
Can I get rows from SQLAlchemy that are plain arrays, rather than dictionaries?
656,050
<p>I'm trying to optimize some Python code. The profiler tells me that SQLAlchemy's _get_col() is what's killing performance. The code looks something like this:</p> <pre><code>lots_of_rows = get_lots_of_rows() for row in lots_of_rows: if row.x == row.y: print row.z </code></pre> <p>I was about to go through the code and make it more like this...</p> <pre><code>lots_of_rows = get_lots_of_rows() for row in lots_of_rows: if row[0] == row[1]: print row[2] </code></pre> <p>...but I've found some documentation that seems to indicate that when accessing row objects like arrays, you're actually still pulling dictionary keys. In other words, the row object looks like this:</p> <pre><code>'x': (x object) '0': (x object) 'y': (y object) '1': (y object) 'z': (z object) '2': (z object) </code></pre> <p>If that's the case, I doubt I'll see any performance improvement from accessing columns by number rather than name. Is there any way to get SA to return results as a list of tuples, or a list of lists, rather than a list of dictionaries? Alternately, can anyone suggest any other optimizations?</p>
3
2009-03-17T21:17:03Z
656,086
<p>I think <code>row.items()</code> is what you're looking for. It returns a list of (key, value) tuples for the row.</p> <p><a href="http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/connections.html#sqlalchemy.engine.base.RowProxy" rel="nofollow">Link</a></p>
1
2009-03-17T21:25:26Z
[ "python", "sqlalchemy" ]
Can I get rows from SQLAlchemy that are plain arrays, rather than dictionaries?
656,050
<p>I'm trying to optimize some Python code. The profiler tells me that SQLAlchemy's _get_col() is what's killing performance. The code looks something like this:</p> <pre><code>lots_of_rows = get_lots_of_rows() for row in lots_of_rows: if row.x == row.y: print row.z </code></pre> <p>I was about to go through the code and make it more like this...</p> <pre><code>lots_of_rows = get_lots_of_rows() for row in lots_of_rows: if row[0] == row[1]: print row[2] </code></pre> <p>...but I've found some documentation that seems to indicate that when accessing row objects like arrays, you're actually still pulling dictionary keys. In other words, the row object looks like this:</p> <pre><code>'x': (x object) '0': (x object) 'y': (y object) '1': (y object) 'z': (z object) '2': (z object) </code></pre> <p>If that's the case, I doubt I'll see any performance improvement from accessing columns by number rather than name. Is there any way to get SA to return results as a list of tuples, or a list of lists, rather than a list of dictionaries? Alternately, can anyone suggest any other optimizations?</p>
3
2009-03-17T21:17:03Z
656,298
<p>Forgive the obvious answer, but why isn't row.x == row.y in your query? For example:</p> <pre><code>mytable.select().where(mytable.c.x==mytable.c.y) </code></pre> <p>Should give you a huge performance boost. <a href="http://www.sqlalchemy.org/docs/05/sqlexpression.html#selecting" rel="nofollow">Read the rest of the documentation.</a></p>
2
2009-03-17T22:33:20Z
[ "python", "sqlalchemy" ]
Can I get rows from SQLAlchemy that are plain arrays, rather than dictionaries?
656,050
<p>I'm trying to optimize some Python code. The profiler tells me that SQLAlchemy's _get_col() is what's killing performance. The code looks something like this:</p> <pre><code>lots_of_rows = get_lots_of_rows() for row in lots_of_rows: if row.x == row.y: print row.z </code></pre> <p>I was about to go through the code and make it more like this...</p> <pre><code>lots_of_rows = get_lots_of_rows() for row in lots_of_rows: if row[0] == row[1]: print row[2] </code></pre> <p>...but I've found some documentation that seems to indicate that when accessing row objects like arrays, you're actually still pulling dictionary keys. In other words, the row object looks like this:</p> <pre><code>'x': (x object) '0': (x object) 'y': (y object) '1': (y object) 'z': (z object) '2': (z object) </code></pre> <p>If that's the case, I doubt I'll see any performance improvement from accessing columns by number rather than name. Is there any way to get SA to return results as a list of tuples, or a list of lists, rather than a list of dictionaries? Alternately, can anyone suggest any other optimizations?</p>
3
2009-03-17T21:17:03Z
656,707
<p>You should post your profiler results as well as stack traces around the '_get_col' call so we know which _get_col is being called. (and whether _get_col really is the bottleneck).</p> <p>I looked at the sqlalchemy source, looks like it may be calling 'lookup_key' (in engine/base.py) each time and it looks like this caches the column value locally, i guess lazily (via PopulateDict). </p> <p>You can try bypassing that by directly using row.__props (not recommended since it's private), maybe you can row.cursor, but it looks like you would gain much by bypassing sqlalchemy (except the sql generation) and working directly w/ a cursor. </p> <p>-- J</p>
0
2009-03-18T01:51:59Z
[ "python", "sqlalchemy" ]
Can I get rows from SQLAlchemy that are plain arrays, rather than dictionaries?
656,050
<p>I'm trying to optimize some Python code. The profiler tells me that SQLAlchemy's _get_col() is what's killing performance. The code looks something like this:</p> <pre><code>lots_of_rows = get_lots_of_rows() for row in lots_of_rows: if row.x == row.y: print row.z </code></pre> <p>I was about to go through the code and make it more like this...</p> <pre><code>lots_of_rows = get_lots_of_rows() for row in lots_of_rows: if row[0] == row[1]: print row[2] </code></pre> <p>...but I've found some documentation that seems to indicate that when accessing row objects like arrays, you're actually still pulling dictionary keys. In other words, the row object looks like this:</p> <pre><code>'x': (x object) '0': (x object) 'y': (y object) '1': (y object) 'z': (z object) '2': (z object) </code></pre> <p>If that's the case, I doubt I'll see any performance improvement from accessing columns by number rather than name. Is there any way to get SA to return results as a list of tuples, or a list of lists, rather than a list of dictionaries? Alternately, can anyone suggest any other optimizations?</p>
3
2009-03-17T21:17:03Z
866,228
<p>SQLAlchemy proxies all access to the underlying database cursor to map named keys to positions in the row tuple and perform any necessary type conversions. The underlying implementation is quite heavily optimized, caching almost everything. Looking over the disassembly the only ways to further optimize seem to be to throw out extensibility and get rid of a couple of attribute lookups or to resort to dynamic code generation for smaller gains, or to gain more, implement the corresponding ResultProxy and RowProxy classes in C.</p> <p>Some quick profiling shows that the overhead is around 5us per lookup on my laptop. That will be significant if only trivial processing is done with the data. In those kind of cases it might be reasonable to drop down to dbapi level. This doesn't mean that you have to lose the query building functionality of SQLAlchemy. Just execute the statement as you usually would and get the dbapi cursor from the <code>ResultProxy</code> by accessing <code>result.cursor.cursor</code>. (<code>result.cursor</code> is an SQLAlchemy CursorFairy object) Then you can use the regular dbapi fetchall(), fetchone() and fetchmany() methods.</p> <p>But if you really are doing trivial processing it might be useful to do it, or at least the filtering part on the database server. You probably lose database portability, but that might not be an issue.</p>
1
2009-05-14T22:37:46Z
[ "python", "sqlalchemy" ]
Why did Python 2.6 add a global next() function?
656,155
<p>I noticed that Python2.6 added a next() to it's <a href="http://docs.python.org/library/functions.html" rel="nofollow">list of global functions</a>.</p> <blockquote> <p><a href="http://docs.python.org/library/functions.html#next" rel="nofollow"><code>next(iterator[, default])</code></a></p> <pre><code>Retrieve the next item from the iterator by calling its next() method. </code></pre> <p>If <code>default</code> is given, it is returned if the iterator is exhausted, otherwise <code>StopIteration</code> is raised.</p> </blockquote> <p>What was the motivation for adding this? What can you do with <code>next(iterator)</code> that you can't do with <code>iterator.next()</code> and an <code>except</code> clause to handle the StopIteration?</p>
14
2009-03-17T21:42:39Z
656,184
<p>It's just for consistency with functions like <code>len()</code>. I believe <code>next(i)</code> calls <code>i.__next__()</code> internally.</p> <p>See <a href="http://www.python.org/dev/peps/pep-3114/">http://www.python.org/dev/peps/pep-3114/</a></p>
18
2009-03-17T21:52:54Z
[ "python", "python-2.6" ]
Why did Python 2.6 add a global next() function?
656,155
<p>I noticed that Python2.6 added a next() to it's <a href="http://docs.python.org/library/functions.html" rel="nofollow">list of global functions</a>.</p> <blockquote> <p><a href="http://docs.python.org/library/functions.html#next" rel="nofollow"><code>next(iterator[, default])</code></a></p> <pre><code>Retrieve the next item from the iterator by calling its next() method. </code></pre> <p>If <code>default</code> is given, it is returned if the iterator is exhausted, otherwise <code>StopIteration</code> is raised.</p> </blockquote> <p>What was the motivation for adding this? What can you do with <code>next(iterator)</code> that you can't do with <code>iterator.next()</code> and an <code>except</code> clause to handle the StopIteration?</p>
14
2009-03-17T21:42:39Z
656,236
<p>It calls <code>__next__</code> internally, but it makes it look more 'functional' than 'object-oriented'. Mind you that's just my opinion, but I don't like <code>next(i)</code> rather than <code>i.next()</code>. But as Steve Mc said, it also helps slightly with consistency.</p>
0
2009-03-17T22:09:34Z
[ "python", "python-2.6" ]
Why did Python 2.6 add a global next() function?
656,155
<p>I noticed that Python2.6 added a next() to it's <a href="http://docs.python.org/library/functions.html" rel="nofollow">list of global functions</a>.</p> <blockquote> <p><a href="http://docs.python.org/library/functions.html#next" rel="nofollow"><code>next(iterator[, default])</code></a></p> <pre><code>Retrieve the next item from the iterator by calling its next() method. </code></pre> <p>If <code>default</code> is given, it is returned if the iterator is exhausted, otherwise <code>StopIteration</code> is raised.</p> </blockquote> <p>What was the motivation for adding this? What can you do with <code>next(iterator)</code> that you can't do with <code>iterator.next()</code> and an <code>except</code> clause to handle the StopIteration?</p>
14
2009-03-17T21:42:39Z
656,555
<p>Note that in Python 3.0+ the <code>next</code> method has been renamed to <code>__next__</code>. This is because of consistency. <code>next</code> is a special method and special methods are named by convention (PEP 8) with double leading and trailing underscore. Special methods are not meant to be called directly, that's why the <code>next</code> built in function was introduced.</p>
10
2009-03-18T00:31:36Z
[ "python", "python-2.6" ]
Implementation: How to retrieve and send emails for different Gmail accounts?
656,180
<p>I need advice and how to got about setting up a simple service for my users. I would like to add a new feature where users can send and receive emails from their gmail account. I have seen this done several times and I know its possible.</p> <p>There use to be a project for "Libgmailer" at sourceforge but I think it was abandoned. Is anyone aware of anything similar?</p> <p>I have found that Gmail has a Python API but my site is making use of PHP.</p> <p>I really need ideas on how to best go about this!</p> <p>Thanks all for any input</p>
1
2009-03-17T21:51:51Z
656,194
<p>Well if Google didn't come up with anything personally I'd see if I could reverse engineer the Python API by implementing it and watching it with a packet sniffer. My guess is it's just accessing some web service which should be pretty easy to mimic regardless of the language you're using.</p>
0
2009-03-17T21:55:45Z
[ "php", "python", "email", "gmail" ]
Implementation: How to retrieve and send emails for different Gmail accounts?
656,180
<p>I need advice and how to got about setting up a simple service for my users. I would like to add a new feature where users can send and receive emails from their gmail account. I have seen this done several times and I know its possible.</p> <p>There use to be a project for "Libgmailer" at sourceforge but I think it was abandoned. Is anyone aware of anything similar?</p> <p>I have found that Gmail has a Python API but my site is making use of PHP.</p> <p>I really need ideas on how to best go about this!</p> <p>Thanks all for any input</p>
1
2009-03-17T21:51:51Z
656,198
<p>any library/source that works with imap or pop will work.</p>
6
2009-03-17T21:56:17Z
[ "php", "python", "email", "gmail" ]
Implementation: How to retrieve and send emails for different Gmail accounts?
656,180
<p>I need advice and how to got about setting up a simple service for my users. I would like to add a new feature where users can send and receive emails from their gmail account. I have seen this done several times and I know its possible.</p> <p>There use to be a project for "Libgmailer" at sourceforge but I think it was abandoned. Is anyone aware of anything similar?</p> <p>I have found that Gmail has a Python API but my site is making use of PHP.</p> <p>I really need ideas on how to best go about this!</p> <p>Thanks all for any input</p>
1
2009-03-17T21:51:51Z
656,205
<p>Just a thought, Gmail supports POP/IMAP access. Could you do it using those protocols? It would mean asking your users to go into their gmail and enable it though.</p>
0
2009-03-17T21:58:33Z
[ "php", "python", "email", "gmail" ]
python time + timedelta equivalent
656,297
<p>I'm trying to do something like this:</p> <pre><code>time() + timedelta(hours=1) </code></pre> <p>however, <a href="http://bugs.python.org/issue1487389">Python doesn't allow it</a>, apparently for good reason.</p> <p>Does anyone have a simple work around?</p> <h3>Related:</h3> <ul> <li><a href="http://stackoverflow.com/questions/100210/python-easy-way-to-add-n-seconds-to-a-datetime-time">Python - easy way to add N seconds to a datetime.time?</a></li> </ul>
37
2009-03-17T22:32:43Z
656,318
<p>Workaround:</p> <pre><code>t = time() t2 = time(t.hour+1, t.minute, t.second, t.microsecond) </code></pre> <p>You can also omit the microseconds, if you don't need that much precision.</p>
3
2009-03-17T22:43:01Z
[ "python" ]
python time + timedelta equivalent
656,297
<p>I'm trying to do something like this:</p> <pre><code>time() + timedelta(hours=1) </code></pre> <p>however, <a href="http://bugs.python.org/issue1487389">Python doesn't allow it</a>, apparently for good reason.</p> <p>Does anyone have a simple work around?</p> <h3>Related:</h3> <ul> <li><a href="http://stackoverflow.com/questions/100210/python-easy-way-to-add-n-seconds-to-a-datetime-time">Python - easy way to add N seconds to a datetime.time?</a></li> </ul>
37
2009-03-17T22:32:43Z
656,334
<p>This is a bit nasty, but:</p> <pre><code>from datetime import datetime, timedelta now = datetime.now().time() # Just use January the first, 2000 d1 = datetime(2000, 1, 1, now.hour, now.minute, now.second) d2 = d1 + timedelta(hours=1, minutes=23) print d2.time() </code></pre>
5
2009-03-17T22:50:54Z
[ "python" ]
python time + timedelta equivalent
656,297
<p>I'm trying to do something like this:</p> <pre><code>time() + timedelta(hours=1) </code></pre> <p>however, <a href="http://bugs.python.org/issue1487389">Python doesn't allow it</a>, apparently for good reason.</p> <p>Does anyone have a simple work around?</p> <h3>Related:</h3> <ul> <li><a href="http://stackoverflow.com/questions/100210/python-easy-way-to-add-n-seconds-to-a-datetime-time">Python - easy way to add N seconds to a datetime.time?</a></li> </ul>
37
2009-03-17T22:32:43Z
656,394
<p>The solution is in <a href="http://bugs.python.org/issue1487389">the link that you provided</a> in your question:</p> <pre><code>datetime.combine(date.today(), time()) + timedelta(hours=1) </code></pre> <p>Full example:</p> <pre><code>from datetime import date, datetime, time, timedelta dt = datetime.combine(date.today(), time(23, 55)) + timedelta(minutes=30) print dt.time() </code></pre> <p>Output:</p> <pre><code>00:25:00 </code></pre>
71
2009-03-17T23:14:34Z
[ "python" ]
python time + timedelta equivalent
656,297
<p>I'm trying to do something like this:</p> <pre><code>time() + timedelta(hours=1) </code></pre> <p>however, <a href="http://bugs.python.org/issue1487389">Python doesn't allow it</a>, apparently for good reason.</p> <p>Does anyone have a simple work around?</p> <h3>Related:</h3> <ul> <li><a href="http://stackoverflow.com/questions/100210/python-easy-way-to-add-n-seconds-to-a-datetime-time">Python - easy way to add N seconds to a datetime.time?</a></li> </ul>
37
2009-03-17T22:32:43Z
6,838,994
<p>If it's worth adding another file / dependency to your project, I've just written a tiny little class that extends <code>datetime.time</code> with the ability to do arithmetic. If you go past midnight, it just wraps around:</p> <pre><code>&gt;&gt;&gt; from nptime import nptime &gt;&gt;&gt; from datetime import timedelta &gt;&gt;&gt; afternoon = nptime(12, 24) + timedelta(days=1, minutes=36) &gt;&gt;&gt; afternoon nptime(13, 0) &gt;&gt;&gt; str(afternoon) '13:00:00' </code></pre> <p>It's available from PyPi as <code>nptime</code> ("non-pedantic time"), or on GitHub: <a href="https://github.com/tgs/nptime" rel="nofollow">https://github.com/tgs/nptime</a></p> <p>The documentation is at <a href="http://tgs.github.io/nptime/" rel="nofollow">http://tgs.github.io/nptime/</a></p>
7
2011-07-27T02:58:22Z
[ "python" ]
python time + timedelta equivalent
656,297
<p>I'm trying to do something like this:</p> <pre><code>time() + timedelta(hours=1) </code></pre> <p>however, <a href="http://bugs.python.org/issue1487389">Python doesn't allow it</a>, apparently for good reason.</p> <p>Does anyone have a simple work around?</p> <h3>Related:</h3> <ul> <li><a href="http://stackoverflow.com/questions/100210/python-easy-way-to-add-n-seconds-to-a-datetime-time">Python - easy way to add N seconds to a datetime.time?</a></li> </ul>
37
2009-03-17T22:32:43Z
22,466,841
<p>You can change time() to now() for it to work</p> <pre><code>datetime.now() + timedelta(hours=1) </code></pre>
0
2014-03-17T22:34:20Z
[ "python" ]
Python lib to Read a Flash swf Format File
656,704
<p>I'm interested in using Python to hack on the data in Flash swf files. There is good <a href="http://www.adobe.com/devnet/swf/">documentation</a> available on the format of swf files, and I am considering writing my own Python lib to parse that data out using the standard Python <a href="http://docs.python.org/library/struct.html">struct</a> lib.</p> <p>Does anybody know of a Python project that already does this? I would also be interested in any available solutions that use Perl, Ruby, Haskell, etc.</p>
6
2009-03-18T01:49:32Z
656,726
<p>Well, unless you're doing it for fun (in which case, go for it!), why not use <a href="http://www.libming.org/" rel="nofollow">Ming</a>? It supposedly has python wrappers...</p>
3
2009-03-18T02:02:41Z
[ "python", "flash" ]
Python lib to Read a Flash swf Format File
656,704
<p>I'm interested in using Python to hack on the data in Flash swf files. There is good <a href="http://www.adobe.com/devnet/swf/">documentation</a> available on the format of swf files, and I am considering writing my own Python lib to parse that data out using the standard Python <a href="http://docs.python.org/library/struct.html">struct</a> lib.</p> <p>Does anybody know of a Python project that already does this? I would also be interested in any available solutions that use Perl, Ruby, Haskell, etc.</p>
6
2009-03-18T01:49:32Z
660,673
<p>I found another option in <a href="http://www.swftools.org/" rel="nofollow">SWF Tools</a>. They provide a Python wrapper that supports generating SWF files in Python.</p> <p>I'm not sure if either SWF Tools or Ming actually supports parsing in and modifying an existing swf file, however. Both seem geared more towards generating swf files from scratch.</p>
1
2009-03-19T00:45:57Z
[ "python", "flash" ]
PyWinAuto still useful?
656,779
<p>I've been playing with PyWinAuto today and having fun automating all sorts GUI tests. I was wondering if it is still state of the art or if there might be something else (also free) which does windows rich client automation better. </p>
9
2009-03-18T02:34:01Z
657,105
<p>pywinauto is great because it's Python.</p> <p>Perhaps a bit more full featured is <a href="http://www.autoitscript.com/autoit3/index.shtml">AutoIT</a>, which has a COM server that you can automate (from Python using win32com), and some cool tools, like a "<a href="http://www.autoitscript.com/autoit3/docs/intro/au3spy.htm">Window Info</a>" utility, which will give you the text (title), class, size, status-bar text, and so on for the window currently under the mouse cursor.</p> <p>There are some cases where pywinauto is a bit harder to use than AutoIt, and seems a little less polished. One example is automating Inno Setup programs. The Inno Setup "setup.exe" program launches a separate application that actually performs the install, and it's a pain to track this down with pywinauto, but AutoIt makes it easy.</p>
8
2009-03-18T05:51:04Z
[ "python", "pywinauto" ]
PyWinAuto still useful?
656,779
<p>I've been playing with PyWinAuto today and having fun automating all sorts GUI tests. I was wondering if it is still state of the art or if there might be something else (also free) which does windows rich client automation better. </p>
9
2009-03-18T02:34:01Z
1,653,008
<p>I used to do test automation on our projects with AutoIt but switched over to pywinauto 3 months ago and have been very happy with that decision. There are some rough edges, but I've been able to fill them in with my own supplementary test functions. In addition I find that coding tests and support code in Python is <em>much</em> easier and more manageable compared to AutoIt. With Python I have way more powerful options for logging, debugging, documentation, process management and test configuration. For me it was absolutely the right way to go.</p>
7
2009-10-31T00:49:55Z
[ "python", "pywinauto" ]
PyWinAuto still useful?
656,779
<p>I've been playing with PyWinAuto today and having fun automating all sorts GUI tests. I was wondering if it is still state of the art or if there might be something else (also free) which does windows rich client automation better. </p>
9
2009-03-18T02:34:01Z
6,291,256
<p>I am going the same way, bit by bit and I have to say that python + pywinauto is good stuff!</p>
3
2011-06-09T10:16:31Z
[ "python", "pywinauto" ]
Communicating with a running python daemon
656,933
<p>I wrote a small Python application that runs as a daemon. It utilizes threading and queues. </p> <p>I'm looking for general approaches to altering this application so that I can communicate with it while it's running. Mostly I'd like to be able to monitor its health.</p> <p>In a nutshell, I'd like to be able to do something like this:</p> <pre><code>python application.py start # launches the daemon </code></pre> <p>Later, I'd like to be able to come along and do something like:</p> <pre><code>python application.py check_queue_size # return info from the daemonized process </code></pre> <p>To be clear, I don't have any problem implementing the Django-inspired syntax. What I don't have any idea how to do is to send signals to the daemonized process (start), or how to write the daemon to handle and respond to such signals.</p> <p>Like I said above, I'm looking for general approaches. The only one I can see right now is telling the daemon constantly log everything that might be needed to a file, but I hope there's a less messy way to go about it.</p> <p><strong>UPDATE:</strong> Wow, a lot of great answers. Thanks so much. I think I'll look at both Pyro and the web.py/Werkzeug approaches, since Twisted is a little more than I want to bite off at this point. The next conceptual challenge, I suppose, is how to go about talking to my worker threads without hanging them up.</p> <p>Thanks again.</p>
44
2009-03-18T04:09:31Z
656,956
<p>What about having it run an http server?</p> <p>It seems crazy but running a simple web server for administrating your server requires just a few lines using web.py</p> <p>You can also consider creating a unix pipe.</p>
18
2009-03-18T04:22:00Z
[ "python", "daemon" ]
Communicating with a running python daemon
656,933
<p>I wrote a small Python application that runs as a daemon. It utilizes threading and queues. </p> <p>I'm looking for general approaches to altering this application so that I can communicate with it while it's running. Mostly I'd like to be able to monitor its health.</p> <p>In a nutshell, I'd like to be able to do something like this:</p> <pre><code>python application.py start # launches the daemon </code></pre> <p>Later, I'd like to be able to come along and do something like:</p> <pre><code>python application.py check_queue_size # return info from the daemonized process </code></pre> <p>To be clear, I don't have any problem implementing the Django-inspired syntax. What I don't have any idea how to do is to send signals to the daemonized process (start), or how to write the daemon to handle and respond to such signals.</p> <p>Like I said above, I'm looking for general approaches. The only one I can see right now is telling the daemon constantly log everything that might be needed to a file, but I hope there's a less messy way to go about it.</p> <p><strong>UPDATE:</strong> Wow, a lot of great answers. Thanks so much. I think I'll look at both Pyro and the web.py/Werkzeug approaches, since Twisted is a little more than I want to bite off at this point. The next conceptual challenge, I suppose, is how to go about talking to my worker threads without hanging them up.</p> <p>Thanks again.</p>
44
2009-03-18T04:09:31Z
657,003
<p>Assuming you're under *nix, you can send signals to a running program with <code>kill</code> from a shell (and analogs in many other environments). To handle them from within python check out the <a href="http://docs.python.org/library/signal.html">signal</a> module.</p>
5
2009-03-18T04:47:33Z
[ "python", "daemon" ]
Communicating with a running python daemon
656,933
<p>I wrote a small Python application that runs as a daemon. It utilizes threading and queues. </p> <p>I'm looking for general approaches to altering this application so that I can communicate with it while it's running. Mostly I'd like to be able to monitor its health.</p> <p>In a nutshell, I'd like to be able to do something like this:</p> <pre><code>python application.py start # launches the daemon </code></pre> <p>Later, I'd like to be able to come along and do something like:</p> <pre><code>python application.py check_queue_size # return info from the daemonized process </code></pre> <p>To be clear, I don't have any problem implementing the Django-inspired syntax. What I don't have any idea how to do is to send signals to the daemonized process (start), or how to write the daemon to handle and respond to such signals.</p> <p>Like I said above, I'm looking for general approaches. The only one I can see right now is telling the daemon constantly log everything that might be needed to a file, but I hope there's a less messy way to go about it.</p> <p><strong>UPDATE:</strong> Wow, a lot of great answers. Thanks so much. I think I'll look at both Pyro and the web.py/Werkzeug approaches, since Twisted is a little more than I want to bite off at this point. The next conceptual challenge, I suppose, is how to go about talking to my worker threads without hanging them up.</p> <p>Thanks again.</p>
44
2009-03-18T04:09:31Z
657,031
<p>I would use twisted with a named pipe or just open up a socket. Take a look at the echo server and client <a href="http://twistedmatrix.com/projects/core/documentation/examples/">examples</a>. You would need to modify the echo server to check for some string passed by the client and then respond with whatever requested info.</p> <p>Because of Python's threading issues you are going to have trouble responding to information requests while simultaneously continuing to do whatever the daemon is meant to do anyways. Asynchronous techniques or forking another processes are your only real option. </p>
9
2009-03-18T05:04:08Z
[ "python", "daemon" ]
Communicating with a running python daemon
656,933
<p>I wrote a small Python application that runs as a daemon. It utilizes threading and queues. </p> <p>I'm looking for general approaches to altering this application so that I can communicate with it while it's running. Mostly I'd like to be able to monitor its health.</p> <p>In a nutshell, I'd like to be able to do something like this:</p> <pre><code>python application.py start # launches the daemon </code></pre> <p>Later, I'd like to be able to come along and do something like:</p> <pre><code>python application.py check_queue_size # return info from the daemonized process </code></pre> <p>To be clear, I don't have any problem implementing the Django-inspired syntax. What I don't have any idea how to do is to send signals to the daemonized process (start), or how to write the daemon to handle and respond to such signals.</p> <p>Like I said above, I'm looking for general approaches. The only one I can see right now is telling the daemon constantly log everything that might be needed to a file, but I hope there's a less messy way to go about it.</p> <p><strong>UPDATE:</strong> Wow, a lot of great answers. Thanks so much. I think I'll look at both Pyro and the web.py/Werkzeug approaches, since Twisted is a little more than I want to bite off at this point. The next conceptual challenge, I suppose, is how to go about talking to my worker threads without hanging them up.</p> <p>Thanks again.</p>
44
2009-03-18T04:09:31Z
657,085
<pre><code># your server from twisted.web import xmlrpc, server from twisted.internet import reactor class MyServer(xmlrpc.XMLRPC): def xmlrpc_monitor(self, params): return server_related_info if __name__ == '__main__': r = MyServer() reactor.listenTCP(8080, Server.Site(r)) reactor.run() </code></pre> <p>client can be written using xmlrpclib, check example code <a href="http://docs.python.org/library/xmlrpclib.html">here</a>.</p>
7
2009-03-18T05:38:27Z
[ "python", "daemon" ]
Communicating with a running python daemon
656,933
<p>I wrote a small Python application that runs as a daemon. It utilizes threading and queues. </p> <p>I'm looking for general approaches to altering this application so that I can communicate with it while it's running. Mostly I'd like to be able to monitor its health.</p> <p>In a nutshell, I'd like to be able to do something like this:</p> <pre><code>python application.py start # launches the daemon </code></pre> <p>Later, I'd like to be able to come along and do something like:</p> <pre><code>python application.py check_queue_size # return info from the daemonized process </code></pre> <p>To be clear, I don't have any problem implementing the Django-inspired syntax. What I don't have any idea how to do is to send signals to the daemonized process (start), or how to write the daemon to handle and respond to such signals.</p> <p>Like I said above, I'm looking for general approaches. The only one I can see right now is telling the daemon constantly log everything that might be needed to a file, but I hope there's a less messy way to go about it.</p> <p><strong>UPDATE:</strong> Wow, a lot of great answers. Thanks so much. I think I'll look at both Pyro and the web.py/Werkzeug approaches, since Twisted is a little more than I want to bite off at this point. The next conceptual challenge, I suppose, is how to go about talking to my worker threads without hanging them up.</p> <p>Thanks again.</p>
44
2009-03-18T04:09:31Z
657,702
<p>Use <a href="http://werkzeug.pocoo.org/">werkzeug</a> and make your daemon include an HTTP-based WSGI server. </p> <p>Your daemon has a collection of small WSGI apps to respond with status information.</p> <p>Your client simply uses urllib2 to make POST or GET requests to localhost:somePort. Your client and server must agree on the port number (and the URL's).</p> <p>This is very simple to implement and very scalable. Adding new commands is a trivial exercise.</p> <p>Note that your daemon does not have to respond in HTML (that's often simple, though). Our daemons respond to the WSGI-requests with JSON-encoded status objects.</p>
14
2009-03-18T10:26:16Z
[ "python", "daemon" ]
Communicating with a running python daemon
656,933
<p>I wrote a small Python application that runs as a daemon. It utilizes threading and queues. </p> <p>I'm looking for general approaches to altering this application so that I can communicate with it while it's running. Mostly I'd like to be able to monitor its health.</p> <p>In a nutshell, I'd like to be able to do something like this:</p> <pre><code>python application.py start # launches the daemon </code></pre> <p>Later, I'd like to be able to come along and do something like:</p> <pre><code>python application.py check_queue_size # return info from the daemonized process </code></pre> <p>To be clear, I don't have any problem implementing the Django-inspired syntax. What I don't have any idea how to do is to send signals to the daemonized process (start), or how to write the daemon to handle and respond to such signals.</p> <p>Like I said above, I'm looking for general approaches. The only one I can see right now is telling the daemon constantly log everything that might be needed to a file, but I hope there's a less messy way to go about it.</p> <p><strong>UPDATE:</strong> Wow, a lot of great answers. Thanks so much. I think I'll look at both Pyro and the web.py/Werkzeug approaches, since Twisted is a little more than I want to bite off at this point. The next conceptual challenge, I suppose, is how to go about talking to my worker threads without hanging them up.</p> <p>Thanks again.</p>
44
2009-03-18T04:09:31Z
658,156
<p>Yet another approach: use <a href="https://pypi.python.org/pypi/Pyro4" rel="nofollow">Pyro</a> (Python remoting objects).</p> <p>Pyro basically allows you to publish Python object instances as services that can be called remotely. I have used Pyro for the exact purpose you describe, and I found it to work very well.</p> <p>By default, a Pyro server daemon accepts connections from everywhere. To limit this, either use a connection validator (see documentation), or supply <code>host='127.0.0.1'</code> to the <code>Daemon</code> constructor to only listen for local connections.</p> <p>Example code taken from the Pyro documentation:</p> <p><strong>Server</strong></p> <pre> import Pyro.core class JokeGen(Pyro.core.ObjBase): def __init__(self): Pyro.core.ObjBase.__init__(self) def joke(self, name): return "Sorry "+name+", I don't know any jokes." Pyro.core.initServer() daemon=Pyro.core.Daemon() uri=daemon.connect(JokeGen(),"jokegen") print "The daemon runs on port:",daemon.port print "The object's uri is:",uri daemon.requestLoop() </pre> <p><strong>Client</strong></p> <pre> import Pyro.core # you have to change the URI below to match your own host/port. jokes = Pyro.core.getProxyForURI("PYROLOC://localhost:7766/jokegen") print jokes.joke("Irmen") </pre> <p>Another similar project is <a href="http://rpyc.wikidot.com/" rel="nofollow">RPyC</a>. I have not tried RPyC.</p>
26
2009-03-18T12:57:31Z
[ "python", "daemon" ]
Communicating with a running python daemon
656,933
<p>I wrote a small Python application that runs as a daemon. It utilizes threading and queues. </p> <p>I'm looking for general approaches to altering this application so that I can communicate with it while it's running. Mostly I'd like to be able to monitor its health.</p> <p>In a nutshell, I'd like to be able to do something like this:</p> <pre><code>python application.py start # launches the daemon </code></pre> <p>Later, I'd like to be able to come along and do something like:</p> <pre><code>python application.py check_queue_size # return info from the daemonized process </code></pre> <p>To be clear, I don't have any problem implementing the Django-inspired syntax. What I don't have any idea how to do is to send signals to the daemonized process (start), or how to write the daemon to handle and respond to such signals.</p> <p>Like I said above, I'm looking for general approaches. The only one I can see right now is telling the daemon constantly log everything that might be needed to a file, but I hope there's a less messy way to go about it.</p> <p><strong>UPDATE:</strong> Wow, a lot of great answers. Thanks so much. I think I'll look at both Pyro and the web.py/Werkzeug approaches, since Twisted is a little more than I want to bite off at this point. The next conceptual challenge, I suppose, is how to go about talking to my worker threads without hanging them up.</p> <p>Thanks again.</p>
44
2009-03-18T04:09:31Z
658,352
<p>You could associate it with Pyro (<a href="http://pythonhosted.org/Pyro4/" rel="nofollow">http://pythonhosted.org/Pyro4/</a>) the Python Remote Object. It lets you remotely access python objects. It's easily to implement, has low overhead, and isn't as invasive as Twisted.</p>
4
2009-03-18T13:58:35Z
[ "python", "daemon" ]
Tired of ASP.NET, which of the following should I learn and why?
656,987
<p>Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why</p> <ul> <li>Clojure/Compojure+Ring/Moustache+Ring</li> <li>Groovy/Grails </li> <li>Python/Django </li> <li>Ruby/Rails</li> <li>Turbogear</li> <li>Cappuccino or Sproutcore</li> <li>Javascript/jQuery</li> </ul>
8
2009-03-18T04:41:21Z
656,998
<p>I would probably learn Ruby on Rails. It has a lot of different methodologies compared to ASP.NET, and it might open your eyes to some different and very powerful approaches to web apps.</p>
10
2009-03-18T04:45:55Z
[ "python", "asp.net-mvc", "ruby", "groovy", "clojure" ]
Tired of ASP.NET, which of the following should I learn and why?
656,987
<p>Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why</p> <ul> <li>Clojure/Compojure+Ring/Moustache+Ring</li> <li>Groovy/Grails </li> <li>Python/Django </li> <li>Ruby/Rails</li> <li>Turbogear</li> <li>Cappuccino or Sproutcore</li> <li>Javascript/jQuery</li> </ul>
8
2009-03-18T04:41:21Z
656,999
<p>Have you considered turning off the computer and going outside instead?</p> <p>Remember to wear pants!</p>
29
2009-03-18T04:46:03Z
[ "python", "asp.net-mvc", "ruby", "groovy", "clojure" ]
Tired of ASP.NET, which of the following should I learn and why?
656,987
<p>Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why</p> <ul> <li>Clojure/Compojure+Ring/Moustache+Ring</li> <li>Groovy/Grails </li> <li>Python/Django </li> <li>Ruby/Rails</li> <li>Turbogear</li> <li>Cappuccino or Sproutcore</li> <li>Javascript/jQuery</li> </ul>
8
2009-03-18T04:41:21Z
657,000
<p>I would suggest <a href="http://www.jquery.com" rel="nofollow">jQuery</a> or python, both are fun to work with and useful for either web work or just common tasks.</p>
4
2009-03-18T04:46:29Z
[ "python", "asp.net-mvc", "ruby", "groovy", "clojure" ]
Tired of ASP.NET, which of the following should I learn and why?
656,987
<p>Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why</p> <ul> <li>Clojure/Compojure+Ring/Moustache+Ring</li> <li>Groovy/Grails </li> <li>Python/Django </li> <li>Ruby/Rails</li> <li>Turbogear</li> <li>Cappuccino or Sproutcore</li> <li>Javascript/jQuery</li> </ul>
8
2009-03-18T04:41:21Z
657,002
<p>I recommend Clojure and Compojure because Clojure is awesome. Clojure is a new and modern LISP implemented on the JVM and can interact seamlessly with any Java library. It already has 3 IDE plugins in development, a book written about it, a very smart and open-minded person running the whole operation and a great newbie friendly community. The language is simple, easy to learn and yet really powerful. A good way to open your mind to new ideas without going as far as pure functional programming. Coding websites with Clojure is a breeze and really fun. It has a lot going for it and a lot of momentum. All the kool kids are doin' it so I recommend giving it a try!</p>
8
2009-03-18T04:46:58Z
[ "python", "asp.net-mvc", "ruby", "groovy", "clojure" ]
Tired of ASP.NET, which of the following should I learn and why?
656,987
<p>Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why</p> <ul> <li>Clojure/Compojure+Ring/Moustache+Ring</li> <li>Groovy/Grails </li> <li>Python/Django </li> <li>Ruby/Rails</li> <li>Turbogear</li> <li>Cappuccino or Sproutcore</li> <li>Javascript/jQuery</li> </ul>
8
2009-03-18T04:41:21Z
657,014
<p>If you main goal is to broaden yourself, I'd suggest looking at things like <a href="http://www.seaside.st/" rel="nofollow">Seaside</a> or <a href="http://happs.org/" rel="nofollow">HAppS</a>.</p>
5
2009-03-18T04:53:25Z
[ "python", "asp.net-mvc", "ruby", "groovy", "clojure" ]
Tired of ASP.NET, which of the following should I learn and why?
656,987
<p>Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why</p> <ul> <li>Clojure/Compojure+Ring/Moustache+Ring</li> <li>Groovy/Grails </li> <li>Python/Django </li> <li>Ruby/Rails</li> <li>Turbogear</li> <li>Cappuccino or Sproutcore</li> <li>Javascript/jQuery</li> </ul>
8
2009-03-18T04:41:21Z
657,026
<p>You should wait until you get an answer from someone who's used more than one of those. That said (I've only used rails, python, and javascript), one way to frame it would be as a balance between sheer intellectual joy and practicality. My thoughts on Rails and Python from that perspective:</p> <ul> <li><p>Rails is going to be different and interesting, and it was hip in 2005-2007. There may be something more hip now. (Hip counts when you want to get future colleagues excited about what you've done, when they haven't done it.) I'd venture that it's at least as eye-opening as something based on LISP or Smalltalk or Haskell, but probably more practical because you may actually end up using it at a job or for contract work. Clojure, Seaside, and HAppS sound really cool, but until one of them really catches on, you're unlikely to ever use any of that stuff again in your career unless you're a computer science PhD working with other PhD's. (<strong>Edit in response to comments:</strong> please don't read this as a disparagement of those frameworks. As Rayne and MarkusQ have noted, depending on your motivations, they may be just what you're looking for. I'm just trying to communicate one method for weighing the alternatives based on your goals.)</p></li> <li><p>Python is a great language to know all around. I haven't used Django, but it has some industry traction (not as much as rails). Python as a language though will serve you well no matter what you do -- it's great for banging out utility scripts and rapidly prototyping ideas. There's a huge community and tons of libraries.</p></li> </ul> <p>You can gauge a technology's potential usefulness for moneymaking by searching for it on craigslist, dice.com, monster.com, etc.</p>
4
2009-03-18T05:02:49Z
[ "python", "asp.net-mvc", "ruby", "groovy", "clojure" ]
Tired of ASP.NET, which of the following should I learn and why?
656,987
<p>Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why</p> <ul> <li>Clojure/Compojure+Ring/Moustache+Ring</li> <li>Groovy/Grails </li> <li>Python/Django </li> <li>Ruby/Rails</li> <li>Turbogear</li> <li>Cappuccino or Sproutcore</li> <li>Javascript/jQuery</li> </ul>
8
2009-03-18T04:41:21Z
657,029
<p><strong>Javascript</strong>, because the skills you learn will complement your current Asp.net skills.</p>
6
2009-03-18T05:03:18Z
[ "python", "asp.net-mvc", "ruby", "groovy", "clojure" ]
Tired of ASP.NET, which of the following should I learn and why?
656,987
<p>Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why</p> <ul> <li>Clojure/Compojure+Ring/Moustache+Ring</li> <li>Groovy/Grails </li> <li>Python/Django </li> <li>Ruby/Rails</li> <li>Turbogear</li> <li>Cappuccino or Sproutcore</li> <li>Javascript/jQuery</li> </ul>
8
2009-03-18T04:41:21Z
657,138
<p>OK, first, apparently we all need a pants check. Done?</p> <p>I'm of two minds:</p> <ol> <li><p>if you are looking for a practical language / platform to pick up that you hope to use to help you in your day-to-day then I'd go with Python/Django. Python has developed into a really sweat and powerful language and Django is as nice a web development MVC as any other and pretty easy to pick up and get going with. You can run it locally, its easy to deploy on Apache w/ mod_python. Did I mention that Python is a really nice language? Also good support in the tools world, google app engine etc....</p></li> <li><p>if you are looking to expand your thinking/though processes about the way you program and think about programming then I'm with Joel Spolsky - choose HAppS (Joel would go Haslkell) or Clojure which I've not used but I've done a lot of lisp and it makes you think different and the language constructs like the macro capability will change the way you think of solving problems</p></li> </ol>
12
2009-03-18T06:14:25Z
[ "python", "asp.net-mvc", "ruby", "groovy", "clojure" ]
Tired of ASP.NET, which of the following should I learn and why?
656,987
<p>Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why</p> <ul> <li>Clojure/Compojure+Ring/Moustache+Ring</li> <li>Groovy/Grails </li> <li>Python/Django </li> <li>Ruby/Rails</li> <li>Turbogear</li> <li>Cappuccino or Sproutcore</li> <li>Javascript/jQuery</li> </ul>
8
2009-03-18T04:41:21Z
657,198
<p>Have you tried ASP.NET MVC? It is actually very different to ASP.NET (vanilla), but retains your knowledge of the .NET framework. Most people wouldn't look back...</p> <p>With the view based on <strong>your</strong> html (rather than whatever the controls decide to emit), it is also ideally placed to work alongside jQuery (it is even installed in the default project template) for all your dhtml/ajax needs.</p> <p>Resources:</p> <ul> <li><a href="http://www.manning.com/palermo/" rel="nofollow">ASP.NET MVC in Action</a></li> <li><a href="http://www.manning.com/bibeault/" rel="nofollow">jQuery in Action</a></li> </ul>
30
2009-03-18T06:51:46Z
[ "python", "asp.net-mvc", "ruby", "groovy", "clojure" ]
Tired of ASP.NET, which of the following should I learn and why?
656,987
<p>Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why</p> <ul> <li>Clojure/Compojure+Ring/Moustache+Ring</li> <li>Groovy/Grails </li> <li>Python/Django </li> <li>Ruby/Rails</li> <li>Turbogear</li> <li>Cappuccino or Sproutcore</li> <li>Javascript/jQuery</li> </ul>
8
2009-03-18T04:41:21Z
657,797
<p>Ruby on Rails, because that's what I use.</p>
1
2009-03-18T11:04:48Z
[ "python", "asp.net-mvc", "ruby", "groovy", "clojure" ]
Tired of ASP.NET, which of the following should I learn and why?
656,987
<p>Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why</p> <ul> <li>Clojure/Compojure+Ring/Moustache+Ring</li> <li>Groovy/Grails </li> <li>Python/Django </li> <li>Ruby/Rails</li> <li>Turbogear</li> <li>Cappuccino or Sproutcore</li> <li>Javascript/jQuery</li> </ul>
8
2009-03-18T04:41:21Z
658,881
<p>Definitely <strong>clojure</strong>. It is the most different of all languages mentioned in the list, so it would be probably most fun to learn / use.</p>
4
2009-03-18T15:52:52Z
[ "python", "asp.net-mvc", "ruby", "groovy", "clojure" ]
Tired of ASP.NET, which of the following should I learn and why?
656,987
<p>Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why</p> <ul> <li>Clojure/Compojure+Ring/Moustache+Ring</li> <li>Groovy/Grails </li> <li>Python/Django </li> <li>Ruby/Rails</li> <li>Turbogear</li> <li>Cappuccino or Sproutcore</li> <li>Javascript/jQuery</li> </ul>
8
2009-03-18T04:41:21Z
670,621
<p>I have worked with several technologies... not touched ASP. NET. Heard about it from other people who are under its influence.<br /> I have started working with Ruby on Rails and it is fun. Since you want to learn and develop web sites, you should go for Ruby on Rails. There are lot of things you can do with RoR on web. I like things that you can do with RMagick. (cropping images, thumbnails,slideshow etc) Talk about multi-lingual sites... and there you have "gettext". I vote for RoR.</p>
1
2009-03-22T06:45:02Z
[ "python", "asp.net-mvc", "ruby", "groovy", "clojure" ]
Tired of ASP.NET, which of the following should I learn and why?
656,987
<p>Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why</p> <ul> <li>Clojure/Compojure+Ring/Moustache+Ring</li> <li>Groovy/Grails </li> <li>Python/Django </li> <li>Ruby/Rails</li> <li>Turbogear</li> <li>Cappuccino or Sproutcore</li> <li>Javascript/jQuery</li> </ul>
8
2009-03-18T04:41:21Z
670,680
<p>Let's start by clarifying your question. Why are you "tired of ASP.NET?" Is it because of the tedious webforms model that tries so hard to protect you from the browser/server conversation that it ends up getting in the way?</p> <p>Or is it because you have been trying to work with one of the tiresome 3rd party enhancement controls that build on the tedium of the webforms model?</p> <p>Or do are you simply tired of working with five different languages at once: ASP.NET, HTML, CSS, Javascript, and C#/VB?</p> <p>If you answered yes to the first two of these questions here's some advice:</p> <ol> <li>Get some rest.</li> <li>Try ASP.NET MVC. It gets out of your way and lets you work with the browser and IIS</li> <li>Realize that changing web development models will be difficult no matter which one you choose to move to. The path is smoother the fewer things you change (see number 2).</li> </ol> <p>If you answered yes only to the 3rd question (five different languages) then all I can tell you is, welcome to web development. It will be this way for awhile.</p>
8
2009-03-22T07:56:43Z
[ "python", "asp.net-mvc", "ruby", "groovy", "clojure" ]
Tired of ASP.NET, which of the following should I learn and why?
656,987
<p>Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why</p> <ul> <li>Clojure/Compojure+Ring/Moustache+Ring</li> <li>Groovy/Grails </li> <li>Python/Django </li> <li>Ruby/Rails</li> <li>Turbogear</li> <li>Cappuccino or Sproutcore</li> <li>Javascript/jQuery</li> </ul>
8
2009-03-18T04:41:21Z
681,944
<p>I've used Ruby on Rails but also have done quite a bit of Groovy and Grails work. If you don't have any previous experience I would go with either of those. They're both fun to learn, pretty easy, and are very powerful.</p> <p>They're both backed up by frameworks: Ruby had Rails/Merb Groovy has Grails</p> <p>They can both use jQuery.</p> <p>I don't know much about Python/Django combination.</p>
0
2009-03-25T14:50:06Z
[ "python", "asp.net-mvc", "ruby", "groovy", "clojure" ]
Tired of ASP.NET, which of the following should I learn and why?
656,987
<p>Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why</p> <ul> <li>Clojure/Compojure+Ring/Moustache+Ring</li> <li>Groovy/Grails </li> <li>Python/Django </li> <li>Ruby/Rails</li> <li>Turbogear</li> <li>Cappuccino or Sproutcore</li> <li>Javascript/jQuery</li> </ul>
8
2009-03-18T04:41:21Z
691,195
<p>I've started to learn Ruby on Rails along with MVC (since conceptually there similar) and found it a great relief from the same routine with .Net.</p>
0
2009-03-27T19:33:42Z
[ "python", "asp.net-mvc", "ruby", "groovy", "clojure" ]
Tired of ASP.NET, which of the following should I learn and why?
656,987
<p>Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why</p> <ul> <li>Clojure/Compojure+Ring/Moustache+Ring</li> <li>Groovy/Grails </li> <li>Python/Django </li> <li>Ruby/Rails</li> <li>Turbogear</li> <li>Cappuccino or Sproutcore</li> <li>Javascript/jQuery</li> </ul>
8
2009-03-18T04:41:21Z
691,259
<p>Nobody seems to be voting for groovy. I'd go for that. I don't know anything about grails, but groovy the language is pretty cool. In the past nine months at my job I've been required to learn python and ruby. In the process I also took some time to understand groovy. groovy is the language that had me hooked before I finished reading the first chapter of Groovy in Action. </p> <p>Ruby is the one I'm actively using now, and while I did nothing but python for six months that's my least favorite of the bunch. Python is not a bad language per se, I just didn't enjoy using it. I find ruby to be a very pleasant language and am glad I had the opportunity to learn it.</p> <p>Fully learning javascript might be the more practical choice, but I'd still vote for Groovy. I'm anxious to find an opportunity to use it at work. </p>
3
2009-03-27T19:53:25Z
[ "python", "asp.net-mvc", "ruby", "groovy", "clojure" ]
Tired of ASP.NET, which of the following should I learn and why?
656,987
<p>Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why</p> <ul> <li>Clojure/Compojure+Ring/Moustache+Ring</li> <li>Groovy/Grails </li> <li>Python/Django </li> <li>Ruby/Rails</li> <li>Turbogear</li> <li>Cappuccino or Sproutcore</li> <li>Javascript/jQuery</li> </ul>
8
2009-03-18T04:41:21Z
703,688
<p>I'll add in my vote for Groovy, as well as another one for Ruby. Both Grails and Rails are excellent frameworks, although Rails will get you a job a lot sooner than Grails. Both are truly a pleasure to work with, and have actually made me enjoy coding again.</p> <p>Groovy is nice because you can use <em>any</em> Java library. So, lightning-fast database access, XML parsing, PDF generation, and so on. In a nutshell, Groovy is Java, if Java had been written by a bunch of Ruby guys.</p> <p>Grails is also great, although it's a lot buggier than Rails, and if you want to do anything complicated you're going to need to learn a bit about Spring, Hibernate, and Java. Grails does have better internationalization support and more deployment options, as well as a really good integrated scheduler (Quartz) for long-running and scheduled tasks.</p> <p>Rails is Ruby all the way down, so you can very easily read the framework code and figure out how things worked -- I did this in order to figure out how to implement a graph (data structure), and was really pleased with how easy it was to figure out how to change things.</p>
1
2009-04-01T01:19:14Z
[ "python", "asp.net-mvc", "ruby", "groovy", "clojure" ]
Tired of ASP.NET, which of the following should I learn and why?
656,987
<p>Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why</p> <ul> <li>Clojure/Compojure+Ring/Moustache+Ring</li> <li>Groovy/Grails </li> <li>Python/Django </li> <li>Ruby/Rails</li> <li>Turbogear</li> <li>Cappuccino or Sproutcore</li> <li>Javascript/jQuery</li> </ul>
8
2009-03-18T04:41:21Z
1,138,746
<p>Learn Ruby on Rails. It'll change the way you see web development. It did for me!</p> <p>A valid alternative is Django and Python. I don't use it, but I consider it to be just as good as Rails.</p>
1
2009-07-16T16:22:57Z
[ "python", "asp.net-mvc", "ruby", "groovy", "clojure" ]
Where can i get free GSM libraries/components for delphi or python?
657,100
<p>Where can i get good free GSM libraries for <strong>Delphi</strong> or <strong>Python</strong>? Libraries i can use to send and receive sms's on my application?</p> <p>Gath</p>
4
2009-03-18T05:47:08Z
657,190
<p>For free and open source <a href="http://sourceforge.net/projects/tpapro/" rel="nofollow">AsyncPro</a>></p> <p>Not free but the components has active development <a href="http://www.deepsoftware.com/nrcomm" rel="nofollow">nrComm Lib</a></p> <p>Another solution to use SMS gateway, such as <a href="http://www.clickatell.com/" rel="nofollow">ClickAtell</a>, with solution you can send sms using a simple post command to the gateway url or webservices.</p>
2
2009-03-18T06:47:04Z
[ "python", "delphi", "gsm" ]
Where can i get free GSM libraries/components for delphi or python?
657,100
<p>Where can i get good free GSM libraries for <strong>Delphi</strong> or <strong>Python</strong>? Libraries i can use to send and receive sms's on my application?</p> <p>Gath</p>
4
2009-03-18T05:47:08Z
698,892
<p>A <a href="http://pypi.python.org/pypi?%3aaction=search&amp;term=sms&amp;submit=search" rel="nofollow">PyPi search turns up several promising Python SMS libraries</a>. Some of them talk to a GSM modem, others work through web SMS gateways, and there's even one to interface with Apple's Sudden Motion Sensor.</p>
0
2009-03-30T20:34:20Z
[ "python", "delphi", "gsm" ]
Where can i get free GSM libraries/components for delphi or python?
657,100
<p>Where can i get good free GSM libraries for <strong>Delphi</strong> or <strong>Python</strong>? Libraries i can use to send and receive sms's on my application?</p> <p>Gath</p>
4
2009-03-18T05:47:08Z
755,535
<p><a href="http://sourceforge.net/projects/tpapro/" rel="nofollow">Get it here</a> - completely free (previously commercial components):</p>
1
2009-04-16T10:32:23Z
[ "python", "delphi", "gsm" ]
Where can i get free GSM libraries/components for delphi or python?
657,100
<p>Where can i get good free GSM libraries for <strong>Delphi</strong> or <strong>Python</strong>? Libraries i can use to send and receive sms's on my application?</p> <p>Gath</p>
4
2009-03-18T05:47:08Z
756,499
<p>I've always enjoyed <a href="http://fma.sf.net/" rel="nofollow">this application</a> with my Sony-Ericsson devices:</p>
0
2009-04-16T14:51:40Z
[ "python", "delphi", "gsm" ]
Where can i get free GSM libraries/components for delphi or python?
657,100
<p>Where can i get good free GSM libraries for <strong>Delphi</strong> or <strong>Python</strong>? Libraries i can use to send and receive sms's on my application?</p> <p>Gath</p>
4
2009-03-18T05:47:08Z
1,071,447
<p>Another SMS gateway with a Python interface is TextMagic.</p> <p>Read my response to a similar question <a href="http://stackoverflow.com/questions/716946/how-do-i-enable-sms-notifications-in-my-web-app/1071496#1071496">here</a></p>
1
2009-07-01T21:17:41Z
[ "python", "delphi", "gsm" ]
Python: Prevent fileinput from adding newline characters
657,186
<p>I am using a Python script to <strong>find and replace</strong> certain strings in text files of a given directory. I am using the <code>fileinput</code> module to ease the find-and-replace operation, i.e., the file is read, text replaced and written back to the same file.</p> <p>The code looks as follows:</p> <pre><code>import fileinput def fixFile(fileName): # Open file for in-place replace for line in fileinput.FileInput(fileName, inplace=1): line = line.replace("findStr", "replaceStr") print line # Put back line into file </code></pre> <p>The problem is that the written files have:</p> <ol> <li>One blank line inserted after <em>every</em> line.</li> <li>Ctrl-M character at the end of <em>every</em> line.</li> </ol> <p>How do I prevent these extra appendages from getting inserted into the files?</p>
15
2009-03-18T06:44:30Z
657,197
<p>Use </p> <pre><code>print line, </code></pre> <p>or</p> <pre><code>file.write(line) </code></pre> <p>to fix extra newlines.</p> <p>As of [Ctrl]-[M] - that is probably caused by input files in DOS encoding.</p>
9
2009-03-18T06:49:34Z
[ "python", "file-io" ]
Python: Prevent fileinput from adding newline characters
657,186
<p>I am using a Python script to <strong>find and replace</strong> certain strings in text files of a given directory. I am using the <code>fileinput</code> module to ease the find-and-replace operation, i.e., the file is read, text replaced and written back to the same file.</p> <p>The code looks as follows:</p> <pre><code>import fileinput def fixFile(fileName): # Open file for in-place replace for line in fileinput.FileInput(fileName, inplace=1): line = line.replace("findStr", "replaceStr") print line # Put back line into file </code></pre> <p>The problem is that the written files have:</p> <ol> <li>One blank line inserted after <em>every</em> line.</li> <li>Ctrl-M character at the end of <em>every</em> line.</li> </ol> <p>How do I prevent these extra appendages from getting inserted into the files?</p>
15
2009-03-18T06:44:30Z
657,199
<p>Your newlines are coming from the print function</p> <p>use:</p> <pre><code>import sys sys.stdout.write ('some stuff') </code></pre> <p>and your line breaks will go away</p>
26
2009-03-18T06:54:22Z
[ "python", "file-io" ]
Python: Prevent fileinput from adding newline characters
657,186
<p>I am using a Python script to <strong>find and replace</strong> certain strings in text files of a given directory. I am using the <code>fileinput</code> module to ease the find-and-replace operation, i.e., the file is read, text replaced and written back to the same file.</p> <p>The code looks as follows:</p> <pre><code>import fileinput def fixFile(fileName): # Open file for in-place replace for line in fileinput.FileInput(fileName, inplace=1): line = line.replace("findStr", "replaceStr") print line # Put back line into file </code></pre> <p>The problem is that the written files have:</p> <ol> <li>One blank line inserted after <em>every</em> line.</li> <li>Ctrl-M character at the end of <em>every</em> line.</li> </ol> <p>How do I prevent these extra appendages from getting inserted into the files?</p>
15
2009-03-18T06:44:30Z
886,951
<p>Instead of this:</p> <pre><code>print line # Put back line into file </code></pre> <p>use this:</p> <pre><code>print line, # Put back line into file </code></pre>
6
2009-05-20T09:06:39Z
[ "python", "file-io" ]
Python: Prevent fileinput from adding newline characters
657,186
<p>I am using a Python script to <strong>find and replace</strong> certain strings in text files of a given directory. I am using the <code>fileinput</code> module to ease the find-and-replace operation, i.e., the file is read, text replaced and written back to the same file.</p> <p>The code looks as follows:</p> <pre><code>import fileinput def fixFile(fileName): # Open file for in-place replace for line in fileinput.FileInput(fileName, inplace=1): line = line.replace("findStr", "replaceStr") print line # Put back line into file </code></pre> <p>The problem is that the written files have:</p> <ol> <li>One blank line inserted after <em>every</em> line.</li> <li>Ctrl-M character at the end of <em>every</em> line.</li> </ol> <p>How do I prevent these extra appendages from getting inserted into the files?</p>
15
2009-03-18T06:44:30Z
2,600,997
<p>Change the first line in your for loop to:</p> <p><code> line = line.rstrip().replace("findStr", "replaceStr")</code></p>
5
2010-04-08T15:04:01Z
[ "python", "file-io" ]
Python: Prevent fileinput from adding newline characters
657,186
<p>I am using a Python script to <strong>find and replace</strong> certain strings in text files of a given directory. I am using the <code>fileinput</code> module to ease the find-and-replace operation, i.e., the file is read, text replaced and written back to the same file.</p> <p>The code looks as follows:</p> <pre><code>import fileinput def fixFile(fileName): # Open file for in-place replace for line in fileinput.FileInput(fileName, inplace=1): line = line.replace("findStr", "replaceStr") print line # Put back line into file </code></pre> <p>The problem is that the written files have:</p> <ol> <li>One blank line inserted after <em>every</em> line.</li> <li>Ctrl-M character at the end of <em>every</em> line.</li> </ol> <p>How do I prevent these extra appendages from getting inserted into the files?</p>
15
2009-03-18T06:44:30Z
15,806,268
<p>Due to every iteration print statement ends with newline, you are getting blank line between lines.</p> <p>To overcome this problem, you can use strip along with print.</p> <pre><code>import fileinput def fixFile(fileName): for line in fileinput.FileInput(fileName, inplace=1): line = line.replace("findStr", "replaceStr") print line.strip() </code></pre> <p>Now, you can see blank lines are striped. </p>
0
2013-04-04T08:35:51Z
[ "python", "file-io" ]
Python: Prevent fileinput from adding newline characters
657,186
<p>I am using a Python script to <strong>find and replace</strong> certain strings in text files of a given directory. I am using the <code>fileinput</code> module to ease the find-and-replace operation, i.e., the file is read, text replaced and written back to the same file.</p> <p>The code looks as follows:</p> <pre><code>import fileinput def fixFile(fileName): # Open file for in-place replace for line in fileinput.FileInput(fileName, inplace=1): line = line.replace("findStr", "replaceStr") print line # Put back line into file </code></pre> <p>The problem is that the written files have:</p> <ol> <li>One blank line inserted after <em>every</em> line.</li> <li>Ctrl-M character at the end of <em>every</em> line.</li> </ol> <p>How do I prevent these extra appendages from getting inserted into the files?</p>
15
2009-03-18T06:44:30Z
30,756,723
<p>For the update on Python 4.3, you can just use: </p> <pre><code>print(line, end = '') </code></pre> <p>to avoid the insertion of a new line.</p>
0
2015-06-10T12:43:29Z
[ "python", "file-io" ]
How to access Yahoo Enterprise Web Services using Python SOAPpy?
657,473
<p>I have a PHP script which works and i need to write the same in Python but SOAPpy generates a slightly different request and i'm not sure how to fix it so the server likes it.</p> <p>The request generated by php script looks like this:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://marketing.ews.yahooapis.com/V4" &gt; &lt;SOAP-ENV:Header&gt; &lt;ns1:username&gt;*****&lt;/ns1:username&gt; &lt;ns1:password&gt;*****&lt;/ns1:password&gt; &lt;ns1:masterAccountID&gt;*****&lt;/ns1:masterAccountID&gt; &lt;ns1:accountID&gt;6674262970&lt;/ns1:accountID&gt; &lt;ns1:license&gt;*****&lt;/ns1:license&gt; &lt;/SOAP-ENV:Header&gt; &lt;SOAP-ENV:Body&gt; &lt;ns1:getCampaignsByAccountID&gt; &lt;ns1:accountID&gt;6674262970&lt;/ns1:accountID&gt; &lt;ns1:includeDeleted&gt;false&lt;/ns1:includeDeleted&gt; &lt;/ns1:getCampaignsByAccountID&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>When trying to make the same using SOAPPy i get this request:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" &gt; &lt;SOAP-ENV:Header&gt; &lt;username xsi:type="xsd:string"&gt;*****&lt;/username&gt; &lt;masterAccountID xsi:type="xsd:string"&gt;*****&lt;/masterAccountID&gt; &lt;license xsi:type="xsd:string"&gt;*****&lt;/license&gt; &lt;accountID xsi:type="xsd:integer"&gt;6674262970&lt;/accountID&gt; &lt;password xsi:type="xsd:string"&gt;*****&lt;/password&gt; &lt;/SOAP-ENV:Header&gt; &lt;SOAP-ENV:Body&gt; &lt;ns1:getCampaignsByAccountID xmlns:ns1="http://marketing.ews.yahooapis.com/V4"&gt; &lt;includeDeleted xsi:type="xsd:boolean"&gt;False&lt;/includeDeleted&gt; &lt;accountID xsi:type="xsd:integer"&gt;6674262970&lt;/accountID&gt; &lt;/ns1:getCampaignsByAccountID&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>A slightly different request but i guess it should work but i get an error from the server: "Account ID specified in the </p> <p>header does not match the one specified in the parameter."</p> <p>But they do match!</p> <p>The only thing i see is some difference in namespaces, but i have no idea what to do right now. Please help.</p>
0
2009-03-18T09:08:57Z
657,753
<p>accountID should be of type xsd:string rather than xsd:integer. (maybe you're passing a string instead of an integer and that is why SOAPpy does it that way?)</p>
0
2009-03-18T10:46:21Z
[ "python", "soap", "soappy" ]
How to access Yahoo Enterprise Web Services using Python SOAPpy?
657,473
<p>I have a PHP script which works and i need to write the same in Python but SOAPpy generates a slightly different request and i'm not sure how to fix it so the server likes it.</p> <p>The request generated by php script looks like this:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://marketing.ews.yahooapis.com/V4" &gt; &lt;SOAP-ENV:Header&gt; &lt;ns1:username&gt;*****&lt;/ns1:username&gt; &lt;ns1:password&gt;*****&lt;/ns1:password&gt; &lt;ns1:masterAccountID&gt;*****&lt;/ns1:masterAccountID&gt; &lt;ns1:accountID&gt;6674262970&lt;/ns1:accountID&gt; &lt;ns1:license&gt;*****&lt;/ns1:license&gt; &lt;/SOAP-ENV:Header&gt; &lt;SOAP-ENV:Body&gt; &lt;ns1:getCampaignsByAccountID&gt; &lt;ns1:accountID&gt;6674262970&lt;/ns1:accountID&gt; &lt;ns1:includeDeleted&gt;false&lt;/ns1:includeDeleted&gt; &lt;/ns1:getCampaignsByAccountID&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>When trying to make the same using SOAPPy i get this request:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" &gt; &lt;SOAP-ENV:Header&gt; &lt;username xsi:type="xsd:string"&gt;*****&lt;/username&gt; &lt;masterAccountID xsi:type="xsd:string"&gt;*****&lt;/masterAccountID&gt; &lt;license xsi:type="xsd:string"&gt;*****&lt;/license&gt; &lt;accountID xsi:type="xsd:integer"&gt;6674262970&lt;/accountID&gt; &lt;password xsi:type="xsd:string"&gt;*****&lt;/password&gt; &lt;/SOAP-ENV:Header&gt; &lt;SOAP-ENV:Body&gt; &lt;ns1:getCampaignsByAccountID xmlns:ns1="http://marketing.ews.yahooapis.com/V4"&gt; &lt;includeDeleted xsi:type="xsd:boolean"&gt;False&lt;/includeDeleted&gt; &lt;accountID xsi:type="xsd:integer"&gt;6674262970&lt;/accountID&gt; &lt;/ns1:getCampaignsByAccountID&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>A slightly different request but i guess it should work but i get an error from the server: "Account ID specified in the </p> <p>header does not match the one specified in the parameter."</p> <p>But they do match!</p> <p>The only thing i see is some difference in namespaces, but i have no idea what to do right now. Please help.</p>
0
2009-03-18T09:08:57Z
760,722
<p>The problem was not about SOAP headers format but just about the parameter order. Here's the full explanation and code: <a href="http://pea.somemilk.org/2009/04/05/yahoo-search-marketing-python-soap-binding/" rel="nofollow">http://pea.somemilk.org/2009/04/05/yahoo-search-marketing-python-soap-binding/</a></p>
1
2009-04-17T14:54:47Z
[ "python", "soap", "soappy" ]
Python : is it ok returning both boolean and string?
657,857
<p>Original Question</p> <p>I have made a function which is waiting for a particular string to appear on a serial port, and returns all character read until the string was found, or false if not. This is quite convenient, but I was wondering if it is considered bad practice or not ?</p> <p>Clarification :</p> <p>The primary goal is to wait for a <strong>particular</strong> string to appear in a given amount of time. Except for IO error, the possible outcome is True (the string did appear) or False The secondary goal is to get the entire output, because there might be information that I would like to parse for before the actual answer that is looked for. I thought may be I could combine the primary and secondary goal in one return value.</p> <pre><code>def MyFunc(s, timeout) : test = get_some_input(timeout) if test.endswith(s) return test else return False </code></pre> <p>Edit : Another proposed answer is to raise an exception. I don't think it is a good idea, because the timeout is an expected behaviour. I mean, if there is a parameter for specifying a timeout, then a timeout is a possible outcome, and not an exception.</p> <p>Edit 2 : Since I need to store the input, maybe using a class is the right solution. The wait for function has a clear return value, yet the entire string that was read until timeout is also accessible.</p> <pre><code>class Parser : def __init__(self, sport_name): self.currentMsg = '' self.ser = serial.Serial(sport_name, 115200) def WaitFor(self, s, timeOut=None): self.ser.timeout = timeOut self.currentMsg = '' while self.currentMsg.endswith(s) != True : # should add a try catch here c=self.ser.read() if c != '' : self.currentMsg += c else : print 'timeout waiting for ' + s return False return True </code></pre>
7
2009-03-18T11:26:18Z
657,861
<p>Would it not be more suitable to return a <code>None</code> instead of <code>False</code>?</p>
25
2009-03-18T11:28:22Z
[ "python" ]
Python : is it ok returning both boolean and string?
657,857
<p>Original Question</p> <p>I have made a function which is waiting for a particular string to appear on a serial port, and returns all character read until the string was found, or false if not. This is quite convenient, but I was wondering if it is considered bad practice or not ?</p> <p>Clarification :</p> <p>The primary goal is to wait for a <strong>particular</strong> string to appear in a given amount of time. Except for IO error, the possible outcome is True (the string did appear) or False The secondary goal is to get the entire output, because there might be information that I would like to parse for before the actual answer that is looked for. I thought may be I could combine the primary and secondary goal in one return value.</p> <pre><code>def MyFunc(s, timeout) : test = get_some_input(timeout) if test.endswith(s) return test else return False </code></pre> <p>Edit : Another proposed answer is to raise an exception. I don't think it is a good idea, because the timeout is an expected behaviour. I mean, if there is a parameter for specifying a timeout, then a timeout is a possible outcome, and not an exception.</p> <p>Edit 2 : Since I need to store the input, maybe using a class is the right solution. The wait for function has a clear return value, yet the entire string that was read until timeout is also accessible.</p> <pre><code>class Parser : def __init__(self, sport_name): self.currentMsg = '' self.ser = serial.Serial(sport_name, 115200) def WaitFor(self, s, timeOut=None): self.ser.timeout = timeOut self.currentMsg = '' while self.currentMsg.endswith(s) != True : # should add a try catch here c=self.ser.read() if c != '' : self.currentMsg += c else : print 'timeout waiting for ' + s return False return True </code></pre>
7
2009-03-18T11:26:18Z
657,862
<p>The convenient thing is to return an empty string in this case.</p> <p>Besides an empty string in Python will evaluate to False anyway. So you could call it like:</p> <pre><code>if Myfunc(s, timeout): print "success" </code></pre> <p>Addition: As pointed out by S.Lott the true Pythonic way is to return None. Though I choose to return strings in string related funcs. A matter of preference indeed.</p> <p>Also I assume the caller of Myfunc only cares about getting a string to manipulate on - empty or not. If the caller needs to check about timeout issues, etc.. it's better to use exceptions or returning None.</p>
5
2009-03-18T11:28:38Z
[ "python" ]
Python : is it ok returning both boolean and string?
657,857
<p>Original Question</p> <p>I have made a function which is waiting for a particular string to appear on a serial port, and returns all character read until the string was found, or false if not. This is quite convenient, but I was wondering if it is considered bad practice or not ?</p> <p>Clarification :</p> <p>The primary goal is to wait for a <strong>particular</strong> string to appear in a given amount of time. Except for IO error, the possible outcome is True (the string did appear) or False The secondary goal is to get the entire output, because there might be information that I would like to parse for before the actual answer that is looked for. I thought may be I could combine the primary and secondary goal in one return value.</p> <pre><code>def MyFunc(s, timeout) : test = get_some_input(timeout) if test.endswith(s) return test else return False </code></pre> <p>Edit : Another proposed answer is to raise an exception. I don't think it is a good idea, because the timeout is an expected behaviour. I mean, if there is a parameter for specifying a timeout, then a timeout is a possible outcome, and not an exception.</p> <p>Edit 2 : Since I need to store the input, maybe using a class is the right solution. The wait for function has a clear return value, yet the entire string that was read until timeout is also accessible.</p> <pre><code>class Parser : def __init__(self, sport_name): self.currentMsg = '' self.ser = serial.Serial(sport_name, 115200) def WaitFor(self, s, timeOut=None): self.ser.timeout = timeOut self.currentMsg = '' while self.currentMsg.endswith(s) != True : # should add a try catch here c=self.ser.read() if c != '' : self.currentMsg += c else : print 'timeout waiting for ' + s return False return True </code></pre>
7
2009-03-18T11:26:18Z
657,864
<p>Maybe if you return a tuple like (False, None) and (True, test) it would be better, as you can evaluate them separatedly and not add unnecesary complexity.</p> <p>EDIT: Perhaps the string that appeared on the serial port is "" (maybe expected), so returning True can say that it arrived that way.</p>
3
2009-03-18T11:28:57Z
[ "python" ]
Python : is it ok returning both boolean and string?
657,857
<p>Original Question</p> <p>I have made a function which is waiting for a particular string to appear on a serial port, and returns all character read until the string was found, or false if not. This is quite convenient, but I was wondering if it is considered bad practice or not ?</p> <p>Clarification :</p> <p>The primary goal is to wait for a <strong>particular</strong> string to appear in a given amount of time. Except for IO error, the possible outcome is True (the string did appear) or False The secondary goal is to get the entire output, because there might be information that I would like to parse for before the actual answer that is looked for. I thought may be I could combine the primary and secondary goal in one return value.</p> <pre><code>def MyFunc(s, timeout) : test = get_some_input(timeout) if test.endswith(s) return test else return False </code></pre> <p>Edit : Another proposed answer is to raise an exception. I don't think it is a good idea, because the timeout is an expected behaviour. I mean, if there is a parameter for specifying a timeout, then a timeout is a possible outcome, and not an exception.</p> <p>Edit 2 : Since I need to store the input, maybe using a class is the right solution. The wait for function has a clear return value, yet the entire string that was read until timeout is also accessible.</p> <pre><code>class Parser : def __init__(self, sport_name): self.currentMsg = '' self.ser = serial.Serial(sport_name, 115200) def WaitFor(self, s, timeOut=None): self.ser.timeout = timeOut self.currentMsg = '' while self.currentMsg.endswith(s) != True : # should add a try catch here c=self.ser.read() if c != '' : self.currentMsg += c else : print 'timeout waiting for ' + s return False return True </code></pre>
7
2009-03-18T11:26:18Z
658,125
<p>You could return the string if it arrived in time, or raise a suitable exception indicating time out.</p>
5
2009-03-18T12:47:39Z
[ "python" ]
Python : is it ok returning both boolean and string?
657,857
<p>Original Question</p> <p>I have made a function which is waiting for a particular string to appear on a serial port, and returns all character read until the string was found, or false if not. This is quite convenient, but I was wondering if it is considered bad practice or not ?</p> <p>Clarification :</p> <p>The primary goal is to wait for a <strong>particular</strong> string to appear in a given amount of time. Except for IO error, the possible outcome is True (the string did appear) or False The secondary goal is to get the entire output, because there might be information that I would like to parse for before the actual answer that is looked for. I thought may be I could combine the primary and secondary goal in one return value.</p> <pre><code>def MyFunc(s, timeout) : test = get_some_input(timeout) if test.endswith(s) return test else return False </code></pre> <p>Edit : Another proposed answer is to raise an exception. I don't think it is a good idea, because the timeout is an expected behaviour. I mean, if there is a parameter for specifying a timeout, then a timeout is a possible outcome, and not an exception.</p> <p>Edit 2 : Since I need to store the input, maybe using a class is the right solution. The wait for function has a clear return value, yet the entire string that was read until timeout is also accessible.</p> <pre><code>class Parser : def __init__(self, sport_name): self.currentMsg = '' self.ser = serial.Serial(sport_name, 115200) def WaitFor(self, s, timeOut=None): self.ser.timeout = timeOut self.currentMsg = '' while self.currentMsg.endswith(s) != True : # should add a try catch here c=self.ser.read() if c != '' : self.currentMsg += c else : print 'timeout waiting for ' + s return False return True </code></pre>
7
2009-03-18T11:26:18Z
658,145
<p>I believe the orthodox Python design would be to return None. The <a href="http://docs.python.org/reference/datamodel.html#the-standard-type-hierarchy" rel="nofollow">manual</a> says:</p> <blockquote> <p>None</p> <p>This type has a single value. There is a single object with this value. This object is accessed through the built-in name None. It is used to signify the absence of a value in many situations, e.g., it is returned from functions that don’t explicitly return anything. Its truth value is false.</p> </blockquote>
10
2009-03-18T12:53:35Z
[ "python" ]
Python : is it ok returning both boolean and string?
657,857
<p>Original Question</p> <p>I have made a function which is waiting for a particular string to appear on a serial port, and returns all character read until the string was found, or false if not. This is quite convenient, but I was wondering if it is considered bad practice or not ?</p> <p>Clarification :</p> <p>The primary goal is to wait for a <strong>particular</strong> string to appear in a given amount of time. Except for IO error, the possible outcome is True (the string did appear) or False The secondary goal is to get the entire output, because there might be information that I would like to parse for before the actual answer that is looked for. I thought may be I could combine the primary and secondary goal in one return value.</p> <pre><code>def MyFunc(s, timeout) : test = get_some_input(timeout) if test.endswith(s) return test else return False </code></pre> <p>Edit : Another proposed answer is to raise an exception. I don't think it is a good idea, because the timeout is an expected behaviour. I mean, if there is a parameter for specifying a timeout, then a timeout is a possible outcome, and not an exception.</p> <p>Edit 2 : Since I need to store the input, maybe using a class is the right solution. The wait for function has a clear return value, yet the entire string that was read until timeout is also accessible.</p> <pre><code>class Parser : def __init__(self, sport_name): self.currentMsg = '' self.ser = serial.Serial(sport_name, 115200) def WaitFor(self, s, timeOut=None): self.ser.timeout = timeOut self.currentMsg = '' while self.currentMsg.endswith(s) != True : # should add a try catch here c=self.ser.read() if c != '' : self.currentMsg += c else : print 'timeout waiting for ' + s return False return True </code></pre>
7
2009-03-18T11:26:18Z
659,335
<p>It would be better to return a string AND a boolean (as in the title) instead of returning a string OR a boolean. You shouldn't have to figure out what the return value means. It should be totally explicit and orthogonal issues should be separated into different variables.</p> <pre><code>(okay,value) = get_some_input(blah); if (okay): print value </code></pre> <p>I tend not to return tuples a lot, because it feels funny. But it's perfectly valid to do so.</p> <p>Returning "None" is a valid solution, already mentioned here.</p>
6
2009-03-18T17:32:43Z
[ "python" ]
Python : is it ok returning both boolean and string?
657,857
<p>Original Question</p> <p>I have made a function which is waiting for a particular string to appear on a serial port, and returns all character read until the string was found, or false if not. This is quite convenient, but I was wondering if it is considered bad practice or not ?</p> <p>Clarification :</p> <p>The primary goal is to wait for a <strong>particular</strong> string to appear in a given amount of time. Except for IO error, the possible outcome is True (the string did appear) or False The secondary goal is to get the entire output, because there might be information that I would like to parse for before the actual answer that is looked for. I thought may be I could combine the primary and secondary goal in one return value.</p> <pre><code>def MyFunc(s, timeout) : test = get_some_input(timeout) if test.endswith(s) return test else return False </code></pre> <p>Edit : Another proposed answer is to raise an exception. I don't think it is a good idea, because the timeout is an expected behaviour. I mean, if there is a parameter for specifying a timeout, then a timeout is a possible outcome, and not an exception.</p> <p>Edit 2 : Since I need to store the input, maybe using a class is the right solution. The wait for function has a clear return value, yet the entire string that was read until timeout is also accessible.</p> <pre><code>class Parser : def __init__(self, sport_name): self.currentMsg = '' self.ser = serial.Serial(sport_name, 115200) def WaitFor(self, s, timeOut=None): self.ser.timeout = timeOut self.currentMsg = '' while self.currentMsg.endswith(s) != True : # should add a try catch here c=self.ser.read() if c != '' : self.currentMsg += c else : print 'timeout waiting for ' + s return False return True </code></pre>
7
2009-03-18T11:26:18Z
659,437
<p>To add to Ber's point, you might want to take something else into account. If you use an empty string or None, you leave the door open for bugs of the "dumb" variety. On the other hand, if you raise an exception, you're forcing the execution of whatever operation is running to be aborted.</p> <p>For example, consider the following code:</p> <pre><code>result = MyFunc(s, timeout) if result[0] == 'a': do_something() </code></pre> <p>This will raise an exception if the operation timed out and got either an empty string or None. So you'd have to change that to:</p> <pre><code>result = MyFunc(s, timeout) if result and result[0] == 'a': do_something() </code></pre> <p>These kinds of changes tend to add up and make your code more difficult to understand.</p> <p>Of course, I'm sure that your answer to this will be something along the lines of "I won't do that" or "that won't happen" to which my answer is "Even if you don't run into it with this function, you will eventually if you make a habit of doing this." These kinds of bugs are almost always the result of corner cases that you don't usually think about.</p>
2
2009-03-18T17:58:29Z
[ "python" ]
Python : is it ok returning both boolean and string?
657,857
<p>Original Question</p> <p>I have made a function which is waiting for a particular string to appear on a serial port, and returns all character read until the string was found, or false if not. This is quite convenient, but I was wondering if it is considered bad practice or not ?</p> <p>Clarification :</p> <p>The primary goal is to wait for a <strong>particular</strong> string to appear in a given amount of time. Except for IO error, the possible outcome is True (the string did appear) or False The secondary goal is to get the entire output, because there might be information that I would like to parse for before the actual answer that is looked for. I thought may be I could combine the primary and secondary goal in one return value.</p> <pre><code>def MyFunc(s, timeout) : test = get_some_input(timeout) if test.endswith(s) return test else return False </code></pre> <p>Edit : Another proposed answer is to raise an exception. I don't think it is a good idea, because the timeout is an expected behaviour. I mean, if there is a parameter for specifying a timeout, then a timeout is a possible outcome, and not an exception.</p> <p>Edit 2 : Since I need to store the input, maybe using a class is the right solution. The wait for function has a clear return value, yet the entire string that was read until timeout is also accessible.</p> <pre><code>class Parser : def __init__(self, sport_name): self.currentMsg = '' self.ser = serial.Serial(sport_name, 115200) def WaitFor(self, s, timeOut=None): self.ser.timeout = timeOut self.currentMsg = '' while self.currentMsg.endswith(s) != True : # should add a try catch here c=self.ser.read() if c != '' : self.currentMsg += c else : print 'timeout waiting for ' + s return False return True </code></pre>
7
2009-03-18T11:26:18Z
671,300
<p>This is a classic use case for Python generators. The <code>yield</code> keyword provides a simple way to iterate over discrete sets without returning the whole thing at once:</p> <pre><code>def MyFunc(s, timeout) : test = get_some_input(timeout) while test.endswith(s) yield test test = get_some_input(timeout) for input in MyFunc(s, timeout): print input </code></pre> <p>The key here is there is no return value to specify the end of input; instead, you simply reach the end of the iterator. More information on generators <a href="http://www.python.org/dev/peps/pep-0255/" rel="nofollow">here</a>.</p>
1
2009-03-22T17:06:20Z
[ "python" ]
How do I find the modules that are available for import from within a package?
657,868
<p>Is there a way of knowing which modules are available to import from inside a package?</p>
2
2009-03-18T11:30:35Z
657,883
<p>Many packages will include a list called <code>__all__</code>, which lists the member modules. This is used when python does <code>from x import *</code>. You can read more about that <a href="http://docs.python.org/tutorial/modules.html#importing-from-a-package" rel="nofollow">here</a>.</p> <p>If the package does not define <code>__all__</code>, you'll have to do something like the answer to a question I asked earlier, <a href="http://stackoverflow.com/questions/487971/is-there-a-standard-way-to-list-names-of-python-modules-in-a-package">here</a>.</p>
3
2009-03-18T11:35:47Z
[ "python", "import" ]
How do I find the modules that are available for import from within a package?
657,868
<p>Is there a way of knowing which modules are available to import from inside a package?</p>
2
2009-03-18T11:30:35Z
657,927
<p>import fred</p> <p>print dir(fred)</p>
-2
2009-03-18T11:51:05Z
[ "python", "import" ]
How do I find the modules that are available for import from within a package?
657,868
<p>Is there a way of knowing which modules are available to import from inside a package?</p>
2
2009-03-18T11:30:35Z
658,158
<p>You have the source.</p> <p>Look at the files inside the package directory. Those modules are available for you to import.</p>
-1
2009-03-18T12:57:33Z
[ "python", "import" ]
How do I find the modules that are available for import from within a package?
657,868
<p>Is there a way of knowing which modules are available to import from inside a package?</p>
2
2009-03-18T11:30:35Z
659,680
<p>dir([object]);</p> <p>Without arguments, dir() return the list of names in the current local scope. With an argument, attempt to return a list of valid attributes for that object.</p> <p>So, in the case of a module, such as 'sys':</p> <pre><code>&gt;&gt;&gt; import sys &gt;&gt;&gt; dir(sys) ['__displayhook__', '__doc__', '__excepthook__', '__name__', '__stderr__', '__stdin__', '__stdout__', '_current_frames', '_getframe', 'api_version', 'argv', 'builtin_module_names', 'byteorder', 'call_tracing', 'callstats', 'copyright', 'displayhook', 'exc_clear', 'exc_info', 'exc_type', 'excepthook', 'exec_prefix', 'executable', 'exit', 'getcheckinterval', 'getdefaultencoding', 'getdlopenflags', 'getfilesystemencoding', 'getrecursionlimit', 'getrefcount', 'hexversion', 'maxint', 'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks', 'path_importer_cache', 'platform', 'prefix', 'ps1', 'ps2', 'pydebug', 'setcheckinterval', 'setdlopenflags', 'setprofile', 'setrecursionlimit', 'settrace', 'stderr', 'stdin', 'stdout', 'subversion', 'version', 'version_info', 'warnoptions'] </code></pre> <p>That's all there is to it.</p>
-1
2009-03-18T19:08:31Z
[ "python", "import" ]
How would you implement a basic event-loop?
658,403
<p>If you have worked with gui toolkits, you know that there is a event-loop/main-loop that should be executed after everything is done, and that will keep the application alive and responsive to different events. For example, for Qt, you would do this in main():</p> <pre><code>int main() { QApplication app(argc, argv); // init code return app.exec(); } </code></pre> <p>Which in this case, app.exec() is the application's main-loop.</p> <p>The obvious way to implement this kind of loop would be:</p> <pre><code>void exec() { while (1) { process_events(); // create a thread for each new event (possibly?) } } </code></pre> <p>But this caps the CPU to 100% and is practicaly useless. Now, how can I implement such an event loop that is responsive without eating the CPU altogether?</p> <p>Answers are appreciated in Python and/or C++. Thanks.</p> <p>Footnote: For the sake of learning, I will implement my own signals/slots, and I would use those to generate custom events (e.g. <code>go_forward_event(steps)</code>). But if you know how I can use system events manually, I would like to know about that too.</p>
42
2009-03-18T14:12:02Z
658,459
<p>Generally I would do this with some sort of <a href="http://en.wikipedia.org/wiki/Semaphore%5F%28programming%29">counting semaphore</a>:</p> <ol> <li>Semaphore starts at zero.</li> <li>Event loop waits on semaphore.</li> <li>Event(s) come in, semaphore is incremented.</li> <li>Event handler unblocks and decrements the semaphore and processes the event.</li> <li>When all events are processed, semaphore is zero and event loop blocks again.</li> </ol> <p>If you don't want to get that complicated, you could just add a sleep() call in your while loop with a trivially small sleep time. That will cause your message processing thread to yield it's CPU time to other threads. The CPU won't be pegged at 100% any more, but it's still pretty wasteful.</p>
11
2009-03-18T14:23:12Z
[ "c++", "python", "blocking", "event-loop" ]
How would you implement a basic event-loop?
658,403
<p>If you have worked with gui toolkits, you know that there is a event-loop/main-loop that should be executed after everything is done, and that will keep the application alive and responsive to different events. For example, for Qt, you would do this in main():</p> <pre><code>int main() { QApplication app(argc, argv); // init code return app.exec(); } </code></pre> <p>Which in this case, app.exec() is the application's main-loop.</p> <p>The obvious way to implement this kind of loop would be:</p> <pre><code>void exec() { while (1) { process_events(); // create a thread for each new event (possibly?) } } </code></pre> <p>But this caps the CPU to 100% and is practicaly useless. Now, how can I implement such an event loop that is responsive without eating the CPU altogether?</p> <p>Answers are appreciated in Python and/or C++. Thanks.</p> <p>Footnote: For the sake of learning, I will implement my own signals/slots, and I would use those to generate custom events (e.g. <code>go_forward_event(steps)</code>). But if you know how I can use system events manually, I would like to know about that too.</p>
42
2009-03-18T14:12:02Z
658,495
<p>I used to wonder a lot about the same!</p> <p>A GUI main loop looks like this, in pseudo-code:</p> <pre><code>void App::exec() { for(;;) { vector&lt;Waitable&gt; waitables; waitables.push_back(m_networkSocket); waitables.push_back(m_xConnection); waitables.push_back(m_globalTimer); Waitable* whatHappened = System::waitOnAll(waitables); switch(whatHappened) { case &amp;m_networkSocket: readAndDispatchNetworkEvent(); break; case &amp;m_xConnection: readAndDispatchGuiEvent(); break; case &amp;m_globalTimer: readAndDispatchTimerEvent(); break; } } } </code></pre> <p>What is a "Waitable"? Well, it's system dependant. On UNIX it's called a "file descriptor" and "waitOnAll" is the ::select system call. The so-called <code>vector&lt;Waitable&gt;</code> is a <code>::fd_set</code> on UNIX, and "whatHappened" is actually queried via <code>FD_ISSET</code>. The actual waitable-handles are acquired in various ways, for example <code>m_xConnection</code> can be taken from ::XConnectionNumber(). X11 also provides a high-level, portable API for this -- ::XNextEvent() -- but if you were to use that, you wouldn't be able to wait on several event sources <em>simultaneously</em>.</p> <p>How does the blocking work? "waitOnAll" is a syscall that tells the OS to put your process on a "sleep list". This means you are not given any CPU time until an event occurs on one of the waitables. This, then, means your process is idle, consuming 0% CPU. When an event occurs, your process will briefly react to it and then return to idle state. GUI apps spend almost <em>all</em> their time idling.</p> <p>What happens to all the CPU cycles while you're sleeping? Depends. Sometimes another process will have a use for them. If not, your OS will busy-loop the CPU, or put it into temporary low-power mode, etc.</p> <p>Please ask for further details!</p>
53
2009-03-18T14:29:21Z
[ "c++", "python", "blocking", "event-loop" ]
How would you implement a basic event-loop?
658,403
<p>If you have worked with gui toolkits, you know that there is a event-loop/main-loop that should be executed after everything is done, and that will keep the application alive and responsive to different events. For example, for Qt, you would do this in main():</p> <pre><code>int main() { QApplication app(argc, argv); // init code return app.exec(); } </code></pre> <p>Which in this case, app.exec() is the application's main-loop.</p> <p>The obvious way to implement this kind of loop would be:</p> <pre><code>void exec() { while (1) { process_events(); // create a thread for each new event (possibly?) } } </code></pre> <p>But this caps the CPU to 100% and is practicaly useless. Now, how can I implement such an event loop that is responsive without eating the CPU altogether?</p> <p>Answers are appreciated in Python and/or C++. Thanks.</p> <p>Footnote: For the sake of learning, I will implement my own signals/slots, and I would use those to generate custom events (e.g. <code>go_forward_event(steps)</code>). But if you know how I can use system events manually, I would like to know about that too.</p>
42
2009-03-18T14:12:02Z
659,070
<p>I would use a simple, light-weight messaging library called ZeroMQ (<a href="http://www.zeromq.org/">http://www.zeromq.org/</a>). It is an open source library (LGPL). This is a very small library; on my server, the whole project compiles in about 60 seconds. </p> <p>ZeroMQ will hugely simplify your event-driven code, AND it is also THE most efficient solution in terms of performance. Communicating between threads using ZeroMQ is much faster (in terms of speed) than using semaphores or local UNIX sockets. ZeroMQ also be a 100% portable solution, whereas all the other solutions would tie your code down to a specific operating system. </p>
9
2009-03-18T16:37:08Z
[ "c++", "python", "blocking", "event-loop" ]
How would you implement a basic event-loop?
658,403
<p>If you have worked with gui toolkits, you know that there is a event-loop/main-loop that should be executed after everything is done, and that will keep the application alive and responsive to different events. For example, for Qt, you would do this in main():</p> <pre><code>int main() { QApplication app(argc, argv); // init code return app.exec(); } </code></pre> <p>Which in this case, app.exec() is the application's main-loop.</p> <p>The obvious way to implement this kind of loop would be:</p> <pre><code>void exec() { while (1) { process_events(); // create a thread for each new event (possibly?) } } </code></pre> <p>But this caps the CPU to 100% and is practicaly useless. Now, how can I implement such an event loop that is responsive without eating the CPU altogether?</p> <p>Answers are appreciated in Python and/or C++. Thanks.</p> <p>Footnote: For the sake of learning, I will implement my own signals/slots, and I would use those to generate custom events (e.g. <code>go_forward_event(steps)</code>). But if you know how I can use system events manually, I would like to know about that too.</p>
42
2009-03-18T14:12:02Z
660,785
<p>Python:</p> <p>You can look at the implementation of the <a href="http://docs.huihoo.com/python/twisted/howto/reactor-basics.html">Twisted reactor</a> which is probably the best implementation for an event loop in python. Reactors in Twisted are implementations of an interface and you can specify a type reactor to run: select, epoll, kqueue (all based on a c api using those system calls), there are also reactors based on the QT and GTK toolkits.</p> <p>A simple implementation would be to use select:</p> <pre><code>#echo server that accepts multiple client connections without forking threads import select import socket import sys host = '' port = 50000 backlog = 5 size = 1024 server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server.bind((host,port)) server.listen(backlog) input = [server,sys.stdin] running = 1 #the eventloop running while running: inputready,outputready,exceptready = select.select(input,[],[]) for s in inputready: if s == server: # handle the server socket client, address = server.accept() input.append(client) elif s == sys.stdin: # handle standard input junk = sys.stdin.readline() running = 0 else: # handle all other sockets data = s.recv(size) if data: s.send(data) else: s.close() input.remove(s) server.close() </code></pre>
17
2009-03-19T01:45:14Z
[ "c++", "python", "blocking", "event-loop" ]
How do I suppress scientific notation in Python?
658,763
<p>Here's my code:</p> <pre><code>x = 1.0 y = 100000.0 print x/y </code></pre> <p>My quotient displays as <code>1.00000e-05</code></p> <p>Is there any way to suppress scientific notation and make it display as <code>0.00001</code>? How to convert the scientific notation into <code>float</code>. </p> <p>Thanks in advance.<br> This feels somewhat ridiculous to ask but I haven't figured out a way to do it yet. I'm going to use the result as a string.</p>
44
2009-03-18T15:27:21Z
658,777
<pre><code>'%f' % (x/y) </code></pre> <p>but you need to manage precision yourself. e.g.,</p> <pre><code>'%f' % (1/10**8) </code></pre> <p>will display zeros only.<br> <a href="http://docs.python.org/library/stdtypes.html#string-formatting-operations">details are in the docs</a></p> <p>Or for Python 3 <a href="http://docs.python.org/py3k/library/stdtypes.html#old-string-formatting-operations">the equivalent old formatting</a> or the <a href="http://docs.python.org/py3k/library/string.html#string-formatting">newer style formatting</a></p>
25
2009-03-18T15:30:48Z
[ "python", "floating-point" ]
How do I suppress scientific notation in Python?
658,763
<p>Here's my code:</p> <pre><code>x = 1.0 y = 100000.0 print x/y </code></pre> <p>My quotient displays as <code>1.00000e-05</code></p> <p>Is there any way to suppress scientific notation and make it display as <code>0.00001</code>? How to convert the scientific notation into <code>float</code>. </p> <p>Thanks in advance.<br> This feels somewhat ridiculous to ask but I haven't figured out a way to do it yet. I'm going to use the result as a string.</p>
44
2009-03-18T15:27:21Z
658,796
<p>In addition to SG's answer, you can also use the Decimal module:</p> <pre><code>from decimal import Decimal x = str(Decimal(1) / Decimal(10000)) # x is a string '0.0001' </code></pre>
3
2009-03-18T15:34:09Z
[ "python", "floating-point" ]
How do I suppress scientific notation in Python?
658,763
<p>Here's my code:</p> <pre><code>x = 1.0 y = 100000.0 print x/y </code></pre> <p>My quotient displays as <code>1.00000e-05</code></p> <p>Is there any way to suppress scientific notation and make it display as <code>0.00001</code>? How to convert the scientific notation into <code>float</code>. </p> <p>Thanks in advance.<br> This feels somewhat ridiculous to ask but I haven't figured out a way to do it yet. I'm going to use the result as a string.</p>
44
2009-03-18T15:27:21Z
5,463,788
<p>With newer versions of Python (2.6 and later), you can use <a href="http://docs.python.org/library/string.html#format-string-syntax"><code>''.format()</code></a> to accomplish what @SilentGhost suggested:</p> <pre><code>'{0:f}'.format(x/y) </code></pre>
24
2011-03-28T19:05:07Z
[ "python", "floating-point" ]
How do I suppress scientific notation in Python?
658,763
<p>Here's my code:</p> <pre><code>x = 1.0 y = 100000.0 print x/y </code></pre> <p>My quotient displays as <code>1.00000e-05</code></p> <p>Is there any way to suppress scientific notation and make it display as <code>0.00001</code>? How to convert the scientific notation into <code>float</code>. </p> <p>Thanks in advance.<br> This feels somewhat ridiculous to ask but I haven't figured out a way to do it yet. I'm going to use the result as a string.</p>
44
2009-03-18T15:27:21Z
28,361,728
<p>If it is a <code>string</code> then use the built in <code>float</code> on it to do the conversion for instance: <code>print( "%.5f" % float("1.43572e-03"))</code> answer:<code>0.00143572</code></p>
1
2015-02-06T08:43:32Z
[ "python", "floating-point" ]
How do I suppress scientific notation in Python?
658,763
<p>Here's my code:</p> <pre><code>x = 1.0 y = 100000.0 print x/y </code></pre> <p>My quotient displays as <code>1.00000e-05</code></p> <p>Is there any way to suppress scientific notation and make it display as <code>0.00001</code>? How to convert the scientific notation into <code>float</code>. </p> <p>Thanks in advance.<br> This feels somewhat ridiculous to ask but I haven't figured out a way to do it yet. I'm going to use the result as a string.</p>
44
2009-03-18T15:27:21Z
33,219,633
<p>Using the newer version <code>''.format</code> (also remember to specify how many digit after the <code>.</code> you wish to display, this depends on how small is the floating number). See this example:</p> <pre><code>&gt;&gt;&gt; a = -7.1855143557448603e-17 &gt;&gt;&gt; '{:f}'.format(a) '-0.000000' </code></pre> <p>as shown above, default is 6 digits! This is not helpful for our case example, so instead we could use something like this:</p> <pre><code>&gt;&gt;&gt; '{:.20f}'.format(a) '-0.00000000000000007186' </code></pre>
15
2015-10-19T16:41:27Z
[ "python", "floating-point" ]
Linking to Python import library in Visual Studio 2005
658,879
<p>I have a C++ application that has embedded Python. I'm building with Visual Studio 2005. When I try to link to python26.lib, I get a number of unresolved symbols, all of which begin with "__imp":</p> <p>error LNK2019: unresolved external symbol __imp__Py_Initialize referenced in function _main</p> <p>python26.lib is an import library (installed by the Python 2.6 installer). What do I have to do to resolve these symbols? They do exist in the import library (dumpbin /all shows them). Thanks.</p>
8
2009-03-18T15:52:48Z
659,107
<p>Try to include <code>C:\WINDOWS\system32\python26.dll</code> in your references. <code>python26.lib</code> contains the symbol names for the main DLL.</p>
2
2009-03-18T16:45:12Z
[ "python", "visual-studio", "import", "linker" ]
Linking to Python import library in Visual Studio 2005
658,879
<p>I have a C++ application that has embedded Python. I'm building with Visual Studio 2005. When I try to link to python26.lib, I get a number of unresolved symbols, all of which begin with "__imp":</p> <p>error LNK2019: unresolved external symbol __imp__Py_Initialize referenced in function _main</p> <p>python26.lib is an import library (installed by the Python 2.6 installer). What do I have to do to resolve these symbols? They do exist in the import library (dumpbin /all shows them). Thanks.</p>
8
2009-03-18T15:52:48Z
660,181
<p>Looks like I was trying to link a 64-bit Python library to a 32-bit application. I wish the linker would tell me something other than "unresolved symbol." Linking to the 32-bit library fixes the problem. </p>
9
2009-03-18T21:26:04Z
[ "python", "visual-studio", "import", "linker" ]
pinging mysql using mysql alchemy and python
658,888
<p>how do i ping mysql using mysql alchemy and python?</p>
0
2009-03-18T15:54:39Z
659,387
<p>Use mysqlshow to see if MySQL is running as expected.</p> <p><a href="http://dev.mysql.com/doc/refman/5.1/en/mysqlshow.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.1/en/mysqlshow.html</a></p> <p>Assure that SQLAlchemy has supprt for MySQL.</p> <p><a href="http://www.sqlalchemy.org/docs/05/dbengine.html#supported-dbapis" rel="nofollow">http://www.sqlalchemy.org/docs/05/dbengine.html#supported-dbapis</a></p> <p>Use a simple query through SQLAlchemy.</p> <p><a href="http://www.sqlalchemy.org/docs/05/ormtutorial.html" rel="nofollow">http://www.sqlalchemy.org/docs/05/ormtutorial.html</a></p>
2
2009-03-18T17:44:57Z
[ "python", "mysql" ]
Python equivalent to "php -s"
658,939
<p>As you may or may not know, you can generate a color syntax-higlighted HTML file from a PHP source file using <strong>php -s</strong>.</p> <p>I know about the <a href="http://code.google.com/p/syntaxhighlighter/" rel="nofollow">syntaxhighlighter</a> that Stackoverflow uses and that's not really what I'm looking for. I'm looking for something will generate HTML output without Javascript.</p> Does anyone know of something equivalent to <strong><em>php</em></strong> -<strong><em>s</em></strong> for Python?
6
2009-03-18T16:10:57Z
659,016
<pre><code>$ pygmentize -O full -O style=native -o test.html test.py </code></pre> <p>To install <a href="http://pygments.org/" rel="nofollow">Pygments</a>:</p> <pre><code>$ easy_install Pygments </code></pre> <p>You can use it as a library.</p> <pre><code>from pygments import highlight from pygments.lexers import guess_lexer from pygments.formatters import HtmlFormatter code = '#!/usr/bin/python\nprint "Hello World!"' lexer = guess_lexer(code) # or just pygments.lexers.PythonLexer() formatter = HtmlFormatter(noclasses=True, nowrap=True, lineseparator="&lt;br&gt;\n") print highlight(code, lexer, formatter) </code></pre> <p>Output:</p> <pre><code>&lt;span style="color: #408080; font-style: italic"&gt;#!/usr/bin/python&lt;/span&gt;&lt;br&gt; &lt;span style="color: #008000; font-weight: bold"&gt;print&lt;/span&gt; &lt;span style="color: #BA2121"&gt;&amp;quot;Hello World!&amp;quot;&lt;/span&gt;&lt;br&gt; </code></pre> <p>(added whitespace for clarity)</p> <p>As html:</p> <p>#!/usr/bin/python<br> print &quot;Hello World!&quot;<br></p>
12
2009-03-18T16:26:33Z
[ "php", "python", "syntax-highlighting" ]
Python equivalent to "php -s"
658,939
<p>As you may or may not know, you can generate a color syntax-higlighted HTML file from a PHP source file using <strong>php -s</strong>.</p> <p>I know about the <a href="http://code.google.com/p/syntaxhighlighter/" rel="nofollow">syntaxhighlighter</a> that Stackoverflow uses and that's not really what I'm looking for. I'm looking for something will generate HTML output without Javascript.</p> Does anyone know of something equivalent to <strong><em>php</em></strong> -<strong><em>s</em></strong> for Python?
6
2009-03-18T16:10:57Z
659,022
<p>If you have access to kwrite from KDE, you can export a file as HTML which will have the same colorization that you use for editing. This works for all languages.</p>
0
2009-03-18T16:29:04Z
[ "php", "python", "syntax-highlighting" ]
Python equivalent to "php -s"
658,939
<p>As you may or may not know, you can generate a color syntax-higlighted HTML file from a PHP source file using <strong>php -s</strong>.</p> <p>I know about the <a href="http://code.google.com/p/syntaxhighlighter/" rel="nofollow">syntaxhighlighter</a> that Stackoverflow uses and that's not really what I'm looking for. I'm looking for something will generate HTML output without Javascript.</p> Does anyone know of something equivalent to <strong><em>php</em></strong> -<strong><em>s</em></strong> for Python?
6
2009-03-18T16:10:57Z
659,036
<p>if you need only a few files to convert to html pages and are on windows you can use Notepad++. It comes (as of last versions) with NppExport plugin, that let's one to convert source code to highlighted HTML and RTF (according to your colouring scheme). It works not only with python of course, but with any language you can use in Notepad++.</p>
0
2009-03-18T16:32:24Z
[ "php", "python", "syntax-highlighting" ]
Python equivalent to "php -s"
658,939
<p>As you may or may not know, you can generate a color syntax-higlighted HTML file from a PHP source file using <strong>php -s</strong>.</p> <p>I know about the <a href="http://code.google.com/p/syntaxhighlighter/" rel="nofollow">syntaxhighlighter</a> that Stackoverflow uses and that's not really what I'm looking for. I'm looking for something will generate HTML output without Javascript.</p> Does anyone know of something equivalent to <strong><em>php</em></strong> -<strong><em>s</em></strong> for Python?
6
2009-03-18T16:10:57Z
1,340,657
<p>I found Highlight at <a href="http://www.andre-simon.de" rel="nofollow">http://www.andre-simon.de</a> to be an extremely good tool for doing this. It is Open-source (GPL'ed though!)</p>
1
2009-08-27T12:08:56Z
[ "php", "python", "syntax-highlighting" ]
Accessing Microsoft Automation Objects from Python
659,018
<p>I have a set of macros that I have turned into an add-in in excel. The macros allow me to interact with another program that has what are called Microsoft Automation Objects that provide some control over what the other program does. For example, I have a filter tool in the add-in that filters the list provided by the other program to match a list in the Excel workbook. This is slow though. I might have fifty thousand lines in the other program and want to filter out all of the lines that don't match a list of three thousand lines in Excel. This type of matching takes about 30-40 minutes. I have begun wondering if there is way to do this with Python instead since I suspect the matching process could be done in seconds.</p> <p>Edited:</p> <p>Thanks- Based on the suggestion to look at Hammond's book I found out a number of resources. However, though I am still exploring it looks like many of these are old. For example, Hammond's book was published in 2000, which means the writing was finished almost a decade ago. Correction I just found the package called PyWin32 with a 2/2009 build. </p> <p>This should get me started. Thanks</p>
4
2009-03-18T16:28:03Z
659,090
<p>Mark Hammond and Andy Robinson have written <a href="http://shop.oreilly.com/product/9781565926219.do" rel="nofollow">the book</a> on accessing Windows COM objects from Python.</p> <p><a href="http://books.google.com/books?id=ns1WMyLVnRMC&amp;pg=PA198&amp;lpg=PA198&amp;dq=python+microsoft+automation+objects&amp;source=bl&amp;ots=NVoi1KaePn&amp;sig=U7PW8ttWlZumpqiLrzWSBL8IxSU&amp;hl=en&amp;ei=FyPBSYWUA4mMsAPSptgv&amp;sa=X&amp;oi=book_result&amp;resnum=1&amp;ct=result#PPA198,M1" rel="nofollow">Here</a> is an example using Excel.</p>
4
2009-03-18T16:41:32Z
[ "python", "object", "automation" ]
Accessing Microsoft Automation Objects from Python
659,018
<p>I have a set of macros that I have turned into an add-in in excel. The macros allow me to interact with another program that has what are called Microsoft Automation Objects that provide some control over what the other program does. For example, I have a filter tool in the add-in that filters the list provided by the other program to match a list in the Excel workbook. This is slow though. I might have fifty thousand lines in the other program and want to filter out all of the lines that don't match a list of three thousand lines in Excel. This type of matching takes about 30-40 minutes. I have begun wondering if there is way to do this with Python instead since I suspect the matching process could be done in seconds.</p> <p>Edited:</p> <p>Thanks- Based on the suggestion to look at Hammond's book I found out a number of resources. However, though I am still exploring it looks like many of these are old. For example, Hammond's book was published in 2000, which means the writing was finished almost a decade ago. Correction I just found the package called PyWin32 with a 2/2009 build. </p> <p>This should get me started. Thanks</p>
4
2009-03-18T16:28:03Z
659,092
<p>As far as I know it is possible to create COM objects (which is what Automation objects are) in Python on Windows. Then assuming you can get out the lists via automation it should be easy to do what you want in python.</p>
0
2009-03-18T16:42:07Z
[ "python", "object", "automation" ]
Accessing Microsoft Automation Objects from Python
659,018
<p>I have a set of macros that I have turned into an add-in in excel. The macros allow me to interact with another program that has what are called Microsoft Automation Objects that provide some control over what the other program does. For example, I have a filter tool in the add-in that filters the list provided by the other program to match a list in the Excel workbook. This is slow though. I might have fifty thousand lines in the other program and want to filter out all of the lines that don't match a list of three thousand lines in Excel. This type of matching takes about 30-40 minutes. I have begun wondering if there is way to do this with Python instead since I suspect the matching process could be done in seconds.</p> <p>Edited:</p> <p>Thanks- Based on the suggestion to look at Hammond's book I found out a number of resources. However, though I am still exploring it looks like many of these are old. For example, Hammond's book was published in 2000, which means the writing was finished almost a decade ago. Correction I just found the package called PyWin32 with a 2/2009 build. </p> <p>This should get me started. Thanks</p>
4
2009-03-18T16:28:03Z
659,221
<blockquote> <p>However, though I am still exploring it looks like many of these are old. </p> </blockquote> <p>COM is old. The interface hasn't changed since at least 1993. </p> <blockquote> <p>I also don't see the package on the Python.org website. I searched for COM packages but didn't see anything useful.</p> </blockquote> <p><a href="http://python.net/crew/mhammond/win32/" rel="nofollow">http://python.net/crew/mhammond/win32/</a> <a href="http://sourceforge.net/projects/pywin32/" rel="nofollow">http://sourceforge.net/projects/pywin32/</a></p> <p>The latest update was Feb 2009, which include Python 3.0 support.</p>
0
2009-03-18T17:09:48Z
[ "python", "object", "automation" ]