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 listlengths 1 5 |
|---|---|---|---|---|---|---|---|---|---|
Threading TCP Server as proxy between connected user and unix socket | 833,962 | <p>I'm writing web application where I need to push data from server to the connected clients. This data can be send from any other script from web application. For example one user make some changes on the server and other users should be notified about that. </p>
<p>So my idea is to use unix socket (path to socket b... | 0 | 2009-05-07T10:46:21Z | 1,005,054 | <p>You should use Twisted, or, more specifically, <a href="http://orbited.org/" rel="nofollow">Orbited</a>, to push data to your clients. The sample code you posted has a number of potential problems, and it would be a lot harder to figure out what they all are than for you to just use a pre-built piece of code to do ... | 0 | 2009-06-17T03:56:57Z | [
"python",
"multithreading",
"sockets",
"tcp"
] |
How to install python-igraph on Ubuntu 8.04 LTS 64-Bit? | 834,076 | <p>Apparently <code>libigraph</code> and <code>python-igraph</code> are the only packages on earth that can't be installed via <code>apt-get</code> or <code>easy_install</code> under Ubuntu 8.04 LTS 64-bit.</p>
<p>Installing both from source from source on seems to go smoothly...until I try to use them.</p>
<p>When I... | 4 | 2009-05-07T11:13:10Z | 834,098 | <p>Where is libigraph.so.0 ? It doesn't seem to be in a location that python looks for such as /usr/lib , /usr/local/lib etc.</p>
| 0 | 2009-05-07T11:18:36Z | [
"python",
"64bit",
"ubuntu-8.04",
"igraph"
] |
How to install python-igraph on Ubuntu 8.04 LTS 64-Bit? | 834,076 | <p>Apparently <code>libigraph</code> and <code>python-igraph</code> are the only packages on earth that can't be installed via <code>apt-get</code> or <code>easy_install</code> under Ubuntu 8.04 LTS 64-bit.</p>
<p>Installing both from source from source on seems to go smoothly...until I try to use them.</p>
<p>When I... | 4 | 2009-05-07T11:13:10Z | 836,948 | <p>How did you compile? Did you do a make install (if there was any).</p>
<p>As for the 'library not found' error in the easy_install version, i'd try the following:</p>
<ol>
<li>'<code>sudo updatedb</code>' (to update the locate database)</li>
<li>'<code>locate libigraph.so.0</code>' (to find where this file is on y... | 11 | 2009-05-07T20:48:20Z | [
"python",
"64bit",
"ubuntu-8.04",
"igraph"
] |
How to install python-igraph on Ubuntu 8.04 LTS 64-Bit? | 834,076 | <p>Apparently <code>libigraph</code> and <code>python-igraph</code> are the only packages on earth that can't be installed via <code>apt-get</code> or <code>easy_install</code> under Ubuntu 8.04 LTS 64-bit.</p>
<p>Installing both from source from source on seems to go smoothly...until I try to use them.</p>
<p>When I... | 4 | 2009-05-07T11:13:10Z | 1,648,339 | <p>I followed the steps in <a href="http://socialsynergyweb.org/network/blog/install-python-igraph-ubuntu-904-64-bit" rel="nofollow">http://socialsynergyweb.org/network/blog/install-python-igraph-ubuntu-904-64-bit</a>. Also to run the actual igraph , i used the script python-igraph-0.5.2/scripts/igraph. Now i am able t... | 0 | 2009-10-30T06:38:41Z | [
"python",
"64bit",
"ubuntu-8.04",
"igraph"
] |
How to install python-igraph on Ubuntu 8.04 LTS 64-Bit? | 834,076 | <p>Apparently <code>libigraph</code> and <code>python-igraph</code> are the only packages on earth that can't be installed via <code>apt-get</code> or <code>easy_install</code> under Ubuntu 8.04 LTS 64-bit.</p>
<p>Installing both from source from source on seems to go smoothly...until I try to use them.</p>
<p>When I... | 4 | 2009-05-07T11:13:10Z | 1,762,839 | <p>Note that there are official Ubuntu packages for igraph available from Launchpad as of 8 Nov 2009. See the corresponding <a href="https://launchpad.net/~igraph/+archive/ppa" rel="nofollow">page</a> on Launchpad for instructions. Unlike the earlier Debian package repository, this should work on both 32-bit and 64-bit... | 2 | 2009-11-19T12:05:35Z | [
"python",
"64bit",
"ubuntu-8.04",
"igraph"
] |
Python ASCII Graph Drawing | 834,395 | <p>I'm looking for a library to draw ASCII graphs (for use in a console) with Python. The graph is quite simple: it's only a flow chart for pipelines.</p>
<p>I saw NetworkX and igraph, but didn't see a way to output to ascii.</p>
<p>Do you have experience in this?</p>
<p>Thanks a lot!</p>
<p>Patrick</p>
<p>EDIT 1:... | 17 | 2009-05-07T12:33:34Z | 834,433 | <p>It's not directly Python based, but you should take a look into the artist-mode of emacs</p>
<ul>
<li><a href="http://www.youtube.com/watch?v=LDbi56U5qRw" rel="nofollow">artist-mode video</a></li>
<li><a href="http://www.lysator.liu.se/~tab/artist/" rel="nofollow">artist-mode site</a></li>
</ul>
<p>You can control... | 1 | 2009-05-07T12:41:18Z | [
"python",
"graph",
"ascii"
] |
Python ASCII Graph Drawing | 834,395 | <p>I'm looking for a library to draw ASCII graphs (for use in a console) with Python. The graph is quite simple: it's only a flow chart for pipelines.</p>
<p>I saw NetworkX and igraph, but didn't see a way to output to ascii.</p>
<p>Do you have experience in this?</p>
<p>Thanks a lot!</p>
<p>Patrick</p>
<p>EDIT 1:... | 17 | 2009-05-07T12:33:34Z | 834,578 | <p>When you say 'simple network graph in ascii', do you mean something like this?</p>
<pre><code>.===. .===. .===. .===.
| a |---| b |---| c |---| d |
'===' '===' '---' '==='
</code></pre>
<p>I suspect there are probably better ways to display whatever information it is that you have than to try and draw ... | 0 | 2009-05-07T13:12:33Z | [
"python",
"graph",
"ascii"
] |
Python ASCII Graph Drawing | 834,395 | <p>I'm looking for a library to draw ASCII graphs (for use in a console) with Python. The graph is quite simple: it's only a flow chart for pipelines.</p>
<p>I saw NetworkX and igraph, but didn't see a way to output to ascii.</p>
<p>Do you have experience in this?</p>
<p>Thanks a lot!</p>
<p>Patrick</p>
<p>EDIT 1:... | 17 | 2009-05-07T12:33:34Z | 834,736 | <p>To draw networks, <a href="http://dkbza.org/pydot.html" rel="nofollow">pydot</a> might be a more convenient solution than matplotlib. It is based on graphviz (<a href="http://www.graphviz.org/Gallery.php" rel="nofollow">gallery</a>).</p>
| 0 | 2009-05-07T13:47:08Z | [
"python",
"graph",
"ascii"
] |
Python ASCII Graph Drawing | 834,395 | <p>I'm looking for a library to draw ASCII graphs (for use in a console) with Python. The graph is quite simple: it's only a flow chart for pipelines.</p>
<p>I saw NetworkX and igraph, but didn't see a way to output to ascii.</p>
<p>Do you have experience in this?</p>
<p>Thanks a lot!</p>
<p>Patrick</p>
<p>EDIT 1:... | 17 | 2009-05-07T12:33:34Z | 1,983,374 | <p><a href="http://www.algorithm.co.il/blogs/index.php/ascii-plotter/" rel="nofollow">ascii-plotter</a> might do what you want...</p>
| 2 | 2009-12-31T00:47:32Z | [
"python",
"graph",
"ascii"
] |
How to do fuzzy string search without a heavy database? | 834,570 | <p>I have a mapping of catalog numbers to product names:</p>
<pre><code>35 cozy comforter
35 warm blanket
67 pillow
</code></pre>
<p>and <strong>need a search that would find misspelled, mixed names like "warm cmfrter"</strong>.</p>
<p>We have code using edit-distance (difflib), but it probably won't scale to the... | 6 | 2009-05-07T13:11:30Z | 834,656 | <p><a href="http://nucular.sourceforge.net" rel="nofollow">Nucular</a>
has full text search, but it doesn't support misspelled matches
out-of-the box. You could try adding an additional field to each entry
which indexes the
<a href="http://code.activestate.com/recipes/52213/" rel="nofollow">SOUNDEX</a> translation of ... | 2 | 2009-05-07T13:30:32Z | [
"python",
"database",
"full-text-search",
"fuzzy-search"
] |
How to do fuzzy string search without a heavy database? | 834,570 | <p>I have a mapping of catalog numbers to product names:</p>
<pre><code>35 cozy comforter
35 warm blanket
67 pillow
</code></pre>
<p>and <strong>need a search that would find misspelled, mixed names like "warm cmfrter"</strong>.</p>
<p>We have code using edit-distance (difflib), but it probably won't scale to the... | 6 | 2009-05-07T13:11:30Z | 834,941 | <p>You will get too many false positives with the SOUNDEX implementation. There are only 26,000 (at most) possible SOUNDEX codes.</p>
<p>Though the Metaphone algorithim was designed for English surnames, it works pretty well for misspellings; I used it once in a branch locator and it was quite successful. </p>
<p>Add... | 2 | 2009-05-07T14:23:58Z | [
"python",
"database",
"full-text-search",
"fuzzy-search"
] |
How to do fuzzy string search without a heavy database? | 834,570 | <p>I have a mapping of catalog numbers to product names:</p>
<pre><code>35 cozy comforter
35 warm blanket
67 pillow
</code></pre>
<p>and <strong>need a search that would find misspelled, mixed names like "warm cmfrter"</strong>.</p>
<p>We have code using edit-distance (difflib), but it probably won't scale to the... | 6 | 2009-05-07T13:11:30Z | 838,768 | <p>The usual way of computing the edit-distance between two strings is a rather expensive algorithm (if I remember correctly, its time complexity is quadratic). Maybe if you used a different string similarity metric then your problem would go away.</p>
<p>One of my favorite methods for fuzzy string matching is [trigra... | 1 | 2009-05-08T08:20:32Z | [
"python",
"database",
"full-text-search",
"fuzzy-search"
] |
How to do fuzzy string search without a heavy database? | 834,570 | <p>I have a mapping of catalog numbers to product names:</p>
<pre><code>35 cozy comforter
35 warm blanket
67 pillow
</code></pre>
<p>and <strong>need a search that would find misspelled, mixed names like "warm cmfrter"</strong>.</p>
<p>We have code using edit-distance (difflib), but it probably won't scale to the... | 6 | 2009-05-07T13:11:30Z | 869,212 | <p><a href="http://www.sybase.com/products/databasemanagement/sqlanywhere" rel="nofollow">Sybase SQL Anywhere</a> has a free Web edition/Developer Edition and comes with full text indexing/search and a FUZZY operator (and some implementation constraints). </p>
<p>To quote from the documentation:</p>
<pre><code>Specif... | 1 | 2009-05-15T15:02:52Z | [
"python",
"database",
"full-text-search",
"fuzzy-search"
] |
How to do fuzzy string search without a heavy database? | 834,570 | <p>I have a mapping of catalog numbers to product names:</p>
<pre><code>35 cozy comforter
35 warm blanket
67 pillow
</code></pre>
<p>and <strong>need a search that would find misspelled, mixed names like "warm cmfrter"</strong>.</p>
<p>We have code using edit-distance (difflib), but it probably won't scale to the... | 6 | 2009-05-07T13:11:30Z | 1,080,769 | <p>Apparently the only way to make fuzzy comparisons fast is to do less of them ;)</p>
<p>Instead of writing another n-gram search or improving the one in Whoosh we now keep a word index, retrieve all entries that have at least one (correctly spelled) word in common with the query, and use difflib to rank those. Works... | 4 | 2009-07-03T20:46:04Z | [
"python",
"database",
"full-text-search",
"fuzzy-search"
] |
How to do fuzzy string search without a heavy database? | 834,570 | <p>I have a mapping of catalog numbers to product names:</p>
<pre><code>35 cozy comforter
35 warm blanket
67 pillow
</code></pre>
<p>and <strong>need a search that would find misspelled, mixed names like "warm cmfrter"</strong>.</p>
<p>We have code using edit-distance (difflib), but it probably won't scale to the... | 6 | 2009-05-07T13:11:30Z | 8,161,560 | <p>sqlite3 supports python callback functions. Matthew Barnett's regex (http://code.google.com/p/mrab-regex-hg/) now supports approximate matching.</p>
<p>So, like this:</p>
<pre><code>try:
import regex
except ImportError:
sys.stderr.write("Can't import mrab-regex; see http://pypi.python.org/pypi/regex\n")
... | 1 | 2011-11-17T02:58:38Z | [
"python",
"database",
"full-text-search",
"fuzzy-search"
] |
Mapping a database table to an attribute of an object | 834,722 | <p>I've come across a place in my current project where I have created several classes for storing a complicated data structure in memory and a completed SQL schema for storing the same data in a database. I've decided to use SQLAlchemy as an ORM layer as it seems the most flexible solution that I can tailor to my need... | 0 | 2009-05-07T13:43:41Z | 835,231 | <p>It seems you want something like</p>
<pre><code>work_instance.variants = [<some iterable of variants>]
</code></pre>
<p>If not please clarify in your question.</p>
<p>Ideally you should have 2 mappings to these 2 tables. It doesn't matter if you won't access the second mapping anywhere else. <code>work</cod... | 1 | 2009-05-07T15:07:41Z | [
"python",
"database",
"orm",
"sqlalchemy"
] |
Python's FTPLib too slow? | 834,840 | <p>I have been playing around with Python's FTP library and am starting to think that it is too slow as compared to using a script file in DOS? I run sessions where I download thousands of data files (I think I have over 8 million right now). My observation is that the download process seems to take five to ten time... | 1 | 2009-05-07T14:05:11Z | 834,923 | <p>FTPlib may not be the cleanest Python API, I don't think it so bad that it run ten times slower than a DOS shell script.</p>
<p>Unless you do not provide any code to compare, e.g you shell and you python snippet to batch dl 5000 files, I can't see how we can help you.</p>
| 2 | 2009-05-07T14:20:38Z | [
"python",
"ftp",
"performance",
"dos"
] |
Python's FTPLib too slow? | 834,840 | <p>I have been playing around with Python's FTP library and am starting to think that it is too slow as compared to using a script file in DOS? I run sessions where I download thousands of data files (I think I have over 8 million right now). My observation is that the download process seems to take five to ten time... | 1 | 2009-05-07T14:05:11Z | 835,026 | <p>FTPLib is implemented in Python whereas your "DOS Script" is actually a script which calls a compiled command. Executing this command is probably faster than interpreting Python code. If it is too slow for you, I suggest to call the DOS command from Python using the <a href="http://docs.python.org/library/subprocess... | 2 | 2009-05-07T14:35:34Z | [
"python",
"ftp",
"performance",
"dos"
] |
Python's FTPLib too slow? | 834,840 | <p>I have been playing around with Python's FTP library and am starting to think that it is too slow as compared to using a script file in DOS? I run sessions where I download thousands of data files (I think I have over 8 million right now). My observation is that the download process seems to take five to ten time... | 1 | 2009-05-07T14:05:11Z | 835,474 | <p>The speed problem is probably in your code. FTPlib is not 10 times slower.</p>
| 2 | 2009-05-07T15:51:09Z | [
"python",
"ftp",
"performance",
"dos"
] |
Python's FTPLib too slow? | 834,840 | <p>I have been playing around with Python's FTP library and am starting to think that it is too slow as compared to using a script file in DOS? I run sessions where I download thousands of data files (I think I have over 8 million right now). My observation is that the download process seems to take five to ten time... | 1 | 2009-05-07T14:05:11Z | 4,941,599 | <pre><code>import ftplib
import time
ftp = ftplib.FTP("localhost", "mph")
t0 = time.time()
with open('big.gz.sav', 'wb') as f:
ftp.retrbinary('RETR ' + '/Temp/big.gz', f.write)
t1 = time.time()
ftp.close()
ftp = ftplib.FTP("localhost", "mph")
t2 = time.time()
ftp.retrbinary('RETR ' + '/Temp/big.gz', lambda x: x)
t3... | 1 | 2011-02-09T05:22:27Z | [
"python",
"ftp",
"performance",
"dos"
] |
Python's FTPLib too slow? | 834,840 | <p>I have been playing around with Python's FTP library and am starting to think that it is too slow as compared to using a script file in DOS? I run sessions where I download thousands of data files (I think I have over 8 million right now). My observation is that the download process seems to take five to ten time... | 1 | 2009-05-07T14:05:11Z | 23,777,541 | <p>disable ftplib and execute ftp via Msdos</p>
<pre><code>os.system('FTP -v -i -s:C:\\ndfd\\wgrib2\\ftpscript.txt')
</code></pre>
<p>inside ftpscript.txt</p>
<pre><code>open example.com
username
password
!:--- FTP commands below here ---
lcd c:\MyLocalDirectory
cd public_html/MyRemoteDirectory
binary
mput "*.*"
di... | 1 | 2014-05-21T08:09:38Z | [
"python",
"ftp",
"performance",
"dos"
] |
Python's FTPLib too slow? | 834,840 | <p>I have been playing around with Python's FTP library and am starting to think that it is too slow as compared to using a script file in DOS? I run sessions where I download thousands of data files (I think I have over 8 million right now). My observation is that the download process seems to take five to ten time... | 1 | 2009-05-07T14:05:11Z | 26,314,086 | <p>define blocksize along with storbinary of ftp connection,so you will get 1.5-3.0x more faster connection than FTP Filezilla :)</p>
<pre><code>from ftplib import FTP
USER = "Your_user_id"
PASS = "Your_password"
PORT = 21
SERVER = 'ftp.billionuploads.com' #use FTP server name here
ftp = FTP()
ftp.connect(SERVER, PO... | 1 | 2014-10-11T11:23:22Z | [
"python",
"ftp",
"performance",
"dos"
] |
Python's FTPLib too slow? | 834,840 | <p>I have been playing around with Python's FTP library and am starting to think that it is too slow as compared to using a script file in DOS? I run sessions where I download thousands of data files (I think I have over 8 million right now). My observation is that the download process seems to take five to ten time... | 1 | 2009-05-07T14:05:11Z | 33,668,081 | <p>Bigger blocksize is not always the optimum.
For example uploading the same 167 MB file through wired network to same FTP server I got following times in seconds for various blocksizes:</p>
<pre><code>Blocksize Time
102400 40
51200 30
25600 28
32768 30
24576 31
19200 34
163... | 0 | 2015-11-12T09:25:07Z | [
"python",
"ftp",
"performance",
"dos"
] |
authentication method | 834,932 | <p>I am writing a server-client application to receive user message and publish it.</p>
<p>Thinking about authentication method.</p>
<ol>
<li>Asymmetric encryption, probably RSA.</li>
<li>Hash (salt+password+'msg'+'userid'), SHA256</li>
<li>HMAC, SHA256. seems to be more secured than the method 2. Also involve hashi... | 0 | 2009-05-07T14:22:25Z | 835,136 | <p>OK, firstly, an option to consider is just going down the "enterprise solution" route and buying into the standard PKI market: buy yourself a certificate from Veri$ign etc and use boring old HTTPS (or at least TLS, the underlying protocol). Then sending the data from the client is (more or less) a doddle, and there'... | 1 | 2009-05-07T14:53:48Z | [
"java",
"python",
"authentication",
"encryption",
"hash"
] |
authentication method | 834,932 | <p>I am writing a server-client application to receive user message and publish it.</p>
<p>Thinking about authentication method.</p>
<ol>
<li>Asymmetric encryption, probably RSA.</li>
<li>Hash (salt+password+'msg'+'userid'), SHA256</li>
<li>HMAC, SHA256. seems to be more secured than the method 2. Also involve hashi... | 0 | 2009-05-07T14:22:25Z | 836,074 | <p>Can't you just use standard SSL sockets to secure the connection, validate the user with a password, and then send the message to be published? If there won't be many clients, you can even use a self-signed certificate and put it in a KeyStore in the client app, that way you won't need to buy a certificate from Veri... | 2 | 2009-05-07T17:44:14Z | [
"java",
"python",
"authentication",
"encryption",
"hash"
] |
authentication method | 834,932 | <p>I am writing a server-client application to receive user message and publish it.</p>
<p>Thinking about authentication method.</p>
<ol>
<li>Asymmetric encryption, probably RSA.</li>
<li>Hash (salt+password+'msg'+'userid'), SHA256</li>
<li>HMAC, SHA256. seems to be more secured than the method 2. Also involve hashi... | 0 | 2009-05-07T14:22:25Z | 837,532 | <p>RSA protocol is generally used to setup a key exchange for a faster encryption means. That's how SSL works. </p>
<p>If the security requirements for your applications are so sensitive that you require PKI, then it should be said (without any intent to be harsh) that if you need to ask about it on SO, then its pro... | 0 | 2009-05-07T23:20:15Z | [
"java",
"python",
"authentication",
"encryption",
"hash"
] |
authentication method | 834,932 | <p>I am writing a server-client application to receive user message and publish it.</p>
<p>Thinking about authentication method.</p>
<ol>
<li>Asymmetric encryption, probably RSA.</li>
<li>Hash (salt+password+'msg'+'userid'), SHA256</li>
<li>HMAC, SHA256. seems to be more secured than the method 2. Also involve hashi... | 0 | 2009-05-07T14:22:25Z | 840,803 | <p>Let me just add a few random thoughts/comments to your proposals.</p>
<ol>
<li>RSA: Since you are mainly interested in authentication, I assume you'd want to use RSA signatures. This would imply that each user needs his own privat key. To me that sounds a little bit like overkill, especially when user and server al... | 1 | 2009-05-08T16:52:37Z | [
"java",
"python",
"authentication",
"encryption",
"hash"
] |
Python dictionary: are keys() and values() always the same order? | 835,092 | <p>It looks like the lists returned by <code>keys()</code> and <code>values()</code> methods of a dictionary are always a 1-to-1 mapping (assuming the dictionary is not altered between calling the 2 methods).</p>
<p>For example:</p>
<pre><code>>>> d = {'one':1, 'two': 2, 'three': 3}
>>> k, v = d.key... | 132 | 2009-05-07T14:46:13Z | 835,111 | <p>Yes, what you observed is indeed a guaranteed property -- keys(), values() and items() return lists in congruent order if the dict is not altered. iterkeys() &c also iterate in the same order as the corresponding lists.</p>
| 59 | 2009-05-07T14:49:34Z | [
"python"
] |
Python dictionary: are keys() and values() always the same order? | 835,092 | <p>It looks like the lists returned by <code>keys()</code> and <code>values()</code> methods of a dictionary are always a 1-to-1 mapping (assuming the dictionary is not altered between calling the 2 methods).</p>
<p>For example:</p>
<pre><code>>>> d = {'one':1, 'two': 2, 'three': 3}
>>> k, v = d.key... | 132 | 2009-05-07T14:46:13Z | 835,255 | <p>According to <a href="http://docs.python.org/dev/py3k/library/stdtypes.html#dictionary-view-objects">http://docs.python.org/dev/py3k/library/stdtypes.html#dictionary-view-objects</a> , the keys(), values() and items() methods of a dict will return corresponding iterators whose orders correspond. However, I am unable... | 5 | 2009-05-07T15:10:48Z | [
"python"
] |
Python dictionary: are keys() and values() always the same order? | 835,092 | <p>It looks like the lists returned by <code>keys()</code> and <code>values()</code> methods of a dictionary are always a 1-to-1 mapping (assuming the dictionary is not altered between calling the 2 methods).</p>
<p>For example:</p>
<pre><code>>>> d = {'one':1, 'two': 2, 'three': 3}
>>> k, v = d.key... | 132 | 2009-05-07T14:46:13Z | 835,295 | <p>Yes it is <a href="https://docs.python.org/2/library/stdtypes.html#dictionary-view-objects">guaranteed in python 2.x</a>:</p>
<blockquote>
<p>If keys, values and items views are iterated over with no intervening
modifications to the dictionary, the order of items will directly
correspond.</p>
</blockquote>
| 35 | 2009-05-07T15:20:08Z | [
"python"
] |
Python dictionary: are keys() and values() always the same order? | 835,092 | <p>It looks like the lists returned by <code>keys()</code> and <code>values()</code> methods of a dictionary are always a 1-to-1 mapping (assuming the dictionary is not altered between calling the 2 methods).</p>
<p>For example:</p>
<pre><code>>>> d = {'one':1, 'two': 2, 'three': 3}
>>> k, v = d.key... | 132 | 2009-05-07T14:46:13Z | 835,298 | <p>For what it's worth, some heavy used production code I have written is based on this assumption and I never had a problem with it. I know that doesn't make it true though :-)</p>
<p>If you don't want to take the risk I would use iteritems() if you can.</p>
<pre><code>for key, value in myDictionary.iteritems():
... | 3 | 2009-05-07T15:21:05Z | [
"python"
] |
Python dictionary: are keys() and values() always the same order? | 835,092 | <p>It looks like the lists returned by <code>keys()</code> and <code>values()</code> methods of a dictionary are always a 1-to-1 mapping (assuming the dictionary is not altered between calling the 2 methods).</p>
<p>For example:</p>
<pre><code>>>> d = {'one':1, 'two': 2, 'three': 3}
>>> k, v = d.key... | 132 | 2009-05-07T14:46:13Z | 835,430 | <p>Found this:</p>
<blockquote>
<p>If <code>items()</code>, <code>keys()</code>, <code>values()</code>,
<code>iteritems()</code>, <code>iterkeys()</code>, and
<code>itervalues()</code> are called with no
intervening modifications to the
dictionary, the lists will directly
correspond.</p>
</blockquote>
<p>... | 143 | 2009-05-07T15:45:47Z | [
"python"
] |
Python dictionary: are keys() and values() always the same order? | 835,092 | <p>It looks like the lists returned by <code>keys()</code> and <code>values()</code> methods of a dictionary are always a 1-to-1 mapping (assuming the dictionary is not altered between calling the 2 methods).</p>
<p>For example:</p>
<pre><code>>>> d = {'one':1, 'two': 2, 'three': 3}
>>> k, v = d.key... | 132 | 2009-05-07T14:46:13Z | 33,065,618 | <p>As already pointed out yes, many practical uses would be zipping both of them.</p>
<pre><code>zip(d.keys(), d.values())
</code></pre>
<p>Since the order of access remain the same though not predictable the above would always return same (key,value) tuple.</p>
| -2 | 2015-10-11T13:36:57Z | [
"python"
] |
Extending Python's builtin Str | 835,469 | <p>I'm trying to subclass <code>str</code>, but having some difficulties due to its immutability.</p>
<pre><code>class DerivedClass(str):
def __new__(cls, string):
ob = super(DerivedClass, cls).__new__(cls, string)
return ob
def upper(self):
#overridden, new functionality. Return ob o... | 14 | 2009-05-07T15:50:29Z | 835,523 | <p>You might be able to do this by overriding <code>__getattribute__</code>.</p>
<pre><code>def __getattribute__(self, name):
# Simple hardcoded check for upper.
# I'm sure there are better ways to get the list of defined methods in
# your class and see if name is contained in it.
if name == 'upper':
... | -2 | 2009-05-07T15:58:08Z | [
"python",
"oop",
"inheritance",
"override",
"immutability"
] |
Extending Python's builtin Str | 835,469 | <p>I'm trying to subclass <code>str</code>, but having some difficulties due to its immutability.</p>
<pre><code>class DerivedClass(str):
def __new__(cls, string):
ob = super(DerivedClass, cls).__new__(cls, string)
return ob
def upper(self):
#overridden, new functionality. Return ob o... | 14 | 2009-05-07T15:50:29Z | 835,859 | <p>You can do this by overriding <code>__getattribute__</code> as Zr40 suggests, but you will need to have getattribute return a callable function. The sample below should give you what you want; it uses the <code>functools.partial</code> wrapper to make life easier, though you could implement it without partial if you... | 5 | 2009-05-07T16:56:42Z | [
"python",
"oop",
"inheritance",
"override",
"immutability"
] |
Extending Python's builtin Str | 835,469 | <p>I'm trying to subclass <code>str</code>, but having some difficulties due to its immutability.</p>
<pre><code>class DerivedClass(str):
def __new__(cls, string):
ob = super(DerivedClass, cls).__new__(cls, string)
return ob
def upper(self):
#overridden, new functionality. Return ob o... | 14 | 2009-05-07T15:50:29Z | 835,913 | <p>You're both close, but checking for each doesn't extend well to overriding many methods.</p>
<pre><code>from functools import partial
class DerivedClass(str):
def __new__(cls, string):
ob = super(DerivedClass, cls).__new__(cls, string)
return ob
def upper(self):
caps = super(Derive... | 5 | 2009-05-07T17:10:53Z | [
"python",
"oop",
"inheritance",
"override",
"immutability"
] |
Extending Python's builtin Str | 835,469 | <p>I'm trying to subclass <code>str</code>, but having some difficulties due to its immutability.</p>
<pre><code>class DerivedClass(str):
def __new__(cls, string):
ob = super(DerivedClass, cls).__new__(cls, string)
return ob
def upper(self):
#overridden, new functionality. Return ob o... | 14 | 2009-05-07T15:50:29Z | 836,963 | <p>Good use for a class decorator -- roughly (untested code):</p>
<pre><code>@do_overrides
class Myst(str):
def upper(self):
...&c...
</code></pre>
<p>and</p>
<pre><code>def do_overrides(cls):
done = set(dir(cls))
base = cls.__bases__[0]
def wrap(f):
def wrapper(*a, **k):
r = f(*a, **k)
... | 7 | 2009-05-07T20:51:12Z | [
"python",
"oop",
"inheritance",
"override",
"immutability"
] |
Can I use a List Comprehension to get Line Indexes from a file? | 835,572 | <p>I need to identify some locations in a file where certain markers might be. I started off thinking that I would use list.index but I soon discovered that returns the first (and only the first) item. so I decided to implement my own solution which was</p>
<pre><code>count=0
docIndex=[]
for line in open('myfile.txt... | 0 | 2009-05-07T16:04:39Z | 835,586 | <p>What about this?</p>
<pre><code>[index for index,line in enumerate(open('myfile.txt')) if 'mystring' in line]
</code></pre>
| 8 | 2009-05-07T16:07:15Z | [
"python",
"list-comprehension"
] |
Elixir (SqlAlchemy): relations between 3 tables with composite primary keys | 835,834 | <p>I've 3 tables:</p>
<ul>
<li>A Company table with <code>(company_id)</code> primary key</li>
<li>A Page table with <code>(company_id, url)</code> primary key & a foreign key back to Company</li>
<li>An Attr table with <code>(company_id, attr_key)</code> primary key & a foreign key back to Company.</li>
</ul>... | 1 | 2009-05-07T16:50:58Z | 866,393 | <p>Yes you can do this. Elixir doesn't have a built in way to do this, but because it's a thin wrapper on SQLAlchemy you can convince it to do this. Because Elixir doesn't have a concept of a many-to-one relation that reuses existing columns you need to use the GenericProperty with the SQLAlchemy relation property and ... | 2 | 2009-05-14T23:34:12Z | [
"python",
"sqlalchemy",
"python-elixir"
] |
How can I set a custom response header for pylons static (public) files? | 836,191 | <p>How do I add a custom header to files pylons is serving from public?</p>
| 2 | 2009-05-07T18:13:41Z | 837,561 | <p>a) Let your webserver serve files from /public instead of paster and configure it to pass some special headers.</p>
<p>b) Add a special route and <a href="http://pythonpaste.org/modules/fileapp.html" rel="nofollow">serve the files yourself ala</a></p>
<pre><code>class FilesController(BaseController):
def downl... | 2 | 2009-05-07T23:29:20Z | [
"python",
"http-headers",
"pylons"
] |
How can I set a custom response header for pylons static (public) files? | 836,191 | <p>How do I add a custom header to files pylons is serving from public?</p>
| 2 | 2009-05-07T18:13:41Z | 1,627,475 | <p>With a recent version of route, you can use the '<a href="http://routes.groovie.org/manual.html#magic-path-info" rel="nofollow">Magic path_info</a>' feature, and follow the documentation from here to write your controller so it calls paster.DirectoryApp.</p>
<p>In my project, I wanted to serve any file in the publi... | 0 | 2009-10-26T21:38:20Z | [
"python",
"http-headers",
"pylons"
] |
How can I set a custom response header for pylons static (public) files? | 836,191 | <p>How do I add a custom header to files pylons is serving from public?</p>
| 2 | 2009-05-07T18:13:41Z | 2,656,741 | <p>In a standard Pylons setup, the public files are served from a StaticUrlParser. This is typically setup in your config/middleware.py:make_app() function</p>
<p>You need to subclass the StaticUrlParser like Antonin ENFRUN describes, though calling it a Controller is confusing because it's doing a different purpose. ... | 0 | 2010-04-17T00:26:30Z | [
"python",
"http-headers",
"pylons"
] |
How can I set a custom response header for pylons static (public) files? | 836,191 | <p>How do I add a custom header to files pylons is serving from public?</p>
| 2 | 2009-05-07T18:13:41Z | 13,825,248 | <p>A simpler way to use FileApp for streaming, based on the <a href="http://pylonsbook.com/en/1.1/the-web-server-gateway-interface-wsgi.html" rel="nofollow">pylons book</a>. The code below assumes your route provides <code>some_file_identifier</code>, but the other two variables are "magic" (see explanation after code)... | 0 | 2012-12-11T17:20:35Z | [
"python",
"http-headers",
"pylons"
] |
How can I tell if a python variable is a string or a list? | 836,387 | <p>I have a routine that takes a list of strings as a parameter, but I'd like to support passing in a single string and converting it to a list of one string. For example:</p>
<pre><code>def func( files ):
for f in files:
doSomethingWithFile( f )
func( ['file1','file2','file3'] )
func( 'file1' ) # should... | 51 | 2009-05-07T18:53:26Z | 836,402 | <pre><code>isinstance(your_var, basestring)
</code></pre>
| 31 | 2009-05-07T18:57:40Z | [
"python",
"list",
"duck-typing"
] |
How can I tell if a python variable is a string or a list? | 836,387 | <p>I have a routine that takes a list of strings as a parameter, but I'd like to support passing in a single string and converting it to a list of one string. For example:</p>
<pre><code>def func( files ):
for f in files:
doSomethingWithFile( f )
func( ['file1','file2','file3'] )
func( 'file1' ) # should... | 51 | 2009-05-07T18:53:26Z | 836,406 | <p>Well, there's nothing unpythonic about checking type. Having said that, if you're willing to put a small burden on the caller:</p>
<pre><code>def func( *files ):
for f in files:
doSomethingWithFile( f )
func( *['file1','file2','file3'] ) #Is treated like func('file1','file2','file3')
func( 'file1' )
... | 30 | 2009-05-07T18:58:29Z | [
"python",
"list",
"duck-typing"
] |
How can I tell if a python variable is a string or a list? | 836,387 | <p>I have a routine that takes a list of strings as a parameter, but I'd like to support passing in a single string and converting it to a list of one string. For example:</p>
<pre><code>def func( files ):
for f in files:
doSomethingWithFile( f )
func( ['file1','file2','file3'] )
func( 'file1' ) # should... | 51 | 2009-05-07T18:53:26Z | 836,407 | <p>Personally, I don't really like this sort of behavior -- it interferes with duck typing. One could argue that it doesn't obey the "Explicit is better than implicit" mantra. Why not use the varargs syntax:</p>
<pre><code>def func( *files ):
for f in files:
doSomethingWithFile( f )
func( 'file1', 'file2'... | 30 | 2009-05-07T18:58:58Z | [
"python",
"list",
"duck-typing"
] |
How can I tell if a python variable is a string or a list? | 836,387 | <p>I have a routine that takes a list of strings as a parameter, but I'd like to support passing in a single string and converting it to a list of one string. For example:</p>
<pre><code>def func( files ):
for f in files:
doSomethingWithFile( f )
func( ['file1','file2','file3'] )
func( 'file1' ) # should... | 51 | 2009-05-07T18:53:26Z | 836,535 | <p>I would say the most Python'y way is to make the user always pass a list, even if there is only one item in it. It makes it really obvious <code>func()</code> can take a list of files</p>
<pre><code>def func(files):
for cur_file in files:
blah(cur_file)
func(['file1'])
</code></pre>
<p>As Dave suggest... | 14 | 2009-05-07T19:24:29Z | [
"python",
"list",
"duck-typing"
] |
How can I tell if a python variable is a string or a list? | 836,387 | <p>I have a routine that takes a list of strings as a parameter, but I'd like to support passing in a single string and converting it to a list of one string. For example:</p>
<pre><code>def func( files ):
for f in files:
doSomethingWithFile( f )
func( ['file1','file2','file3'] )
func( 'file1' ) # should... | 51 | 2009-05-07T18:53:26Z | 837,588 | <pre><code>if hasattr(f, 'lower'): print "I'm string like"
</code></pre>
| 10 | 2009-05-07T23:42:28Z | [
"python",
"list",
"duck-typing"
] |
How can I tell if a python variable is a string or a list? | 836,387 | <p>I have a routine that takes a list of strings as a parameter, but I'd like to support passing in a single string and converting it to a list of one string. For example:</p>
<pre><code>def func( files ):
for f in files:
doSomethingWithFile( f )
func( ['file1','file2','file3'] )
func( 'file1' ) # should... | 51 | 2009-05-07T18:53:26Z | 837,837 | <p>Varargs was confusing for me, so I tested it out in Python to clear it up for myself.</p>
<p>First of all the PEP for varargs is <a href="http://www.python.org/dev/peps/pep-3102/" rel="nofollow">here</a>.</p>
<p>Here is sample program, based on the two answers from Dave and David Berger, followed by the output, ju... | 3 | 2009-05-08T01:24:14Z | [
"python",
"list",
"duck-typing"
] |
How can I tell if a python variable is a string or a list? | 836,387 | <p>I have a routine that takes a list of strings as a parameter, but I'd like to support passing in a single string and converting it to a list of one string. For example:</p>
<pre><code>def func( files ):
for f in files:
doSomethingWithFile( f )
func( ['file1','file2','file3'] )
func( 'file1' ) # should... | 51 | 2009-05-07T18:53:26Z | 837,986 | <pre><code>def func(files):
for f in files if not isinstance(files, basestring) else [files]:
doSomethingWithFile(f)
func(['file1', 'file2', 'file3'])
func('file1')
</code></pre>
| 9 | 2009-05-08T02:25:58Z | [
"python",
"list",
"duck-typing"
] |
How can I tell if a python variable is a string or a list? | 836,387 | <p>I have a routine that takes a list of strings as a parameter, but I'd like to support passing in a single string and converting it to a list of one string. For example:</p>
<pre><code>def func( files ):
for f in files:
doSomethingWithFile( f )
func( ['file1','file2','file3'] )
func( 'file1' ) # should... | 51 | 2009-05-07T18:53:26Z | 11,106,461 | <p>If you have more control over the caller, then one of the other answers is better. I don't have that luxury in my case so I settled on the following solution (with caveats):</p>
<pre><code>def listLike(v):
"""Return True if v is a non-string sequence and is iterable. Note that
not all objects with getitem() h... | 4 | 2012-06-19T17:46:39Z | [
"python",
"list",
"duck-typing"
] |
How to programatically combine two aac files into one? | 836,842 | <p>I'm looking for a <code>cat</code> for aac music files (the stuff iTunes uses).</p>
<p>Use Case: My father in law will not touch computers except for audiobooks he downloads to his iPod. I have taught him some iTunes (Windows) basics, but his library is a mess. It turns out, that iTunes is optimized for listening t... | 3 | 2009-05-07T20:24:36Z | 837,034 | <p>I haven't seen an aac codec library for python, but you could use wav files as an intermediary format.</p>
<p>You can pull the tracks off the cd as wav files, and then use the <a href="http://docs.python.org/library/wave.html" rel="nofollow">wave module</a> to concatenate them into one large file, which could then ... | 0 | 2009-05-07T21:02:27Z | [
"python",
"windows",
"scripting",
"itunes",
"aac"
] |
How to programatically combine two aac files into one? | 836,842 | <p>I'm looking for a <code>cat</code> for aac music files (the stuff iTunes uses).</p>
<p>Use Case: My father in law will not touch computers except for audiobooks he downloads to his iPod. I have taught him some iTunes (Windows) basics, but his library is a mess. It turns out, that iTunes is optimized for listening t... | 3 | 2009-05-07T20:24:36Z | 837,156 | <p>The most powerful Python audio manipulation module out there seems to be <a href="http://audiotools.sourceforge.net/index.html" rel="nofollow">Python Audio Tools</a>. The download comes with CLI tools that would probably do everything you'd want to do, even ripping, so you can even get by with shell scripting the wh... | 1 | 2009-05-07T21:35:23Z | [
"python",
"windows",
"scripting",
"itunes",
"aac"
] |
How to programatically combine two aac files into one? | 836,842 | <p>I'm looking for a <code>cat</code> for aac music files (the stuff iTunes uses).</p>
<p>Use Case: My father in law will not touch computers except for audiobooks he downloads to his iPod. I have taught him some iTunes (Windows) basics, but his library is a mess. It turns out, that iTunes is optimized for listening t... | 3 | 2009-05-07T20:24:36Z | 837,172 | <p>Not programming related (well, kinda.)</p>
<p>iTunes already has functionality to rip as a single track (e.g. an audiobook.) Check this out: <a href="http://www.ehow.com/how_2108906_merge-cd-single-track-itunes.html" rel="nofollow">http://www.ehow.com/how_2108906_merge-cd-single-track-itunes.html</a></p>
<p>That f... | 2 | 2009-05-07T21:40:24Z | [
"python",
"windows",
"scripting",
"itunes",
"aac"
] |
How to programatically combine two aac files into one? | 836,842 | <p>I'm looking for a <code>cat</code> for aac music files (the stuff iTunes uses).</p>
<p>Use Case: My father in law will not touch computers except for audiobooks he downloads to his iPod. I have taught him some iTunes (Windows) basics, but his library is a mess. It turns out, that iTunes is optimized for listening t... | 3 | 2009-05-07T20:24:36Z | 991,742 | <p>I created a freeware program called "Chapter and Verse" to concatenate m4a (AAC) files into a single m4b audiobook file with chapter marks and metadata.</p>
<p>If you have already ripped the CD's to AAC using itunes (which you say you have) then the rest is easy with my software. I wrote it for this exact reason a... | 4 | 2009-06-13T23:14:02Z | [
"python",
"windows",
"scripting",
"itunes",
"aac"
] |
datastore transaction restrictions | 836,992 | <p>in my google app application, whenever a user purchases a number of contracts, these events are executed (simplified for clarity):</p>
<ul>
<li>user.cash is decreased</li>
<li>user.contracts is increased by the number</li>
<li>contracts.current_price is updated.</li>
<li>market.no_of_transactions is increased by 1.... | 3 | 2009-05-07T20:55:48Z | 838,960 | <p>After a through research, I have found that a distributed transaction layer that provides a solution to the single entity group restriction has been developed in userland with the help of some google people. But so far, it is not released and is only available in java.</p>
| 0 | 2009-05-08T09:15:20Z | [
"python",
"google-app-engine",
"transactions",
"gae-datastore",
"gae-ds-transactions"
] |
datastore transaction restrictions | 836,992 | <p>in my google app application, whenever a user purchases a number of contracts, these events are executed (simplified for clarity):</p>
<ul>
<li>user.cash is decreased</li>
<li>user.contracts is increased by the number</li>
<li>contracts.current_price is updated.</li>
<li>market.no_of_transactions is increased by 1.... | 3 | 2009-05-07T20:55:48Z | 2,127,490 | <p>Let me add a quote from the <a href="http://code.google.com/intl/de/appengine/docs/python/datastore/keysandentitygroups.html" rel="nofollow">Datastore documentation</a>:</p>
<blockquote>
<p>A good rule of thumb for entity groups is that they should be about
the size of a single user's worth of
data or smaller... | 0 | 2010-01-24T15:15:31Z | [
"python",
"google-app-engine",
"transactions",
"gae-datastore",
"gae-ds-transactions"
] |
datastore transaction restrictions | 836,992 | <p>in my google app application, whenever a user purchases a number of contracts, these events are executed (simplified for clarity):</p>
<ul>
<li>user.cash is decreased</li>
<li>user.contracts is increased by the number</li>
<li>contracts.current_price is updated.</li>
<li>market.no_of_transactions is increased by 1.... | 3 | 2009-05-07T20:55:48Z | 4,798,839 | <p>shanyu, you mentioned the distributed transaction layer that lets you operate across arbitrarily many entity groups in a single transaction. it actually
<a href="http://code.google.com/p/tapioca-orm/" rel="nofollow">has been released</a>, it just hasn't been advertised very loudly. it was designed and written by dan... | 0 | 2011-01-25T21:08:12Z | [
"python",
"google-app-engine",
"transactions",
"gae-datastore",
"gae-ds-transactions"
] |
Form Submission in Python Without Name Attribute | 837,195 | <p>Background:</p>
<p>Using urllib and urllib2 in Python, you can do a form submission. </p>
<p>You first create a dictionary.</p>
<pre><code>formdictionary = { 'search' : 'stackoverflow' }
</code></pre>
<p>Then you use urlencode method of urllib to transform this dictionary.</p>
<pre><code>params = urllib.urlenc... | 2 | 2009-05-07T21:44:49Z | 837,283 | <p>According to <a href="http://www.w3.org/TR/html401/interact/forms.html#successful-controls" rel="nofollow">the W3 standard</a>, for an input field to be submitted, it must have a name attribute. A quick test on Firefox 3 and Safari 3.2 shows that an input field that is missing the name attribute but has an id attrib... | 2 | 2009-05-07T22:05:09Z | [
"python",
"forms",
"urllib2",
"urllib"
] |
Form Submission in Python Without Name Attribute | 837,195 | <p>Background:</p>
<p>Using urllib and urllib2 in Python, you can do a form submission. </p>
<p>You first create a dictionary.</p>
<pre><code>formdictionary = { 'search' : 'stackoverflow' }
</code></pre>
<p>Then you use urlencode method of urllib to transform this dictionary.</p>
<pre><code>params = urllib.urlenc... | 2 | 2009-05-07T21:44:49Z | 837,322 | <p>An input tag without a name won't be submitted as a form parameter.</p>
<p>For example, create an HTML page containing just this:</p>
<pre><code><form>
<input type="text" name="one" value="foo"/>
<input type="text" value="bar"/>
<input type="submit"/>
</form>
</code></pre>... | 0 | 2009-05-07T22:11:59Z | [
"python",
"forms",
"urllib2",
"urllib"
] |
How do I invoke Python code from Ruby? | 837,256 | <p>Does a easy to use Ruby to Python bridge exist? Or am I better off using system()? </p>
| 5 | 2009-05-07T21:59:01Z | 837,296 | <p>I don't think there's any way to invoke Python from Ruby without forking a process, via system() or something. The language run times are utterly diferent, they'd need to be in separate processes anyway.</p>
| 2 | 2009-05-07T22:08:15Z | [
"python",
"ruby"
] |
How do I invoke Python code from Ruby? | 837,256 | <p>Does a easy to use Ruby to Python bridge exist? Or am I better off using system()? </p>
| 5 | 2009-05-07T21:59:01Z | 837,325 | <p>You could try <a href="http://www.goto.info.waseda.ac.jp/~fukusima/ruby/python-e.html">Masaki Fukushima's library</a> for embedding python in ruby, although it doesn't appear to be maintained. YMMV</p>
<blockquote>
<p>With this library, Ruby scripts can directly call arbitrary Python modules. Both extension modul... | 6 | 2009-05-07T22:12:39Z | [
"python",
"ruby"
] |
How do I invoke Python code from Ruby? | 837,256 | <p>Does a easy to use Ruby to Python bridge exist? Or am I better off using system()? </p>
| 5 | 2009-05-07T21:59:01Z | 837,862 | <p>For python code to run the interpreter needs to be launched as a process. So system() is your best option.</p>
<p>For calling the python code you could use RPC or network sockets, got for the simplest thing which could possibly work.</p>
| -1 | 2009-05-08T01:35:03Z | [
"python",
"ruby"
] |
How do I invoke Python code from Ruby? | 837,256 | <p>Does a easy to use Ruby to Python bridge exist? Or am I better off using system()? </p>
| 5 | 2009-05-07T21:59:01Z | 5,331,067 | <p>gem install rubypython</p>
<p><a href="http://rubypython.rubyforge.org/">rubypython home page</a></p>
| 5 | 2011-03-16T20:00:02Z | [
"python",
"ruby"
] |
How do I invoke Python code from Ruby? | 837,256 | <p>Does a easy to use Ruby to Python bridge exist? Or am I better off using system()? </p>
| 5 | 2009-05-07T21:59:01Z | 14,096,628 | <p>If you want to use Python code like your Python script is a function, try IO.popen .</p>
<p>If you wanted to reverse each string in an array using the python script "reverse.py", your ruby code would be as follows.</p>
<pre><code>strings = ["hello", "my", "name", "is", "jimmy"]
#IO.popen: 1st arg is exactly what y... | 1 | 2012-12-31T01:52:50Z | [
"python",
"ruby"
] |
Find the oldest file (recursively) in a directory | 837,606 | <p>I'm writing a Python backup script and I need to find the oldest file in a directory (and its sub-directories). I also need to filter it down to *.avi files only.</p>
<p>The script will always be running on a Linux machine. Is there some way to do it in Python or would running some shell commands be better?</p>
<p... | 8 | 2009-05-07T23:50:50Z | 837,609 | <p>Check out the linux command <a href="http://content.hccfl.edu/pollock/Unix/FindCmd.htm" rel="nofollow"><code>find</code></a>.</p>
<p>Alternatively, <a href="http://www.linuxforums.org/forum/debian-linux-help/70289-remove-oldest-file-directory.html" rel="nofollow">this post</a> pipes together ls and tail to delete t... | 2 | 2009-05-07T23:53:02Z | [
"python",
"linux",
"file-io"
] |
Find the oldest file (recursively) in a directory | 837,606 | <p>I'm writing a Python backup script and I need to find the oldest file in a directory (and its sub-directories). I also need to filter it down to *.avi files only.</p>
<p>The script will always be running on a Linux machine. Is there some way to do it in Python or would running some shell commands be better?</p>
<p... | 8 | 2009-05-07T23:50:50Z | 837,629 | <p>To do it in Python, you can use <a href="http://docs.python.org/library/os.html"><code>os.walk(path)</code></a> to iterate recursively over the files, and the <code>st_size</code> and <code>st_mtime</code> attributes of <a href="http://docs.python.org/library/os.html"><code>os.stat(filename)</code></a> to get the fi... | 12 | 2009-05-08T00:00:52Z | [
"python",
"linux",
"file-io"
] |
Find the oldest file (recursively) in a directory | 837,606 | <p>I'm writing a Python backup script and I need to find the oldest file in a directory (and its sub-directories). I also need to filter it down to *.avi files only.</p>
<p>The script will always be running on a Linux machine. Is there some way to do it in Python or would running some shell commands be better?</p>
<p... | 8 | 2009-05-07T23:50:50Z | 837,631 | <p>You can use <a href="http://docs.python.org/library/stat.html#module-stat">stat</a> and <a href="http://docs.python.org/library/fnmatch.html#module-fnmatch">fnmatch</a> modules together to find the files</p>
<p>ST_MTIME refere to the last modification time. You can choose another value if you want</p>
<pre><code>i... | 10 | 2009-05-08T00:01:00Z | [
"python",
"linux",
"file-io"
] |
Find the oldest file (recursively) in a directory | 837,606 | <p>I'm writing a Python backup script and I need to find the oldest file in a directory (and its sub-directories). I also need to filter it down to *.avi files only.</p>
<p>The script will always be running on a Linux machine. Is there some way to do it in Python or would running some shell commands be better?</p>
<p... | 8 | 2009-05-07T23:50:50Z | 837,637 | <p>The <a href="http://docs.python.org/library/os.html#files-and-directories" rel="nofollow">os module</a> provides the functions that you need to get directory listings and file info in Python. I've found <a href="http://docs.python.org/library/os.html?highlight=walk#os.walk" rel="nofollow">os.walk</a> to be especial... | 0 | 2009-05-08T00:02:53Z | [
"python",
"linux",
"file-io"
] |
Find the oldest file (recursively) in a directory | 837,606 | <p>I'm writing a Python backup script and I need to find the oldest file in a directory (and its sub-directories). I also need to filter it down to *.avi files only.</p>
<p>The script will always be running on a Linux machine. Is there some way to do it in Python or would running some shell commands be better?</p>
<p... | 8 | 2009-05-07T23:50:50Z | 837,641 | <p>I think the easiest way to do this would be to use find along with ls -t (sort files by time).</p>
<p>something along these lines should do the trick (deletes oldest avi file under specified directory)</p>
<pre><code>find / -name "*.avi" | xargs ls -t | tail -n 1 | xargs rm
</code></pre>
<p>step by step....</p>
... | 7 | 2009-05-08T00:04:04Z | [
"python",
"linux",
"file-io"
] |
Find the oldest file (recursively) in a directory | 837,606 | <p>I'm writing a Python backup script and I need to find the oldest file in a directory (and its sub-directories). I also need to filter it down to *.avi files only.</p>
<p>The script will always be running on a Linux machine. Is there some way to do it in Python or would running some shell commands be better?</p>
<p... | 8 | 2009-05-07T23:50:50Z | 837,840 | <p>Hm. Nadia's answer is closer to what you <em>meant</em> to ask; however, for finding the (single) oldest file in a tree, try this:</p>
<pre><code>import os
def oldest_file_in_tree(rootfolder, extension=".avi"):
return min(
(os.path.join(dirname, filename)
for dirname, dirnames, filenames in os.w... | 19 | 2009-05-08T01:24:55Z | [
"python",
"linux",
"file-io"
] |
Find the oldest file (recursively) in a directory | 837,606 | <p>I'm writing a Python backup script and I need to find the oldest file in a directory (and its sub-directories). I also need to filter it down to *.avi files only.</p>
<p>The script will always be running on a Linux machine. Is there some way to do it in Python or would running some shell commands be better?</p>
<p... | 8 | 2009-05-07T23:50:50Z | 838,037 | <p>Here's another Python formulation, which a bit old-school compared to some others, but is easy to modify, and handles the case of no matching files without raising an exception.</p>
<pre><code>import os
def find_oldest_file(dirname="..", extension=".avi"):
oldest_file, oldest_time = None, None
for dirpath,... | 2 | 2009-05-08T02:56:00Z | [
"python",
"linux",
"file-io"
] |
How do I create a slug in Django? | 837,828 | <p>I am trying to create a SlugField in Django.</p>
<p>I created this simple model:</p>
<pre><code>from django.db import models
class Test(models.Model):
q = models.CharField(max_length=30)
s = models.SlugField()
</code></pre>
<p>I then do this:</p>
<pre><code>>>> from mysite.books.models import T... | 156 | 2009-05-08T01:17:11Z | 837,835 | <p>You will need to use the slugify function. </p>
<pre><code>>>> from django.template.defaultfilters import slugify
>>> slugify("b b b b")
u'b-b-b-b'
>>>
</code></pre>
<p>You can call <code>slugify</code> automatically by overriding the <code>save</code> method:</p>
<pre><code>class test(... | 314 | 2009-05-08T01:22:34Z | [
"python",
"django",
"slug"
] |
How do I create a slug in Django? | 837,828 | <p>I am trying to create a SlugField in Django.</p>
<p>I created this simple model:</p>
<pre><code>from django.db import models
class Test(models.Model):
q = models.CharField(max_length=30)
s = models.SlugField()
</code></pre>
<p>I then do this:</p>
<pre><code>>>> from mysite.books.models import T... | 156 | 2009-05-08T01:17:11Z | 842,865 | <p>If you're using the admin interface to add new items of your model, you can set up a <code>ModelAdmin</code> in your <code>admin.py</code> and utilize <a href="https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.prepopulated_fields"><code>prepopulated_fields</code></a> to automat... | 26 | 2009-05-09T07:26:29Z | [
"python",
"django",
"slug"
] |
How do I create a slug in Django? | 837,828 | <p>I am trying to create a SlugField in Django.</p>
<p>I created this simple model:</p>
<pre><code>from django.db import models
class Test(models.Model):
q = models.CharField(max_length=30)
s = models.SlugField()
</code></pre>
<p>I then do this:</p>
<pre><code>>>> from mysite.books.models import T... | 156 | 2009-05-08T01:17:11Z | 843,067 | <p>In most cases the slug should not change, so you really only want to calculate it on first save:</p>
<pre><code>class Test(models.Model):
q = models.CharField(max_length=30)
s = models.SlugField(editable=False) # hide from admin
def save(self):
if not self.id:
self.s = slugify(self.... | 20 | 2009-05-09T10:10:12Z | [
"python",
"django",
"slug"
] |
How do I create a slug in Django? | 837,828 | <p>I am trying to create a SlugField in Django.</p>
<p>I created this simple model:</p>
<pre><code>from django.db import models
class Test(models.Model):
q = models.CharField(max_length=30)
s = models.SlugField()
</code></pre>
<p>I then do this:</p>
<pre><code>>>> from mysite.books.models import T... | 156 | 2009-05-08T01:17:11Z | 1,480,440 | <p>A small correction to Thepeer's answer: To override <code>save()</code> function in model classes, better add arguments to it:</p>
<pre><code>from django.utils.text import slugify
def save(self, *args, **kwargs):
if not self.id:
self.s = slugify(self.q)
super(test, self).save(*args, **kwargs)
</co... | 49 | 2009-09-26T04:36:35Z | [
"python",
"django",
"slug"
] |
How do I create a slug in Django? | 837,828 | <p>I am trying to create a SlugField in Django.</p>
<p>I created this simple model:</p>
<pre><code>from django.db import models
class Test(models.Model):
q = models.CharField(max_length=30)
s = models.SlugField()
</code></pre>
<p>I then do this:</p>
<pre><code>>>> from mysite.books.models import T... | 156 | 2009-05-08T01:17:11Z | 4,440,730 | <p>If you don't want to set the slugfield to Not be editable, then I believe you'll want to set the Null and Blank properties to False. Otherwise you'll get an error when trying to save in Admin.</p>
<p>So a modification to the above example would be::</p>
<pre><code>class test(models.Model):
q = models.CharFiel... | 6 | 2010-12-14T15:26:49Z | [
"python",
"django",
"slug"
] |
How do I create a slug in Django? | 837,828 | <p>I am trying to create a SlugField in Django.</p>
<p>I created this simple model:</p>
<pre><code>from django.db import models
class Test(models.Model):
q = models.CharField(max_length=30)
s = models.SlugField()
</code></pre>
<p>I then do this:</p>
<pre><code>>>> from mysite.books.models import T... | 156 | 2009-05-08T01:17:11Z | 4,895,850 | <p>Use prepopulated_fields in your admin class:</p>
<pre><code>class ArticleAdmin(admin.ModelAdmin):
prepopulated_fields = {"slug": ("title",)}
admin.site.register(Article, ArticleAdmin)
</code></pre>
<p><a href="http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.prepopulated... | 4 | 2011-02-04T08:14:47Z | [
"python",
"django",
"slug"
] |
How do I create a slug in Django? | 837,828 | <p>I am trying to create a SlugField in Django.</p>
<p>I created this simple model:</p>
<pre><code>from django.db import models
class Test(models.Model):
q = models.CharField(max_length=30)
s = models.SlugField()
</code></pre>
<p>I then do this:</p>
<pre><code>>>> from mysite.books.models import T... | 156 | 2009-05-08T01:17:11Z | 12,212,162 | <p>There is corner case with some utf-8 characters</p>
<p>Example:</p>
<pre><code>>>> from django.template.defaultfilters import slugify
>>> slugify(u"test Ä
ÄÅÄóÅÅ")
u'test-aescon' # there is no "l"
</code></pre>
<p>This can be solved with <a href="http://pypi.python.org/pypi/Unidecode/0.04.... | 87 | 2012-08-31T09:05:21Z | [
"python",
"django",
"slug"
] |
How do I create a slug in Django? | 837,828 | <p>I am trying to create a SlugField in Django.</p>
<p>I created this simple model:</p>
<pre><code>from django.db import models
class Test(models.Model):
q = models.CharField(max_length=30)
s = models.SlugField()
</code></pre>
<p>I then do this:</p>
<pre><code>>>> from mysite.books.models import T... | 156 | 2009-05-08T01:17:11Z | 28,526,821 | <p>I'm using Django 1.7</p>
<p>Create a SlugField in your model like this:</p>
<pre><code>slug = models.SlugField()
</code></pre>
<p>Then in <code>admin.py</code> define <code>prepopulated_fields</code>;</p>
<pre><code>class ArticleAdmin(admin.ModelAdmin):
prepopulated_fields = {"slug": ("title",)}
</code></pre... | 2 | 2015-02-15T13:58:37Z | [
"python",
"django",
"slug"
] |
Working with subdomain in google app engine | 838,078 | <p>How can I work with sub domain in google app engine (python).</p>
<p>I wanna get first domain part and take some action (handler).</p>
<p><b>Example:</b><br />
product.example.com -> send it to products handler<br />
user.example.com -> send it to us... | 19 | 2009-05-08T03:15:08Z | 838,726 | <p>WSGIApplication isn't capable of routing based on domain. Instead, you need to create a separate application for each subdomain, like this:</p>
<pre><code>applications = {
'product.example.com': webapp.WSGIApplication([
('/', IndexHandler),
('/(.*)', ProductHandler)]),
'user.example.com': webapp.WSGIApp... | 26 | 2009-05-08T08:05:53Z | [
"python",
"google-app-engine",
"subdomain"
] |
Working with subdomain in google app engine | 838,078 | <p>How can I work with sub domain in google app engine (python).</p>
<p>I wanna get first domain part and take some action (handler).</p>
<p><b>Example:</b><br />
product.example.com -> send it to products handler<br />
user.example.com -> send it to us... | 19 | 2009-05-08T03:15:08Z | 4,316,588 | <p>I liked the idea from Nick but I had a slightly different issue. I wanted to match one specific subdomain to handle it a bit different, but all other sub domains should be handled the same. So here is my example.</p>
<pre><code>import os
def main():
if (os.environ['HTTP_HOST'] == "sub.example.com"):
app... | 2 | 2010-11-30T17:28:58Z | [
"python",
"google-app-engine",
"subdomain"
] |
Python dictionary deepcopy | 838,642 | <p>I was wondering in how does exactly deepcopy work in the following context:</p>
<pre><code>from copy import deepcopy
def copyExample:
self.myDict = {}
firstPosition = "First"
firstPositionContent = ["first", "primero"]
secondPosition = "Second"
secondPositionContent = ["second"]
self.myDict... | 19 | 2009-05-08T07:38:49Z | 838,673 | <p>The <a href="http://docs.python.org/library/copy.html">documentation</a> makes it pretty clear that you're getting new copies, not references. Deepcopy creates deep copies for built in types, with various exceptions and that you can add custom copy operations to your user-defined objects to get deep copy support for... | 14 | 2009-05-08T07:49:17Z | [
"python",
"dictionary",
"deep-copy"
] |
Python dictionary deepcopy | 838,642 | <p>I was wondering in how does exactly deepcopy work in the following context:</p>
<pre><code>from copy import deepcopy
def copyExample:
self.myDict = {}
firstPosition = "First"
firstPositionContent = ["first", "primero"]
secondPosition = "Second"
secondPositionContent = ["second"]
self.myDict... | 19 | 2009-05-08T07:38:49Z | 21,904,054 | <p>I know it isn't answering your question but I think it's noteworthy for people looking at this question.</p>
<p>If the data you're copying is simple in nature deepcopy might be overkill. With simple in nature I mean if your data is representable as Json. Let me illustrate with code:</p>
<p>I've used <a href="http:... | 1 | 2014-02-20T09:51:02Z | [
"python",
"dictionary",
"deep-copy"
] |
Python cgi and stdin | 838,991 | <p>I'm using pycurl to upload a file via put and python cgi script to receive the file on the server side. Essentially, the code on the server side is:</p>
<pre><code>while True:
next = sys.stdin.read(4096)
if not next:
break
#.... write the buffer
</code></pre>
<p>This seems to work with text, but no... | 1 | 2009-05-08T09:26:34Z | 839,009 | <p>You need to run Python in binary mode. Change your CGI script from:</p>
<pre><code>#!C:/Python25/python.exe
</code></pre>
<p>or whatever it says to:</p>
<pre><code>#!C:/Python25/python.exe -u
</code></pre>
<p>Or you can do it programmatically like this:</p>
<pre><code>msvcrt.setmode(sys.stdin.fileno(), os.O_BI... | 3 | 2009-05-08T09:30:14Z | [
"python",
"cgi",
"stdin"
] |
Python cgi and stdin | 838,991 | <p>I'm using pycurl to upload a file via put and python cgi script to receive the file on the server side. Essentially, the code on the server side is:</p>
<pre><code>while True:
next = sys.stdin.read(4096)
if not next:
break
#.... write the buffer
</code></pre>
<p>This seems to work with text, but no... | 1 | 2009-05-08T09:26:34Z | 839,163 | <p>Use <a href="http://code.google.com/p/modwsgi/" rel="nofollow">mod_wsgi</a> instead of cgi. It will provide you an input file for the upload that's correctly opened.</p>
| 0 | 2009-05-08T10:15:11Z | [
"python",
"cgi",
"stdin"
] |
cursor.rowcount always -1 in sqlite3 in python3k | 839,069 | <p>I am trying to get the <code>rowcount</code> of a <code>sqlite3</code> <code>cursor</code> in my Python3k program, but I am puzzled, as the <code>rowcount</code> is always <code>-1</code>, despite what Python3 docs say (actually it is contradictory, it should be <code>None</code>). Even after fetching all the rows, ... | 12 | 2009-05-08T09:49:27Z | 839,419 | <p>From the <a href="http://docs.python.org/3.0/library/sqlite3.html#sqlite3.Cursor.rowcount">documentation</a>:</p>
<blockquote>
<p>As required by the Python DB API Spec,
the rowcount attribute âis -1 in case
no executeXX() has been performed on
the cursor or the rowcount of the last
operation is not dete... | 11 | 2009-05-08T11:33:06Z | [
"python",
"database",
"sqlite"
] |
cursor.rowcount always -1 in sqlite3 in python3k | 839,069 | <p>I am trying to get the <code>rowcount</code> of a <code>sqlite3</code> <code>cursor</code> in my Python3k program, but I am puzzled, as the <code>rowcount</code> is always <code>-1</code>, despite what Python3 docs say (actually it is contradictory, it should be <code>None</code>). Even after fetching all the rows, ... | 12 | 2009-05-08T09:49:27Z | 845,555 | <p>Instead of "checking if a fetchone() returns something different than None", I suggest:</p>
<pre><code>cursor.execute('SELECT * FROM foobar')
for row in cursor:
...
</code></pre>
<p>this is <code>sqlite</code>-only (not supported in other DB API implementations) but very handy for <code>sqlite</code>-specific P... | 7 | 2009-05-10T15:50:09Z | [
"python",
"database",
"sqlite"
] |
cursor.rowcount always -1 in sqlite3 in python3k | 839,069 | <p>I am trying to get the <code>rowcount</code> of a <code>sqlite3</code> <code>cursor</code> in my Python3k program, but I am puzzled, as the <code>rowcount</code> is always <code>-1</code>, despite what Python3 docs say (actually it is contradictory, it should be <code>None</code>). Even after fetching all the rows, ... | 12 | 2009-05-08T09:49:27Z | 21,838,197 | <pre><code>cursor = newdb.execute('select * from mydb;')
print len(cursor.fetchall())
</code></pre>
<p>The fetchall() will return a list of the rows returned from the select. Len of that list will give you the rowcount.</p>
| 6 | 2014-02-17T19:57:48Z | [
"python",
"database",
"sqlite"
] |
cursor.rowcount always -1 in sqlite3 in python3k | 839,069 | <p>I am trying to get the <code>rowcount</code> of a <code>sqlite3</code> <code>cursor</code> in my Python3k program, but I am puzzled, as the <code>rowcount</code> is always <code>-1</code>, despite what Python3 docs say (actually it is contradictory, it should be <code>None</code>). Even after fetching all the rows, ... | 12 | 2009-05-08T09:49:27Z | 37,788,479 | <p>May better count the rows this way:</p>
<blockquote>
<pre><code>print cur.execute("SELECT COUNT(*) FROM db_name").fetchone()[0]
</code></pre>
</blockquote>
| 2 | 2016-06-13T11:21:05Z | [
"python",
"database",
"sqlite"
] |
Twisted and p2p applications | 839,384 | <p>Can you tell me: could I use twisted for p2p-applications creating? And what protocols should I choose for this?</p>
| 13 | 2009-05-08T11:20:58Z | 839,411 | <p>Yes, twisted was used to create the initial version of Bittorrent. There are some opensource libraries to start from.</p>
| 1 | 2009-05-08T11:30:12Z | [
"python",
"twisted",
"protocols",
"p2p"
] |
Twisted and p2p applications | 839,384 | <p>Can you tell me: could I use twisted for p2p-applications creating? And what protocols should I choose for this?</p>
| 13 | 2009-05-08T11:20:58Z | 839,711 | <p><a href="http://code.activestate.com/recipes/440555/" rel="nofollow">bittorrent twisted python client/server</a></p>
| 4 | 2009-05-08T13:06:53Z | [
"python",
"twisted",
"protocols",
"p2p"
] |
Twisted and p2p applications | 839,384 | <p>Can you tell me: could I use twisted for p2p-applications creating? And what protocols should I choose for this?</p>
| 13 | 2009-05-08T11:20:58Z | 846,470 | <p>Yes, you can absolutely use twisted to create a p2p application. The one that comes first to my mind is Dtella (<a href="http://dtella.org/" rel="nofollow">http://dtella.org/</a>). It's uses the Direct Connect protocol.</p>
<p>They provide the source code, so that could get you started. I know that quite a few diff... | 0 | 2009-05-11T01:46:14Z | [
"python",
"twisted",
"protocols",
"p2p"
] |
Twisted and p2p applications | 839,384 | <p>Can you tell me: could I use twisted for p2p-applications creating? And what protocols should I choose for this?</p>
| 13 | 2009-05-08T11:20:58Z | 846,492 | <p>The best solution is to use the source code for BitTorrent. It was built with Twisted until they switched over to a C++ implementation called Utorrent.</p>
<ul>
<li>Last known Twisted version of BitTorrent
<ul>
<li><a href="http://download.bittorrent.com/dl/archive/BitTorrent-5.2.2.tar.gz" rel="nofollow">http://do... | 12 | 2009-05-11T02:02:34Z | [
"python",
"twisted",
"protocols",
"p2p"
] |
Best Practices for Python Exceptions? | 839,636 | <p>What are the best practices for creating exceptions? I just saw this, and I don't know if I should be horrified, or like it. I read several times in books that exceptions should never ever hold a string, because strings themselves can throw exceptions. Any real truth to this?</p>
<p>Basically from my understanding ... | 45 | 2009-05-08T12:44:43Z | 839,662 | <blockquote>
<p>I read several times in books that
exceptions should never ever hold a
string, because strings themselves can
throw exceptions. Any real truth to
this?</p>
</blockquote>
<p>What?</p>
<p>Please provide a reference or a link to this. It's totally untrue.</p>
<p>Since all objects can throw ex... | 26 | 2009-05-08T12:54:39Z | [
"python",
"exception"
] |
Best Practices for Python Exceptions? | 839,636 | <p>What are the best practices for creating exceptions? I just saw this, and I don't know if I should be horrified, or like it. I read several times in books that exceptions should never ever hold a string, because strings themselves can throw exceptions. Any real truth to this?</p>
<p>Basically from my understanding ... | 45 | 2009-05-08T12:44:43Z | 839,757 | <p>First impression is that it's entirely too much code for an exception.</p>
<p>Formatting exceptions should be done in logger configuration. Same goes for the logging itself.</p>
<p>It also redefines the standard (and deprecated) message attribute, and doesn't call the superclass constructor. (This might or might n... | 2 | 2009-05-08T13:20:42Z | [
"python",
"exception"
] |
Best Practices for Python Exceptions? | 839,636 | <p>What are the best practices for creating exceptions? I just saw this, and I don't know if I should be horrified, or like it. I read several times in books that exceptions should never ever hold a string, because strings themselves can throw exceptions. Any real truth to this?</p>
<p>Basically from my understanding ... | 45 | 2009-05-08T12:44:43Z | 839,844 | <p><a href="http://eli.thegreenplace.net/2008/08/21/robust-exception-handling/" rel="nofollow">Robust exception handling (in Python)</a> - a "best practices for Python exceptions" blog post I wrote a while ago. You may find it useful.</p>
<p>Some key points from the blog:</p>
<blockquote>
<p><strong>Never use excep... | 68 | 2009-05-08T13:41:01Z | [
"python",
"exception"
] |
Best Practices for Python Exceptions? | 839,636 | <p>What are the best practices for creating exceptions? I just saw this, and I don't know if I should be horrified, or like it. I read several times in books that exceptions should never ever hold a string, because strings themselves can throw exceptions. Any real truth to this?</p>
<p>Basically from my understanding ... | 45 | 2009-05-08T12:44:43Z | 8,271,420 | <p>I believe the advice against creating exceptions with a string comes from "Learning Python" (O'Reilly). In a section entitled <strong>String Exceptions Are Right Out!</strong>, it points out the (now removed) ability to create an exception directly with an arbitrary string. </p>
<p>The code it gives as an example i... | 4 | 2011-11-25T15:48:03Z | [
"python",
"exception"
] |
How to use time > year 2038 on official Windows Python 2.5 | 839,755 | <p>The official Python 2.5 on Windows was build with Visual Studio.Net 2003, which uses 32 bit time_t. So when the year is > 2038, it just gives exceptions.</p>
<p>Although this is fixed in Python 2.6 (which changed time_t to 64 bit with VS2008), I'd like to use 2.5 because many modules are already compiled for it.</p... | 5 | 2009-05-08T13:19:17Z | 839,826 | <p>The <code>datetime</code> module in the standard library should work fine for you. What do you need from module <code>time</code> that <code>datetime</code> doesn't offer?</p>
| 5 | 2009-05-08T13:34:27Z | [
"python",
"time",
"python-2.5",
"time-t",
"year2038"
] |
How to use time > year 2038 on official Windows Python 2.5 | 839,755 | <p>The official Python 2.5 on Windows was build with Visual Studio.Net 2003, which uses 32 bit time_t. So when the year is > 2038, it just gives exceptions.</p>
<p>Although this is fixed in Python 2.6 (which changed time_t to 64 bit with VS2008), I'd like to use 2.5 because many modules are already compiled for it.</p... | 5 | 2009-05-08T13:19:17Z | 839,830 | <p>I don't mean to sound trite, but why not:</p>
<ul>
<li>forget about the Y2038 bug with Python 2.5</li>
<li>upgrade to Python 2.6 at some point in the future before 2038</li>
</ul>
<p><strong>edit:</strong>
To clarify: (and I'm serious — I didn't mean to poke fun)</p>
<p>Presumably you can upgrade Python to ... | 5 | 2009-05-08T13:35:51Z | [
"python",
"time",
"python-2.5",
"time-t",
"year2038"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.