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 |
|---|---|---|---|---|---|---|---|---|---|
automatic keystroke to stay logged in | 969,849 | <p>I have a web based email application that logs me out after 10 minutes of inactivity ("For security reasons"). I would like to write something that either a) imitates a keystroke b) pings an ip or c) some other option every 9 minutes so that I stay logged in. I am on my personal laptop in an office with a door, so I... | 1 | 2009-06-09T12:40:42Z | 969,897 | <p>You can also use the <strong>Scheduled Tasks</strong> feature (on the Control Panel) to run it at startup, or you can change your script to ping the IP and exit, and scheduled it to run every 9 minutes. You have nice settings there, for example, you can stop running it at night, so you'll still log out.<br />
You mi... | 3 | 2009-06-09T12:53:25Z | [
"python",
"authentication"
] |
automatic keystroke to stay logged in | 969,849 | <p>I have a web based email application that logs me out after 10 minutes of inactivity ("For security reasons"). I would like to write something that either a) imitates a keystroke b) pings an ip or c) some other option every 9 minutes so that I stay logged in. I am on my personal laptop in an office with a door, so I... | 1 | 2009-06-09T12:40:42Z | 971,984 | <p>Pinging an IP will not likely keep your session from timing out.
You will likely need to do an HTTP GET and include the session cookie supplied by the server to your browser when you login. Your script <strong>may</strong> be able to read the cookie from your browser's cookies folder after you have logged in via th... | 2 | 2009-06-09T19:18:29Z | [
"python",
"authentication"
] |
automatic keystroke to stay logged in | 969,849 | <p>I have a web based email application that logs me out after 10 minutes of inactivity ("For security reasons"). I would like to write something that either a) imitates a keystroke b) pings an ip or c) some other option every 9 minutes so that I stay logged in. I am on my personal laptop in an office with a door, so I... | 1 | 2009-06-09T12:40:42Z | 983,562 | <p>i use the reloadEvery plugin for firefox to keep me logged into websites (forums, phpmyadmin, etc). simple yet effective.</p>
| 0 | 2009-06-11T20:46:43Z | [
"python",
"authentication"
] |
automatic keystroke to stay logged in | 969,849 | <p>I have a web based email application that logs me out after 10 minutes of inactivity ("For security reasons"). I would like to write something that either a) imitates a keystroke b) pings an ip or c) some other option every 9 minutes so that I stay logged in. I am on my personal laptop in an office with a door, so I... | 1 | 2009-06-09T12:40:42Z | 1,786,506 | <p>I've been using this for a while, works great!
<a href="http://stackoverflow.com/questions/969849/automatic-keystroke-to-stay-logged-in/971984#971984">http://stackoverflow.com/questions/969849/automatic-keystroke-to-stay-logged-in/971984#971984</a></p>
| 0 | 2009-11-23T22:28:44Z | [
"python",
"authentication"
] |
users module errors in Google App Engine | 969,877 | <p>I want to use user service of my domain in google App, but...
Is it possible to solve this problem by my side?</p>
<pre>
Traceback (most recent call last):
File "/base/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 501, in __call__
handler.get(*groups)
File "/base/data/home/apps/myapp2... | 1 | 2009-06-09T12:48:23Z | 14,879,943 | <p>Actually not my answer, but from the OP, that didn't act on S. Lott's comment:</p>
<blockquote>
<p>It works now! but I didnt change anything actually, seems like Google need time to update its database for app engine. like 20 mins.</p>
</blockquote>
| 1 | 2013-02-14T16:52:04Z | [
"python",
"google-app-engine",
"user"
] |
Subclassing list | 970,425 | <p>I want create a DataSet class which is basically a list of samples.
But I need to override each insertion operation to the DataSet.</p>
<p>Is there any simple way to do this without writing my own append, extend, iadd etc. ?</p>
<p><strong>UPDATE:</strong> I want to add a backpointer to each sample, holding index ... | 4 | 2009-06-09T14:35:47Z | 970,439 | <p>I don't know of a way of doing what you're asking -- overriding mutators without overriding them. With a class decorator, however, you can "automate" the overriding versions (assuming each can be achieved by wrapping the corresponding method in the base class), so it's not too bad...</p>
<p>Suppose for example that... | 5 | 2009-06-09T14:38:51Z | [
"python"
] |
What is the most state-of-the-art, pure python, XML parser available? | 970,531 | <p>Considering that I want to write python code that would run on Google App Engine and also inside jython, C-extensions are not an option. Amara was a nice library, but due to its C-extensions, I can't use it for either of these platforms.</p>
| 5 | 2009-06-09T14:53:34Z | 970,537 | <p><a href="http://effbot.org/zone/element-index.htm" rel="nofollow">ElementTree</a> is very nice. It's also part of <a href="http://docs.python.org/library/xml.etree.elementtree.html" rel="nofollow">2.5</a>.</p>
| 7 | 2009-06-09T14:54:32Z | [
"python",
"xml",
"google-app-engine",
"jython"
] |
What is the most state-of-the-art, pure python, XML parser available? | 970,531 | <p>Considering that I want to write python code that would run on Google App Engine and also inside jython, C-extensions are not an option. Amara was a nice library, but due to its C-extensions, I can't use it for either of these platforms.</p>
| 5 | 2009-06-09T14:53:34Z | 970,548 | <p><a href="http://docs.python.org/library/xml.sax.html" rel="nofollow">xml.sax</a> is a builtin SAX parser</p>
| 1 | 2009-06-09T14:55:24Z | [
"python",
"xml",
"google-app-engine",
"jython"
] |
What is the most state-of-the-art, pure python, XML parser available? | 970,531 | <p>Considering that I want to write python code that would run on Google App Engine and also inside jython, C-extensions are not an option. Amara was a nice library, but due to its C-extensions, I can't use it for either of these platforms.</p>
| 5 | 2009-06-09T14:53:34Z | 970,554 | <p>There's also <a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">Beautiful Soup</a> (which may be geared more toward HTML, but it also does XML).</p>
| 4 | 2009-06-09T14:56:03Z | [
"python",
"xml",
"google-app-engine",
"jython"
] |
What is the most state-of-the-art, pure python, XML parser available? | 970,531 | <p>Considering that I want to write python code that would run on Google App Engine and also inside jython, C-extensions are not an option. Amara was a nice library, but due to its C-extensions, I can't use it for either of these platforms.</p>
| 5 | 2009-06-09T14:53:34Z | 970,621 | <p>I would normally recommend lxml, but since that uses a C-library (libxml) the alternative would have to be, as Aaron has already suggested, ElementTree (as far as I know there is both a pure python and a c implementation of it available).
<a href="http://code.google.com/p/googleappengine/issues/detail?id=18" rel="no... | 1 | 2009-06-09T15:05:00Z | [
"python",
"xml",
"google-app-engine",
"jython"
] |
How to strip color codes used by mIRC users? | 970,545 | <p>I'm writing a IRC bot in Python using irclib and I'm trying to log the messages on certain channels.<br />
The issue is that some mIRC users and some Bots write using <a href="http://www.mirc.com/help/color.txt" rel="nofollow">color codes</a>.<br />
Any idea on how i could strip those parts and leave only the clear ... | 6 | 2009-06-09T14:55:08Z | 970,598 | <pre><code>p = re.compile("\x03\d+(?:,\d+)?")
p.sub('', text)
</code></pre>
| 1 | 2009-06-09T15:02:06Z | [
"python",
"irc"
] |
How to strip color codes used by mIRC users? | 970,545 | <p>I'm writing a IRC bot in Python using irclib and I'm trying to log the messages on certain channels.<br />
The issue is that some mIRC users and some Bots write using <a href="http://www.mirc.com/help/color.txt" rel="nofollow">color codes</a>.<br />
Any idea on how i could strip those parts and leave only the clear ... | 6 | 2009-06-09T14:55:08Z | 970,723 | <p>Regular expressions are your cleanest bet in my opinion. If you haven't used them before, <a href="http://www.diveintopython.org/regular%5Fexpressions/index.html">this</a> is a good resource. For the full details on Python's regex library, go <a href="http://docs.python.org/library/re.html">here</a>.</p>
<pre><code... | 11 | 2009-06-09T15:17:27Z | [
"python",
"irc"
] |
How to strip color codes used by mIRC users? | 970,545 | <p>I'm writing a IRC bot in Python using irclib and I'm trying to log the messages on certain channels.<br />
The issue is that some mIRC users and some Bots write using <a href="http://www.mirc.com/help/color.txt" rel="nofollow">color codes</a>.<br />
Any idea on how i could strip those parts and leave only the clear ... | 6 | 2009-06-09T14:55:08Z | 1,591,971 | <p>I even had to add '<code>\x0f</code>', whatever use it has</p>
<pre><code>regex = re.compile("\x0f|\x1f|\x02|\x03(?:\d{1,2}(?:,\d{1,2})?)?", re.UNICODE)
regex.sub('', msg)
</code></pre>
| 0 | 2009-10-20T01:12:18Z | [
"python",
"irc"
] |
How to strip color codes used by mIRC users? | 970,545 | <p>I'm writing a IRC bot in Python using irclib and I'm trying to log the messages on certain channels.<br />
The issue is that some mIRC users and some Bots write using <a href="http://www.mirc.com/help/color.txt" rel="nofollow">color codes</a>.<br />
Any idea on how i could strip those parts and leave only the clear ... | 6 | 2009-06-09T14:55:08Z | 2,451,544 | <p>As I found this question useful, I figured I'd contribute.</p>
<p>I added a couple things to the regex</p>
<pre><code>regex = re.compile("\x1f|\x02|\x03|\x16|\x0f(?:\d{1,2}(?:,\d{1,2})?)?", re.UNICODE)
</code></pre>
<p><code>\x16</code> removed the "reverse" character. <code>\x0f</code> gets rid of another bold c... | 1 | 2010-03-16T01:12:10Z | [
"python",
"irc"
] |
How to strip color codes used by mIRC users? | 970,545 | <p>I'm writing a IRC bot in Python using irclib and I'm trying to log the messages on certain channels.<br />
The issue is that some mIRC users and some Bots write using <a href="http://www.mirc.com/help/color.txt" rel="nofollow">color codes</a>.<br />
Any idea on how i could strip those parts and leave only the clear ... | 6 | 2009-06-09T14:55:08Z | 3,504,063 | <p>The second-rated and following suggestions are defective, as they look for digits after whatever character, but not after the color code character.</p>
<p>I have improved and combined all posts, with the following consequences:</p>
<ul>
<li>we <em>do</em> remove the reverse character</li>
<li>remove color codes <e... | 7 | 2010-08-17T15:21:24Z | [
"python",
"irc"
] |
How to strip color codes used by mIRC users? | 970,545 | <p>I'm writing a IRC bot in Python using irclib and I'm trying to log the messages on certain channels.<br />
The issue is that some mIRC users and some Bots write using <a href="http://www.mirc.com/help/color.txt" rel="nofollow">color codes</a>.<br />
Any idea on how i could strip those parts and leave only the clear ... | 6 | 2009-06-09T14:55:08Z | 29,279,757 | <p>AutoDl-irssi had a very good one written in perl, here it is in python:</p>
<p><code>def stripMircColorCodes(line) :
line = re.sub("\x03\d\d?,\d\d?","",line)
line = re.sub("\x03\d\d?","",line)
line = re.sub("[\x01-\x1F]","",line)
return line</code></p>
| 1 | 2015-03-26T13:30:43Z | [
"python",
"irc"
] |
How to strip color codes used by mIRC users? | 970,545 | <p>I'm writing a IRC bot in Python using irclib and I'm trying to log the messages on certain channels.<br />
The issue is that some mIRC users and some Bots write using <a href="http://www.mirc.com/help/color.txt" rel="nofollow">color codes</a>.<br />
Any idea on how i could strip those parts and leave only the clear ... | 6 | 2009-06-09T14:55:08Z | 29,645,095 | <p>I know I posted wanting a regex solution because it could be cleaner, I have created a non regex solution that works perfect. </p>
<pre><code>def colourstrip(data):
find = data.find('\x03')
while find > -1:
done = False
data = data[0:find] + data[find+1:]
if len(data) <= find+1... | 0 | 2015-04-15T08:19:55Z | [
"python",
"irc"
] |
Is a file on the same filesystem as another file in python? | 970,742 | <p>Is there a simple way of finding out if a file is on the same filesystem as another file?</p>
<p>The following command:</p>
<pre><code>import shutil
shutil.move('filepatha', 'filepathb')
</code></pre>
<p>will try and rename the file (if it's on the same filesystem), otherwise it will copy it, then unlink.</p>
<p... | 4 | 2009-06-09T15:20:23Z | 970,830 | <p>Use <code>os.stat</code> (on a filename) or <code>os.fstat</code> (on a file descriptor). The <code>st_dev</code> of the result will be the device number. If they are on the same file system, it will be the same in both.</p>
<pre><code>import os
def same_fs(file1, file2):
dev1 = os.stat(file1).st_dev
dev2 ... | 10 | 2009-06-09T15:33:38Z | [
"python",
"filesystems"
] |
Threads in Java and Python | 970,909 | <p>i have few questions about threads in Python and Java...</p>
<ol>
<li>Is it possible to give priorities to Python threads, as it is in Java?</li>
<li>How can I kill, stop, suspend and interrupt thread in Python?</li>
<li>Thread groups - what are they really for? Does Python support them too?</li>
<li>Synchronizatio... | 5 | 2009-06-09T15:49:05Z | 970,960 | <p>Assuming we're talking about the classic (CPython) implementation:</p>
<ol>
<li>no, no priorities in Python's threads</li>
<li>you can't do any of these things to a thread in Python</li>
<li>no thread groups in Python</li>
<li>you can use many approaches, such as locks, but the recommended approach is generally to ... | 12 | 2009-06-09T15:55:02Z | [
"java",
"python",
"multithreading"
] |
Threads in Java and Python | 970,909 | <p>i have few questions about threads in Python and Java...</p>
<ol>
<li>Is it possible to give priorities to Python threads, as it is in Java?</li>
<li>How can I kill, stop, suspend and interrupt thread in Python?</li>
<li>Thread groups - what are they really for? Does Python support them too?</li>
<li>Synchronizatio... | 5 | 2009-06-09T15:49:05Z | 971,025 | <p>Just a sidestep about point 1 here, because Java Thread priorities might not work as one would expect.</p>
<p>From the SCJP guide:</p>
<blockquote>
<p>Because thread-scheduling priority behaviour is not guaranteed, use thread priorities as a way to improve the efficiency of your program, but just be sure your pr... | 0 | 2009-06-09T16:06:03Z | [
"java",
"python",
"multithreading"
] |
Threads in Java and Python | 970,909 | <p>i have few questions about threads in Python and Java...</p>
<ol>
<li>Is it possible to give priorities to Python threads, as it is in Java?</li>
<li>How can I kill, stop, suspend and interrupt thread in Python?</li>
<li>Thread groups - what are they really for? Does Python support them too?</li>
<li>Synchronizatio... | 5 | 2009-06-09T15:49:05Z | 971,134 | <p>Regular java thread priorities can't be counted on. You may find a lower priority thread running when a higher priority thread is ready and waiting. </p>
<p>There is something called "realtime java" (see <a href="http://www.rtsj.org" rel="nofollow">http://www.rtsj.org</a>) which does enforce thread priority, at lea... | 1 | 2009-06-09T16:27:29Z | [
"java",
"python",
"multithreading"
] |
Threads in Java and Python | 970,909 | <p>i have few questions about threads in Python and Java...</p>
<ol>
<li>Is it possible to give priorities to Python threads, as it is in Java?</li>
<li>How can I kill, stop, suspend and interrupt thread in Python?</li>
<li>Thread groups - what are they really for? Does Python support them too?</li>
<li>Synchronizatio... | 5 | 2009-06-09T15:49:05Z | 972,935 | <p>Unfortunately the standard Python package has something called the GIL, or global interpreter lock. This means only one of your threads will ever be running at a time. That being said, simple multithreaded applications are possible and pretty easy to write. The threading module contains basic synchronization prim... | 0 | 2009-06-09T23:02:07Z | [
"java",
"python",
"multithreading"
] |
Threads in Java and Python | 970,909 | <p>i have few questions about threads in Python and Java...</p>
<ol>
<li>Is it possible to give priorities to Python threads, as it is in Java?</li>
<li>How can I kill, stop, suspend and interrupt thread in Python?</li>
<li>Thread groups - what are they really for? Does Python support them too?</li>
<li>Synchronizatio... | 5 | 2009-06-09T15:49:05Z | 977,446 | <p>I felt the need to debunk the common myths perpetuated here:</p>
<blockquote>
<p>Is it possible to give priorities to Python threads, as it is in Java?</p>
</blockquote>
<p>Not in the OS sense. But you can use cooperative multitasking and your own custom scheduler to ensure that certain threads use more time. Yo... | 1 | 2009-06-10T18:42:17Z | [
"java",
"python",
"multithreading"
] |
Threads in Java and Python | 970,909 | <p>i have few questions about threads in Python and Java...</p>
<ol>
<li>Is it possible to give priorities to Python threads, as it is in Java?</li>
<li>How can I kill, stop, suspend and interrupt thread in Python?</li>
<li>Thread groups - what are they really for? Does Python support them too?</li>
<li>Synchronizatio... | 5 | 2009-06-09T15:49:05Z | 983,519 | <p>here's an example of how I allow my threads to be halted (only works for threads within loops really, unless you wanted to place an if "self.alive" before every line):</p>
<pre><code>import threading, Queue
class HaltableThread(object.Thread):
def __init__(self):
self.stringQueue = Queue.Queue()
self... | 1 | 2009-06-11T20:36:58Z | [
"java",
"python",
"multithreading"
] |
Testing for mysterious load errors in python/django | 970,953 | <p>This is related to this <a href="http://stackoverflow.com/questions/926579/configure-apache-to-recover-from-modpython-errors">http://stackoverflow.com/questions/926579/configure-apache-to-recover-from-modpython-errors</a>, although I've since stopped assuming that this has anything to do with mod_python. Essentiall... | 0 | 2009-06-09T15:54:13Z | 971,454 | <p><strong>"Do these configuration disasters seem like a likely explanation for sporadic ImportErrors"</strong></p>
<p>Yes. An old <code>.pyc</code> file is a disaster of the first magnitude.</p>
<p>We develop on Windows, but run production on Red Hat Linux. An accidentally moved .pyc file is an absolute mystery to... | 2 | 2009-06-09T17:32:29Z | [
"python",
"django",
"apache",
"configuration"
] |
Python and reading lines | 970,975 | <p>When i run an .exe file it prints stuff out to the screen. I don't know the specific line of where i want printed out but is there a way I can get python to print the next line after one that says "Summary" ? I know that is in there when it prints and I need the info right after. Thanks!</p>
| 0 | 2009-06-09T15:57:31Z | 971,003 | <p>actually </p>
<pre><code>program.exe | grep -A 1 Summary
</code></pre>
<p>would do your job.</p>
| 2 | 2009-06-09T16:02:18Z | [
"python",
"printing",
"command-prompt"
] |
Python and reading lines | 970,975 | <p>When i run an .exe file it prints stuff out to the screen. I don't know the specific line of where i want printed out but is there a way I can get python to print the next line after one that says "Summary" ? I know that is in there when it prints and I need the info right after. Thanks!</p>
| 0 | 2009-06-09T15:57:31Z | 971,029 | <p>Really simple Python solution:</p>
<pre><code>def getSummary(s):
return s[s.find('\nSummary'):]
</code></pre>
<p>This returns everything after the first instance of <strong>Summary</strong>
<br>If you need to be more specific, I'd recommend regular expressions.</p>
| 3 | 2009-06-09T16:06:18Z | [
"python",
"printing",
"command-prompt"
] |
Python and reading lines | 970,975 | <p>When i run an .exe file it prints stuff out to the screen. I don't know the specific line of where i want printed out but is there a way I can get python to print the next line after one that says "Summary" ? I know that is in there when it prints and I need the info right after. Thanks!</p>
| 0 | 2009-06-09T15:57:31Z | 975,486 | <p>If the exe prints to screen then pipe that output to a text file. I have assumed the exe is on windows, then from the command line: </p>
<blockquote>
<p>myapp.exe > output.txt</p>
</blockquote>
<p>And your reasonably robust python code would be something like:</p>
<pre><code>try:
f = open("output.txt", "r")... | 1 | 2009-06-10T13:13:27Z | [
"python",
"printing",
"command-prompt"
] |
Have csv.reader tell when it is on the last line | 970,983 | <p>Apparently some csv output implementation somewhere truncates field separators from the right on the last row and only the last row in the file when the fields are null.</p>
<p>Example input csv, fields 'c' and 'd' are nullable:</p>
<pre><code>a|b|c|d
1|2||
1|2|3|4
3|4||
2|3
</code></pre>
<p>In something like the... | 6 | 2009-06-09T15:58:47Z | 971,015 | <p>Basically you only know you've run out <em>after</em> you've run out. So you could wrap the <code>reader</code> iterator, e.g. as follows:</p>
<pre><code>def isLast(itr):
old = itr.next()
for new in itr:
yield False, old
old = new
yield True, old
</code></pre>
<p>and change your code to:</p>
<pre><c... | 10 | 2009-06-09T16:03:43Z | [
"python",
"csv"
] |
Have csv.reader tell when it is on the last line | 970,983 | <p>Apparently some csv output implementation somewhere truncates field separators from the right on the last row and only the last row in the file when the fields are null.</p>
<p>Example input csv, fields 'c' and 'd' are nullable:</p>
<pre><code>a|b|c|d
1|2||
1|2|3|4
3|4||
2|3
</code></pre>
<p>In something like the... | 6 | 2009-06-09T15:58:47Z | 971,024 | <p>Just extend the row to the length of the header:</p>
<pre><code>for line_num, row in enumerate(reader):
while len(row) < len(header):
row.append('')
...
</code></pre>
| 0 | 2009-06-09T16:05:57Z | [
"python",
"csv"
] |
Have csv.reader tell when it is on the last line | 970,983 | <p>Apparently some csv output implementation somewhere truncates field separators from the right on the last row and only the last row in the file when the fields are null.</p>
<p>Example input csv, fields 'c' and 'd' are nullable:</p>
<pre><code>a|b|c|d
1|2||
1|2|3|4
3|4||
2|3
</code></pre>
<p>In something like the... | 6 | 2009-06-09T15:58:47Z | 1,203,092 | <p>Could you not just catch the error when the csv reader reads the last line in a </p>
<p>try:
... do your stuff here...
except: StopIteration </p>
<p>condition ?</p>
<p>See the following python code on stackoverflow for an example of how to use the try: catch: <a href="http://stackoverflow.com/questions/12028... | 0 | 2009-07-29T21:15:46Z | [
"python",
"csv"
] |
Have csv.reader tell when it is on the last line | 970,983 | <p>Apparently some csv output implementation somewhere truncates field separators from the right on the last row and only the last row in the file when the fields are null.</p>
<p>Example input csv, fields 'c' and 'd' are nullable:</p>
<pre><code>a|b|c|d
1|2||
1|2|3|4
3|4||
2|3
</code></pre>
<p>In something like the... | 6 | 2009-06-09T15:58:47Z | 1,204,103 | <p>If you have an expectation of a fixed number of columns in each row, then you should be defensive against:</p>
<p>(1) <em>ANY</em> row being shorter -- e.g. a writer (SQL Server / Query Analyzer IIRC) may omit trailing NULLs <em>at random</em>; users may fiddle with the file using a text editor, including leaving b... | 1 | 2009-07-30T02:09:46Z | [
"python",
"csv"
] |
Have csv.reader tell when it is on the last line | 970,983 | <p>Apparently some csv output implementation somewhere truncates field separators from the right on the last row and only the last row in the file when the fields are null.</p>
<p>Example input csv, fields 'c' and 'd' are nullable:</p>
<pre><code>a|b|c|d
1|2||
1|2|3|4
3|4||
2|3
</code></pre>
<p>In something like the... | 6 | 2009-06-09T15:58:47Z | 10,833,767 | <p>If you use <code>for row in reader:</code>, it will just stop the loop after the last item has been read.</p>
| 0 | 2012-05-31T12:36:52Z | [
"python",
"csv"
] |
Have csv.reader tell when it is on the last line | 970,983 | <p>Apparently some csv output implementation somewhere truncates field separators from the right on the last row and only the last row in the file when the fields are null.</p>
<p>Example input csv, fields 'c' and 'd' are nullable:</p>
<pre><code>a|b|c|d
1|2||
1|2|3|4
3|4||
2|3
</code></pre>
<p>In something like the... | 6 | 2009-06-09T15:58:47Z | 22,941,027 | <p>if you want to get exactly the last row try this code:</p>
<pre><code>with open("\\".join([myPath,files]), 'r') as f:
print f.readlines()[-1] #or your own manipulations
</code></pre>
<p>If you want to continue working with values from row do the following:</p>
<pre><code>f.readlines()[-1].split(",")[0] #this ... | 1 | 2014-04-08T15:08:37Z | [
"python",
"csv"
] |
gql does not work for get paramters for keys | 971,153 | <p>I am trying to compare the key to filter results in gql in python but the direct comparision nor typecasting to int works. There fore I am forced to make a work around as mentioned in uncommented lines below. Any clues.</p>
<pre><code>row = self.request.get("selectedrow")
#mydbobject = DbModel.gql("WHERE key=:1", r... | 0 | 2009-06-09T16:31:59Z | 972,195 | <p>Am I correct in my assumption that you're basically just want to retrieve an object with a particular key? If so, the <a href="http://code.google.com/appengine/docs/python/datastore/modelclass.html" rel="nofollow">get and get_by_id methods</a> may be of help:</p>
<pre><code>mydbobject = DbModel.get_by_id(int(self.r... | 1 | 2009-06-09T19:58:55Z | [
"python",
"google-app-engine",
"gqlquery"
] |
gql does not work for get paramters for keys | 971,153 | <p>I am trying to compare the key to filter results in gql in python but the direct comparision nor typecasting to int works. There fore I am forced to make a work around as mentioned in uncommented lines below. Any clues.</p>
<pre><code>row = self.request.get("selectedrow")
#mydbobject = DbModel.gql("WHERE key=:1", r... | 0 | 2009-06-09T16:31:59Z | 972,350 | <p>The error "invalid literal for int()" indicate that the paramater pass to int was not a string representing an integer. Try to print the value of "row" for debuging, I bet it is an empty string.</p>
<p>The correct way to retrieve an element from the key is simply by using the method "get" or "get_by_id".
In your ca... | 0 | 2009-06-09T20:34:56Z | [
"python",
"google-app-engine",
"gqlquery"
] |
cx_Oracle And User Defined Types | 971,250 | <p>Does anyone know an easier way to work with user defined types in Oracle using cx_Oracle?</p>
<p>For example, if I have these two types:</p>
<pre><code>CREATE type my_type as object(
component varchar2(30)
,key varchar2(100)
,value varchar2(4000))
/
CREATE type my_type_tab as table of my_type
/
</code></pre... | 2 | 2009-06-09T16:50:27Z | 971,328 | <p>Are you trying to populate the table of objects more efficiently?</p>
<p>If you can do a SELECT, have a look at the BULK COLLECT INTO clause</p>
| 0 | 2009-06-09T17:06:55Z | [
"python",
"oracle",
"cx-oracle"
] |
cx_Oracle And User Defined Types | 971,250 | <p>Does anyone know an easier way to work with user defined types in Oracle using cx_Oracle?</p>
<p>For example, if I have these two types:</p>
<pre><code>CREATE type my_type as object(
component varchar2(30)
,key varchar2(100)
,value varchar2(4000))
/
CREATE type my_type_tab as table of my_type
/
</code></pre... | 2 | 2009-06-09T16:50:27Z | 972,200 | <p>I'm not quite sure what you mean by hard-coded, but you can build a dynamic array like this:</p>
<pre><code>SQL> desc my_procedure
Parameter Type Mode Default?
--------- ----------- ---- --------
P_IN MY_TYPE_TAB IN
SQL> declare
2 l_tab my_type_tab;
3 begin
4 select my_type(ow... | -1 | 2009-06-09T19:59:55Z | [
"python",
"oracle",
"cx-oracle"
] |
cx_Oracle And User Defined Types | 971,250 | <p>Does anyone know an easier way to work with user defined types in Oracle using cx_Oracle?</p>
<p>For example, if I have these two types:</p>
<pre><code>CREATE type my_type as object(
component varchar2(30)
,key varchar2(100)
,value varchar2(4000))
/
CREATE type my_type_tab as table of my_type
/
</code></pre... | 2 | 2009-06-09T16:50:27Z | 976,322 | <p>While cx_Oracle can select user defined types, it does not to my knowledge support passing in user defined types as bind variables. So for example the following will work:</p>
<pre><code>cursor.execute("select my_type('foo', 'bar', 'hello') from dual")
val, = cursor.fetchone()
print val.COMPONENT, val.KEY, val.VAL... | 3 | 2009-06-10T15:24:04Z | [
"python",
"oracle",
"cx-oracle"
] |
Opencv sort sequences in python | 971,629 | <p>I'm using the Python OpenCV bindings to find the contours in an Image.
I'm know looking for the possibility to sort this sequence. </p>
<p>It seems the usual python ways for list sorting don't apply here because of the linked list structure generated from OpenCV. </p>
<p>Do you know a good way to sort the Contour... | 1 | 2009-06-09T18:08:31Z | 971,697 | <p>You have to be able to look at an entire sequence in order to sort it (easily). Thus you should copy it to sort it.</p>
<p>I would do something like</p>
<pre><code> contourList = list(<your linked list>)
def sizeKey(countour):
<get size from contour>
contourList.sort(key = sizeKey)
</code... | 2 | 2009-06-09T18:22:16Z | [
"python",
"sorting",
"image-processing",
"opencv",
"contour"
] |
Interfacing web crawler with Django front end | 971,660 | <p>I'm trying to do three things.</p>
<p>One: crawl and archive, at least daily, a predefined set of sites.</p>
<p>Two: run overnight batch python scripts on this data (text classification).</p>
<p>Three: expose a Django based front end to users to let them search the crawled data.</p>
<p>I've been playing with Apa... | 2 | 2009-06-09T18:14:07Z | 971,729 | <p>If you insert your django project's app directories into sys.path, you can write standard Python scripts that utilize the Django ORM functionality. We have an /admin/ directory that contains scripts to perform various tasks-- at the top of each script is a block that looks like:</p>
<pre><code>sys.path.insert(0,os... | 3 | 2009-06-09T18:28:06Z | [
"python",
"django",
"web-crawler"
] |
Interfacing web crawler with Django front end | 971,660 | <p>I'm trying to do three things.</p>
<p>One: crawl and archive, at least daily, a predefined set of sites.</p>
<p>Two: run overnight batch python scripts on this data (text classification).</p>
<p>Three: expose a Django based front end to users to let them search the crawled data.</p>
<p>I've been playing with Apa... | 2 | 2009-06-09T18:14:07Z | 971,752 | <p>If you don't want to write crawler using Django ORM (or already have working crawler) you could share database between crawler and Django-powred front-end.</p>
<p>To be able to search (and edit) existing database using Django admin you should create Django models.
The easy way for that is described here:</p>
<p><a... | 1 | 2009-06-09T18:32:19Z | [
"python",
"django",
"web-crawler"
] |
Interfacing web crawler with Django front end | 971,660 | <p>I'm trying to do three things.</p>
<p>One: crawl and archive, at least daily, a predefined set of sites.</p>
<p>Two: run overnight batch python scripts on this data (text classification).</p>
<p>Three: expose a Django based front end to users to let them search the crawled data.</p>
<p>I've been playing with Apa... | 2 | 2009-06-09T18:14:07Z | 971,834 | <p>You write your own crawler using <a href="http://docs.python.org/library/urllib2.html" rel="nofollow">urllib2</a> to get the pages and <a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">Beautiful Soup</a> to parse the HTML looking for the content.</p>
<p>Here's an example of reading a page:</p>
... | 2 | 2009-06-09T18:52:47Z | [
"python",
"django",
"web-crawler"
] |
Iterating through a multidimensional array in Python | 971,678 | <p>I have created a multidimensional array in Python like this:</p>
<pre><code>self.cells = np.empty((r,c),dtype=np.object)
</code></pre>
<p>Now I want to iterate through all elements of my twodimensional array, and I do not care about the order. How do I achieve this?</p>
| 21 | 2009-06-09T18:18:06Z | 971,733 | <p>Just iterate over one dimension, then the other.</p>
<pre><code>for row in self.cells:
for cell in row:
do_something(cell)
</code></pre>
<p>Of course, with only two dimensions, you can compress this down to a single loop using a <a href="http://docs.python.org/tutorial/datastructures.html#list-comprehe... | 11 | 2009-06-09T18:29:32Z | [
"python",
"arrays",
"multidimensional-array",
"numpy",
"iteration"
] |
Iterating through a multidimensional array in Python | 971,678 | <p>I have created a multidimensional array in Python like this:</p>
<pre><code>self.cells = np.empty((r,c),dtype=np.object)
</code></pre>
<p>Now I want to iterate through all elements of my twodimensional array, and I do not care about the order. How do I achieve this?</p>
| 21 | 2009-06-09T18:18:06Z | 971,774 | <p>It's clear you're using numpy. With numpy you can just do:</p>
<pre><code>for cell in self.cells.flat:
do_somethin(cell)
</code></pre>
| 34 | 2009-06-09T18:34:53Z | [
"python",
"arrays",
"multidimensional-array",
"numpy",
"iteration"
] |
Iterating through a multidimensional array in Python | 971,678 | <p>I have created a multidimensional array in Python like this:</p>
<pre><code>self.cells = np.empty((r,c),dtype=np.object)
</code></pre>
<p>Now I want to iterate through all elements of my twodimensional array, and I do not care about the order. How do I achieve this?</p>
| 21 | 2009-06-09T18:18:06Z | 971,777 | <p>How about this:</p>
<pre><code>import itertools
for cell in itertools.chain(*self.cells):
cell.drawCell(surface, posx, posy)
</code></pre>
| 4 | 2009-06-09T18:35:06Z | [
"python",
"arrays",
"multidimensional-array",
"numpy",
"iteration"
] |
Iterating through a multidimensional array in Python | 971,678 | <p>I have created a multidimensional array in Python like this:</p>
<pre><code>self.cells = np.empty((r,c),dtype=np.object)
</code></pre>
<p>Now I want to iterate through all elements of my twodimensional array, and I do not care about the order. How do I achieve this?</p>
| 21 | 2009-06-09T18:18:06Z | 4,613,211 | <p>If you need to change the values of the individual cells then ndenumerate (in numpy) is your friend. Even if you don't it probably still is!</p>
<pre><code>for index,value in ndenumerate( self.cells ):
do_something( value )
self.cells[index] = new_value
</code></pre>
| 21 | 2011-01-06T08:56:36Z | [
"python",
"arrays",
"multidimensional-array",
"numpy",
"iteration"
] |
Iterating through a multidimensional array in Python | 971,678 | <p>I have created a multidimensional array in Python like this:</p>
<pre><code>self.cells = np.empty((r,c),dtype=np.object)
</code></pre>
<p>Now I want to iterate through all elements of my twodimensional array, and I do not care about the order. How do I achieve this?</p>
| 21 | 2009-06-09T18:18:06Z | 33,863,653 | <p>you can get the index of each element as well as the element itself using enumerate command:</p>
<pre><code>for (i,row) in enumerate(cells):
for (j,value) in enumerate(row):
print i,j,value
</code></pre>
<p><code>i</code>,<code>j</code> contain the row and column index of the element and <code>value</code> i... | 2 | 2015-11-23T04:18:17Z | [
"python",
"arrays",
"multidimensional-array",
"numpy",
"iteration"
] |
Iterating through a multidimensional array in Python | 971,678 | <p>I have created a multidimensional array in Python like this:</p>
<pre><code>self.cells = np.empty((r,c),dtype=np.object)
</code></pre>
<p>Now I want to iterate through all elements of my twodimensional array, and I do not care about the order. How do I achieve this?</p>
| 21 | 2009-06-09T18:18:06Z | 35,247,114 | <p>No one has an answer that will work form arbitrarily many dimensions without numpy, so I'll put here a recursive solution that I've used</p>
<pre><code>def iterThrough(lists):
if not hasattr(lists[0], '__iter__'):
for val in lists:
yield val
else:
for l in lists:
for val in iterThrough(l):
... | 0 | 2016-02-06T22:12:58Z | [
"python",
"arrays",
"multidimensional-array",
"numpy",
"iteration"
] |
Django conditional aggregation | 971,695 | <p>Does anyone know of how I would, through the django ORM, produce a query that conditionally aggregated related models?</p>
<p>Let's say, for example, that you run a site that sells stuff, and you want to know how much each employee has sold in the last seven days. It's simple enough to do this over all sales:</p>
... | 1 | 2009-06-09T18:21:34Z | 972,234 | <p>Alright, I guess I didn't think this through very far. I didn't realize that filter handled things with a left join (though thinking on it, how else would it map to the db?), so the obvious answer is:</p>
<pre><code>Employee.objects.filter(type='salesman').filter(sale__timestamp__gte = start_date)\
.exclud... | 2 | 2009-06-09T20:08:05Z | [
"python",
"database",
"django",
"conditional",
"aggregation"
] |
Caching values in Python list comprehensions | 971,857 | <p>I'm using the following list comprehension:</p>
<pre><code>resources = [obj.get("file") for obj in iterator if obj.get("file") != None]
</code></pre>
<p>Is there a way to "cache" the value of <code>obj.get("file")</code> when it's checked in the if statement so that it doesn't have to call <code>get</code> again o... | 4 | 2009-06-09T18:57:40Z | 971,880 | <pre><code>resources = filter(None, (obj.get("file") for obj in iterator))
</code></pre>
<p>See the documentation for <a href="http://docs.python.org/library/functions.html#filter">filter</a> for how to provide your own evaluation function. Passing <code>None</code> for the function (as above) filters out all values w... | 9 | 2009-06-09T19:01:36Z | [
"python",
"list-comprehension"
] |
Caching values in Python list comprehensions | 971,857 | <p>I'm using the following list comprehension:</p>
<pre><code>resources = [obj.get("file") for obj in iterator if obj.get("file") != None]
</code></pre>
<p>Is there a way to "cache" the value of <code>obj.get("file")</code> when it's checked in the if statement so that it doesn't have to call <code>get</code> again o... | 4 | 2009-06-09T18:57:40Z | 971,890 | <p>Try something like this: </p>
<pre><code>resources = filter( lambda x: x is not None, [obj.get("file") for ob jin iterator])
</code></pre>
| 1 | 2009-06-09T19:02:58Z | [
"python",
"list-comprehension"
] |
Caching values in Python list comprehensions | 971,857 | <p>I'm using the following list comprehension:</p>
<pre><code>resources = [obj.get("file") for obj in iterator if obj.get("file") != None]
</code></pre>
<p>Is there a way to "cache" the value of <code>obj.get("file")</code> when it's checked in the if statement so that it doesn't have to call <code>get</code> again o... | 4 | 2009-06-09T18:57:40Z | 971,999 | <p>Create a temporary dict to hold values. Then, create a function that uses this dict as a cache, and use that function in the list comprehension, like so:</p>
<pre><code>obj_cache = {}
def cache_get (target, key):
if (target, key) not in obj_cache: obj_cache[(target, key)] = target.get(key)
return obj_cache... | 1 | 2009-06-09T19:20:55Z | [
"python",
"list-comprehension"
] |
Caching values in Python list comprehensions | 971,857 | <p>I'm using the following list comprehension:</p>
<pre><code>resources = [obj.get("file") for obj in iterator if obj.get("file") != None]
</code></pre>
<p>Is there a way to "cache" the value of <code>obj.get("file")</code> when it's checked in the if statement so that it doesn't have to call <code>get</code> again o... | 4 | 2009-06-09T18:57:40Z | 972,253 | <p>If you want to stay with list / iterator comprehensions instead of using <code>filter</code> you can simply use: </p>
<pre><code>resources = [file_obj
for file_obj in (obj.get("file") for obj in iterator)
if file_obj is not None]
</code></pre>
| 6 | 2009-06-09T20:12:22Z | [
"python",
"list-comprehension"
] |
How to access the session object in Django Syndication framework code | 972,267 | <p>Quick question. In my syndication feed framework code, </p>
<p><a href="http://docs.djangoproject.com/en/dev/ref/contrib/syndication/" rel="nofollow">http://docs.djangoproject.com/en/dev/ref/contrib/syndication/</a> </p>
<p>what is the best way to get access to the session? I don't have
access to the request, a... | 1 | 2009-06-09T20:15:35Z | 972,477 | <p>It seems like a design flaw to be trying to access session data in the LatestPhoto's class. I would assume that if your syndication feed depended on a session variable, then the items you're syndicating (<code>LatestPhotos</code>) should be constructed with that variable?</p>
<p>Can you make the logic flow decisio... | 2 | 2009-06-09T21:00:15Z | [
"python",
"django"
] |
How to access the session object in Django Syndication framework code | 972,267 | <p>Quick question. In my syndication feed framework code, </p>
<p><a href="http://docs.djangoproject.com/en/dev/ref/contrib/syndication/" rel="nofollow">http://docs.djangoproject.com/en/dev/ref/contrib/syndication/</a> </p>
<p>what is the best way to get access to the session? I don't have
access to the request, a... | 1 | 2009-06-09T20:15:35Z | 975,410 | <p>Figured it out - drrr, so simple. The syndication framework Feed class has a member called request...so simple I never thought of it :)</p>
<p>[this comment applies to django 1.1 and earlier syndication framework]</p>
| 0 | 2009-06-10T13:00:54Z | [
"python",
"django"
] |
spawning process from python | 972,362 | <p>im spawning a script that runs for a long time from a web app like this:</p>
<pre><code>os.spawnle(os.P_NOWAIT, "../bin/producenotify.py", "producenotify.py", "xx",os.environ)
</code></pre>
<p>the script is spawned successfully and it runs, but till it gets over i am not able to free the port that is used by the w... | 11 | 2009-06-09T20:38:50Z | 972,383 | <p>As @mark clarified it's a Linux system, the script could easily make itself fully independent, i.e., a <em>daemon</em>, by following this <a href="http://code.activestate.com/recipes/278731/" rel="nofollow">recipe</a>. (You could also do it in the parent after an <code>os.fork</code> and only then <code>os.exec...<... | 25 | 2009-06-09T20:43:37Z | [
"python",
"process",
"spawn"
] |
spawning process from python | 972,362 | <p>im spawning a script that runs for a long time from a web app like this:</p>
<pre><code>os.spawnle(os.P_NOWAIT, "../bin/producenotify.py", "producenotify.py", "xx",os.environ)
</code></pre>
<p>the script is spawned successfully and it runs, but till it gets over i am not able to free the port that is used by the w... | 11 | 2009-06-09T20:38:50Z | 972,963 | <p>You can use the multiprocessing library to spawn processes. A basic example is shown here:</p>
<pre><code>from multiprocessing import Process
def f(name):
print 'hello', name
if __name__ == '__main__':
p = Process(target=f, args=('bob',))
p.start()
p.join()
</code></pre>
| 11 | 2009-06-09T23:10:20Z | [
"python",
"process",
"spawn"
] |
Python regular expression for multiple tags | 972,749 | <p>I would like to know how to retrieve all results from each <code><p></code> tag.</p>
<pre><code>import re
htmlText = '<p data="5" size="4">item1</p><p size="4">item2</p><p size="4">item3</p>'
print re.match('<p[^>]*size="[0-9]">(.*?)</p>', htmlText).groups()
... | 2 | 2009-06-09T22:09:22Z | 972,760 | <p>You can use <code>re.findall</code> like this:</p>
<pre><code>import re
html = '<p data="5" size="4">item1</p><p size="4">item2</p><p size="4">item3</p>'
print re.findall('<p[^>]*size="[0-9]">(.*?)</p>', html)
# This prints: ['item1', 'item2', 'item3']
</code></pre... | 2 | 2009-06-09T22:12:46Z | [
"python",
"html",
"regex"
] |
Python regular expression for multiple tags | 972,749 | <p>I would like to know how to retrieve all results from each <code><p></code> tag.</p>
<pre><code>import re
htmlText = '<p data="5" size="4">item1</p><p size="4">item2</p><p size="4">item3</p>'
print re.match('<p[^>]*size="[0-9]">(.*?)</p>', htmlText).groups()
... | 2 | 2009-06-09T22:09:22Z | 972,768 | <p>For this type of problem, it is recommended to use a DOM parser, not regex.</p>
<p>I've seen <a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">Beautiful Soup</a> frequently recommended for Python</p>
| 11 | 2009-06-09T22:14:02Z | [
"python",
"html",
"regex"
] |
Python regular expression for multiple tags | 972,749 | <p>I would like to know how to retrieve all results from each <code><p></code> tag.</p>
<pre><code>import re
htmlText = '<p data="5" size="4">item1</p><p size="4">item2</p><p size="4">item3</p>'
print re.match('<p[^>]*size="[0-9]">(.*?)</p>', htmlText).groups()
... | 2 | 2009-06-09T22:09:22Z | 972,846 | <p>Alternatively, <a href="http://docs.python.org/3.0/library/xml.dom.minidom.html" rel="nofollow">xml.dom.minidom</a> will parse your HTML if,</p>
<ul>
<li>...it is wellformed</li>
<li>...you embed it in a single root element.</li>
</ul>
<p>E.g.,</p>
<pre><code>>>> import xml.dom.minidom
>>> htmlT... | 2 | 2009-06-09T22:38:25Z | [
"python",
"html",
"regex"
] |
Python regular expression for multiple tags | 972,749 | <p>I would like to know how to retrieve all results from each <code><p></code> tag.</p>
<pre><code>import re
htmlText = '<p data="5" size="4">item1</p><p size="4">item2</p><p size="4">item3</p>'
print re.match('<p[^>]*size="[0-9]">(.*?)</p>', htmlText).groups()
... | 2 | 2009-06-09T22:09:22Z | 972,928 | <p>Beautiful soup is definitely the way to go with a problem like this. The code is cleaner and easier to read. Once you have it installed, getting all the tags looks something like this.</p>
<pre><code>from BeautifulSoup import BeautifulSoup
import urllib2
def getTags(tag):
f = urllib2.urlopen("http://cnn.com")
... | 5 | 2009-06-09T23:00:36Z | [
"python",
"html",
"regex"
] |
Python regular expression for multiple tags | 972,749 | <p>I would like to know how to retrieve all results from each <code><p></code> tag.</p>
<pre><code>import re
htmlText = '<p data="5" size="4">item1</p><p size="4">item2</p><p size="4">item3</p>'
print re.match('<p[^>]*size="[0-9]">(.*?)</p>', htmlText).groups()
... | 2 | 2009-06-09T22:09:22Z | 973,538 | <p>The regex answer is extremely fragile. Here's proof (and a working BeautifulSoup example).</p>
<pre><code>from BeautifulSoup import BeautifulSoup
# Here's your HTML
html = '<p data="5" size="4">item1</p><p size="4">item2</p><p size="4">item3</p>'
# Here's some simple HTML that ... | 4 | 2009-06-10T03:19:07Z | [
"python",
"html",
"regex"
] |
Google App Engine and Amazon S3 File Uploads | 972,895 | <p>I know this has been asked before but there is really not a clear answer. My problem is I built a file upload script for GAE and only found out after, that you can only store files up to aprox. 1MB in the data store. I can stop you right here if you can tell me that if I enable billing the 1MB limit is history but I... | 6 | 2009-06-09T22:52:13Z | 972,915 | <p>Google App Engine and EC2 are competitors. They do the same thing, although GAE provides an environment for your app to run in with strict language restrictions, while EC2 provides you a virtual machine ( think VMWare ) on which to host your application.</p>
<p>S3 on the other hand is a raw storage api. You can u... | 3 | 2009-06-09T22:57:34Z | [
"python",
"google-app-engine",
"amazon-s3",
"amazon-ec2"
] |
Google App Engine and Amazon S3 File Uploads | 972,895 | <p>I know this has been asked before but there is really not a clear answer. My problem is I built a file upload script for GAE and only found out after, that you can only store files up to aprox. 1MB in the data store. I can stop you right here if you can tell me that if I enable billing the 1MB limit is history but I... | 6 | 2009-06-09T22:52:13Z | 972,998 | <p>Some Google App Engine + S3 links:</p>
<p><a href="http://stackoverflow.com/questions/842426/google-app-engine-large-file-upload">Previous related post... 10mb limit</a>.</p>
<p><a href="http://blog.localkinegrinds.com/2009/04/02/lessons-learned-google-app-engine-app-engine-patch-django-boto/" rel="nofollow">This ... | 0 | 2009-06-09T23:23:15Z | [
"python",
"google-app-engine",
"amazon-s3",
"amazon-ec2"
] |
Google App Engine and Amazon S3 File Uploads | 972,895 | <p>I know this has been asked before but there is really not a clear answer. My problem is I built a file upload script for GAE and only found out after, that you can only store files up to aprox. 1MB in the data store. I can stop you right here if you can tell me that if I enable billing the 1MB limit is history but I... | 6 | 2009-06-09T22:52:13Z | 973,082 | <p>From the <a href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/UsingHTTPPOST.html">Amazon S3 documentation</a>:</p>
<ol>
<li><p>The user opens a web browser and accesses your web page.</p></li>
<li><p>Your web page contains an HTTP form that contains all the information necessary for the user to upload con... | 13 | 2009-06-09T23:57:15Z | [
"python",
"google-app-engine",
"amazon-s3",
"amazon-ec2"
] |
Google App Engine and Amazon S3 File Uploads | 972,895 | <p>I know this has been asked before but there is really not a clear answer. My problem is I built a file upload script for GAE and only found out after, that you can only store files up to aprox. 1MB in the data store. I can stop you right here if you can tell me that if I enable billing the 1MB limit is history but I... | 6 | 2009-06-09T22:52:13Z | 2,004,598 | <p>For future reference, Google added support for large file upload (up to 50 MB): The new feature was released as part of the <a href="http://code.google.com/appengine/docs/python/blobstore/overview.html" rel="nofollow">Blobstore API</a> and is discussed <a href="http://code.google.com/appengine/docs/python/blobstore... | 2 | 2010-01-05T06:51:35Z | [
"python",
"google-app-engine",
"amazon-s3",
"amazon-ec2"
] |
Google App Engine and Amazon S3 File Uploads | 972,895 | <p>I know this has been asked before but there is really not a clear answer. My problem is I built a file upload script for GAE and only found out after, that you can only store files up to aprox. 1MB in the data store. I can stop you right here if you can tell me that if I enable billing the 1MB limit is history but I... | 6 | 2009-06-09T22:52:13Z | 3,515,499 | <p>Thomas L Holaday's answer is the correct answer, I suppose. Anyway, just in case, here's a link to Amazon Web Services SDK for App Engine (Java), which you can use e.g. to upload files from App Engine to Amazon S3. (<strong>Edit:</strong> Oh, just noticed -- <em>excepting S3</em>)
<a href="http://apetresc.wordpress... | 1 | 2010-08-18T18:41:14Z | [
"python",
"google-app-engine",
"amazon-s3",
"amazon-ec2"
] |
Pixmap transparency in PyGTK | 973,073 | <p>How can I create PyGTK pixmaps with one pixel value set to transparent? I know it has <em>something</em> to do with creating a pixmap of depth 1 and setting it as a mask, but all I find is that it either does nothing or totally erases my pixmap when drawn. At the moment, I make a pixmap with</p>
<pre><code>r = self... | 1 | 2009-06-09T23:53:30Z | 973,095 | <p>It looks like you want to use a Pixbuf and not a Pixmap. The Pixbuf includes an alpha setting, which will give you transparency, whereas the Pixmap does not.</p>
| 1 | 2009-06-10T00:03:54Z | [
"python",
"transparency",
"pygtk"
] |
Pixmap transparency in PyGTK | 973,073 | <p>How can I create PyGTK pixmaps with one pixel value set to transparent? I know it has <em>something</em> to do with creating a pixmap of depth 1 and setting it as a mask, but all I find is that it either does nothing or totally erases my pixmap when drawn. At the moment, I make a pixmap with</p>
<pre><code>r = self... | 1 | 2009-06-09T23:53:30Z | 996,923 | <p>I don't think you can do what you want with a <code>Pixmap</code> or <code>Pixbuf</code>, but here are two strategies for implementing scribbling on top of an existing <code>Widget</code>. The most obvious one is just to catch the draw event and draw straight onto the <code>Widget</code>'s <code>Drawable</code>, wi... | 2 | 2009-06-15T16:00:01Z | [
"python",
"transparency",
"pygtk"
] |
How can I make lxml's parser preserve whitespace outside of the root element? | 973,079 | <p>I am using lxml to manipulate some existing XML documents, and I want to introduce as little diff noise as possible. Unfortunately by default <a href="http://codespeak.net/lxml/api/lxml.etree.XMLParser-class.html" rel="nofollow">lxml.etree.XMLParser</a> doesn't preserve whitespace before or after the root element of... | 1 | 2009-06-09T23:56:01Z | 973,147 | <p>Capture the whitespace with a regex and add it back to the string when you're done.</p>
| 1 | 2009-06-10T00:21:15Z | [
"python",
"xml",
"whitespace",
"lxml"
] |
How can I make lxml's parser preserve whitespace outside of the root element? | 973,079 | <p>I am using lxml to manipulate some existing XML documents, and I want to introduce as little diff noise as possible. Unfortunately by default <a href="http://codespeak.net/lxml/api/lxml.etree.XMLParser-class.html" rel="nofollow">lxml.etree.XMLParser</a> doesn't preserve whitespace before or after the root element of... | 1 | 2009-06-09T23:56:01Z | 977,955 | <p>I don't know of any XML library that will do it for you. But using a regex sounds like a decent idea if you really need to do this.</p>
<pre><code>>>> xml = '\n <etaoin>shrdlu</etaoin>\n'
>>> head, tail = re.findall(r"^\s*|\s*$", xml)[:2]
>>> root = etree.fromstring(xml)
&g... | 1 | 2009-06-10T20:25:51Z | [
"python",
"xml",
"whitespace",
"lxml"
] |
What is the clojure equivalent of the Python idiom "if __name__ == '__main__'"? | 973,106 | <p>I'm dabbling in clojure and am having a little trouble trying to determine the clojure (and / or Lisp) equivalent of this common python idiom.</p>
<p>The idiom is that at the bottom of a python module there is often a bit of test code, and then a statement which runs the code, for example:</p>
<pre><code># mymodul... | 24 | 2009-06-10T00:07:58Z | 973,432 | <p>I'm very new to Clojure but I think <a href="http://groups.google.com/group/clojure/browse_thread/thread/d3c2c328787c328f/8c8c526fee2d6deb?lnk=gst&q=clojure+python+__name__#8c8c526fee2d6deb" rel="nofollow">this discussion</a> on the Clojure groups may be a solution and/or workaround, specifically the post by Stu... | 1 | 2009-06-10T02:28:39Z | [
"python",
"lisp",
"clojure",
"idioms"
] |
What is the clojure equivalent of the Python idiom "if __name__ == '__main__'"? | 973,106 | <p>I'm dabbling in clojure and am having a little trouble trying to determine the clojure (and / or Lisp) equivalent of this common python idiom.</p>
<p>The idiom is that at the bottom of a python module there is often a bit of test code, and then a statement which runs the code, for example:</p>
<pre><code># mymodul... | 24 | 2009-06-10T00:07:58Z | 973,662 | <p>You might want to have a look at the <a href="http://code.google.com/p/clojure-contrib/source/browse/trunk/src/clojure/contrib/test%5Fis.clj" rel="nofollow">test-is</a> library from clojure-contrib. It's not the same idiom, but it should support a pretty similar workflow.</p>
| 0 | 2009-06-10T04:17:37Z | [
"python",
"lisp",
"clojure",
"idioms"
] |
What is the clojure equivalent of the Python idiom "if __name__ == '__main__'"? | 973,106 | <p>I'm dabbling in clojure and am having a little trouble trying to determine the clojure (and / or Lisp) equivalent of this common python idiom.</p>
<p>The idiom is that at the bottom of a python module there is often a bit of test code, and then a statement which runs the code, for example:</p>
<pre><code># mymodul... | 24 | 2009-06-10T00:07:58Z | 973,694 | <p>In Common Lisp you can use conditional reading with <a href="http://www.lispworks.com/documentation/HyperSpec/Body/24%5Fab.htm" rel="nofollow">features</a>.</p>
<pre><code>#+testing (run-test 'is-answer-equal-42)
</code></pre>
<p>Above will only be read and thus execute during load if the list of features bound to... | 1 | 2009-06-10T04:33:24Z | [
"python",
"lisp",
"clojure",
"idioms"
] |
What is the clojure equivalent of the Python idiom "if __name__ == '__main__'"? | 973,106 | <p>I'm dabbling in clojure and am having a little trouble trying to determine the clojure (and / or Lisp) equivalent of this common python idiom.</p>
<p>The idiom is that at the bottom of a python module there is often a bit of test code, and then a statement which runs the code, for example:</p>
<pre><code># mymodul... | 24 | 2009-06-10T00:07:58Z | 973,935 | <p>Common Lisp and Clojure (as well as other lisps) provide interactive environment with REPL, and you do not need tricks like «<code>if __name__ == '__main__'</code>». There are REPL-like environments for python: the python from command-line, ipython, python mode for Emacs, etc.</p>
<p>You should just create the li... | 0 | 2009-06-10T06:10:12Z | [
"python",
"lisp",
"clojure",
"idioms"
] |
What is the clojure equivalent of the Python idiom "if __name__ == '__main__'"? | 973,106 | <p>I'm dabbling in clojure and am having a little trouble trying to determine the clojure (and / or Lisp) equivalent of this common python idiom.</p>
<p>The idiom is that at the bottom of a python module there is often a bit of test code, and then a statement which runs the code, for example:</p>
<pre><code># mymodul... | 24 | 2009-06-10T00:07:58Z | 974,286 | <p>It's not idiomatic to run Clojure scripts over and over from the command line. The REPL is a better command line. Clojure being a Lisp, it's common to fire up Clojure and leave the same instance running forever, and interact with it rather than restart it. You can change functions in the running instance one at a... | 27 | 2009-06-10T08:18:39Z | [
"python",
"lisp",
"clojure",
"idioms"
] |
What is the clojure equivalent of the Python idiom "if __name__ == '__main__'"? | 973,106 | <p>I'm dabbling in clojure and am having a little trouble trying to determine the clojure (and / or Lisp) equivalent of this common python idiom.</p>
<p>The idiom is that at the bottom of a python module there is often a bit of test code, and then a statement which runs the code, for example:</p>
<pre><code># mymodul... | 24 | 2009-06-10T00:07:58Z | 1,010,736 | <p>If you are talking about having an "entry point" you can certainly do that:</p>
<pre><code>(ns foo)
(defn foo [n]
(inc n))
(defn main []
(println "working")
(println "Foo has ran:" (foo 1)))
(main)
</code></pre>
<p>what will happen now is that any time this code is (load-file "foo.clj")'d or (use 'foo) or... | -3 | 2009-06-18T04:11:40Z | [
"python",
"lisp",
"clojure",
"idioms"
] |
What is the clojure equivalent of the Python idiom "if __name__ == '__main__'"? | 973,106 | <p>I'm dabbling in clojure and am having a little trouble trying to determine the clojure (and / or Lisp) equivalent of this common python idiom.</p>
<p>The idiom is that at the bottom of a python module there is often a bit of test code, and then a statement which runs the code, for example:</p>
<pre><code># mymodul... | 24 | 2009-06-10T00:07:58Z | 6,061,668 | <p>There's also a list of different possibilities at <a href="http://rosettacode.org/wiki/Scripted_Main#Clojure" rel="nofollow">http://rosettacode.org/wiki/Scripted_Main#Clojure</a>. (If you find a new one - please add it. ;-))</p>
| 1 | 2011-05-19T16:17:58Z | [
"python",
"lisp",
"clojure",
"idioms"
] |
What is the clojure equivalent of the Python idiom "if __name__ == '__main__'"? | 973,106 | <p>I'm dabbling in clojure and am having a little trouble trying to determine the clojure (and / or Lisp) equivalent of this common python idiom.</p>
<p>The idiom is that at the bottom of a python module there is often a bit of test code, and then a statement which runs the code, for example:</p>
<pre><code># mymodul... | 24 | 2009-06-10T00:07:58Z | 35,319,034 | <p><a href="https://github.com/boot-clj/boot" rel="nofollow">Boot</a> is a build tooling (an alternative to leiningen), that <a href="https://github.com/boot-clj/boot/wiki/Scripts" rel="nofollow">supports scripts</a>. So you could have a boot script beginning with <code>#!/usr/bin/env boot</code> that can have a <code>... | 0 | 2016-02-10T15:19:51Z | [
"python",
"lisp",
"clojure",
"idioms"
] |
Running a set of Python scripts in a list | 973,231 | <p>I am working on a Python project that includes a lot of simple example scripts to help new users get used to the system. As well as the source code for each example, I include the output I get on my test machine so users know what to expect when all goes well.</p>
<p>It occured to me that I could use this as a cru... | 2 | 2009-06-10T00:56:03Z | 973,244 | <p>You want to use the <a href="http://docs.python.org/library/subprocess.html#module-subprocess" rel="nofollow">subprocess module</a>.</p>
| 4 | 2009-06-10T01:00:54Z | [
"python"
] |
Running a set of Python scripts in a list | 973,231 | <p>I am working on a Python project that includes a lot of simple example scripts to help new users get used to the system. As well as the source code for each example, I include the output I get on my test machine so users know what to expect when all goes well.</p>
<p>It occured to me that I could use this as a cru... | 2 | 2009-06-10T00:56:03Z | 973,256 | <p>You could leverage <a href="http://docs.python.org/library/doctest.html" rel="nofollow">doctest</a> to help you get this done. Write a method that executes each script, and in the docstring for each method you paste the expected output:</p>
<pre><code>def run_example1():
"""
This is example number 1. Runnin... | 8 | 2009-06-10T01:04:41Z | [
"python"
] |
Running a set of Python scripts in a list | 973,231 | <p>I am working on a Python project that includes a lot of simple example scripts to help new users get used to the system. As well as the source code for each example, I include the output I get on my test machine so users know what to expect when all goes well.</p>
<p>It occured to me that I could use this as a cru... | 2 | 2009-06-10T00:56:03Z | 973,321 | <p>If they are similarly structured (All are executed with a run function for example), you can import the them as python scripts, and call thier run function.</p>
<pre><code>import sys
import os
import imp
pythonfiles = [filename for filename in os.listdir(source_directory) if filename[-3:]=='.py']
for py_file in py... | 3 | 2009-06-10T01:29:56Z | [
"python"
] |
Getting a list of all subdirectories in the current directory | 973,473 | <p>Is there a way to return a list of all the subdirectories in the current directory in Python?</p>
<p>I know you can do this with files, but I need to get the list of directories instead.</p>
| 179 | 2009-06-10T02:48:21Z | 973,488 | <p>Do you mean immediate subdirectories, or every directory right down the tree? </p>
<p>Either way, you could use <a href="http://docs.python.org/library/os.html#os.walk"><code>os.walk</code></a> to do this:</p>
<pre><code>os.walk(directory)
</code></pre>
<p>will yield a tuple for each subdirectory. Ths first entry... | 218 | 2009-06-10T02:54:45Z | [
"python",
"directory",
"subdirectory"
] |
Getting a list of all subdirectories in the current directory | 973,473 | <p>Is there a way to return a list of all the subdirectories in the current directory in Python?</p>
<p>I know you can do this with files, but I need to get the list of directories instead.</p>
| 179 | 2009-06-10T02:48:21Z | 973,489 | <p>If you need a recursive solution that will find all the subdirectories in the subdirectories, use walk as proposed before.</p>
<p>If you only need the current directory's child directories, combine <code>os.listdir</code> with <code>os.path.isdir</code></p>
| 23 | 2009-06-10T02:56:09Z | [
"python",
"directory",
"subdirectory"
] |
Getting a list of all subdirectories in the current directory | 973,473 | <p>Is there a way to return a list of all the subdirectories in the current directory in Python?</p>
<p>I know you can do this with files, but I need to get the list of directories instead.</p>
| 179 | 2009-06-10T02:48:21Z | 973,492 | <pre><code>import os
d='.'
[os.path.join(d,o) for o in os.listdir(d) if os.path.isdir(os.path.join(d,o))]
</code></pre>
| 72 | 2009-06-10T02:57:07Z | [
"python",
"directory",
"subdirectory"
] |
Getting a list of all subdirectories in the current directory | 973,473 | <p>Is there a way to return a list of all the subdirectories in the current directory in Python?</p>
<p>I know you can do this with files, but I need to get the list of directories instead.</p>
| 179 | 2009-06-10T02:48:21Z | 16,488,785 | <p>Thanks for the tips, guys. I ran into an issue with softlinks (infinite recursion) being returned as dirs. Softlinks? We don't want no stinkin' soft links! So...</p>
<p>This rendered just the dirs, not softlinks:</p>
<pre><code>>>> import os
>>> inf = os.walk('.')
>>> [x[0] for x in inf]... | 3 | 2013-05-10T18:38:40Z | [
"python",
"directory",
"subdirectory"
] |
Getting a list of all subdirectories in the current directory | 973,473 | <p>Is there a way to return a list of all the subdirectories in the current directory in Python?</p>
<p>I know you can do this with files, but I need to get the list of directories instead.</p>
| 179 | 2009-06-10T02:48:21Z | 19,017,207 | <p>Implemented this using python-os-walk. (<a href="http://www.pythonforbeginners.com/code-snippets-source-code/python-os-walk/">http://www.pythonforbeginners.com/code-snippets-source-code/python-os-walk/</a>)</p>
<pre><code>import os
print "root prints out directories only from what you specified"
print "dirs prints ... | 10 | 2013-09-26T00:08:29Z | [
"python",
"directory",
"subdirectory"
] |
Getting a list of all subdirectories in the current directory | 973,473 | <p>Is there a way to return a list of all the subdirectories in the current directory in Python?</p>
<p>I know you can do this with files, but I need to get the list of directories instead.</p>
| 179 | 2009-06-10T02:48:21Z | 19,204,316 | <p>With full path and accounting for path being '.', '..', '\', '..\..\subfolder', etc</p>
<pre><code>import os, pprint
pprint.pprint([os.path.join(os.path.abspath(path), x[0]) for x in os.walk(os.path.abspath(path))])
</code></pre>
| 2 | 2013-10-06T01:00:57Z | [
"python",
"directory",
"subdirectory"
] |
Getting a list of all subdirectories in the current directory | 973,473 | <p>Is there a way to return a list of all the subdirectories in the current directory in Python?</p>
<p>I know you can do this with files, but I need to get the list of directories instead.</p>
| 179 | 2009-06-10T02:48:21Z | 26,237,100 | <p>You can get the list of subdirectories in python 2.7 using os.listdir(path)</p>
<pre><code> import os, sys
subdirectories = os.listdir(path)
</code></pre>
| 4 | 2014-10-07T13:23:40Z | [
"python",
"directory",
"subdirectory"
] |
Getting a list of all subdirectories in the current directory | 973,473 | <p>Is there a way to return a list of all the subdirectories in the current directory in Python?</p>
<p>I know you can do this with files, but I need to get the list of directories instead.</p>
| 179 | 2009-06-10T02:48:21Z | 26,846,646 | <p>Since I stumbled upon this problem using Python 3.4 and Windows UNC paths, here's a variant for this environment:</p>
<pre><code>from pathlib import WindowsPath
def SubDirPath (d):
return [f for f in d.iterdir() if f.is_dir()]
subdirs = SubDirPath(WindowsPath(r'\\file01.acme.local\home$'))
print(subdirs)
</co... | 4 | 2014-11-10T15:02:47Z | [
"python",
"directory",
"subdirectory"
] |
Getting a list of all subdirectories in the current directory | 973,473 | <p>Is there a way to return a list of all the subdirectories in the current directory in Python?</p>
<p>I know you can do this with files, but I need to get the list of directories instead.</p>
| 179 | 2009-06-10T02:48:21Z | 32,505,092 | <p>I prefer using filter (<a href="https://docs.python.org/2/library/functions.html#filter">https://docs.python.org/2/library/functions.html#filter</a>), but this is just a matter of taste.</p>
<pre><code>d='.'
filter(lambda x: os.path.isdir(os.path.join(d, x)), os.listdir(d))
</code></pre>
| 12 | 2015-09-10T14:46:58Z | [
"python",
"directory",
"subdirectory"
] |
Getting a list of all subdirectories in the current directory | 973,473 | <p>Is there a way to return a list of all the subdirectories in the current directory in Python?</p>
<p>I know you can do this with files, but I need to get the list of directories instead.</p>
| 179 | 2009-06-10T02:48:21Z | 34,600,048 | <p>Building upon Eli Bendersky's solution, use the following example:</p>
<pre><code>import os
test_directory = <your_directory>
for child in os.listdir(test_directory):
test_path = os.path.join(test_directory, child)
if os.path.isdir(test_path):
print test_path
# Do stuff to the director... | 3 | 2016-01-04T21:19:33Z | [
"python",
"directory",
"subdirectory"
] |
Getting a list of all subdirectories in the current directory | 973,473 | <p>Is there a way to return a list of all the subdirectories in the current directory in Python?</p>
<p>I know you can do this with files, but I need to get the list of directories instead.</p>
| 179 | 2009-06-10T02:48:21Z | 35,261,270 | <p>use a filter function <code>os.path.isdir</code> over <code>os.listdir()</code>
something like this <code>filter(os.path.isdir,[os.path.join(os.path.abspath('PATH'),p) for p in os.listdir('PATH/')])</code></p>
| 0 | 2016-02-08T01:30:14Z | [
"python",
"directory",
"subdirectory"
] |
Getting a list of all subdirectories in the current directory | 973,473 | <p>Is there a way to return a list of all the subdirectories in the current directory in Python?</p>
<p>I know you can do this with files, but I need to get the list of directories instead.</p>
| 179 | 2009-06-10T02:48:21Z | 36,426,997 | <p>You could just use <code>glob.glob</code></p>
<pre><code>from glob import glob
glob("/path/to/directory/*/")
</code></pre>
<p>Don't forget the trailing <code>/</code> after the <code>*</code>.</p>
| 11 | 2016-04-05T12:55:54Z | [
"python",
"directory",
"subdirectory"
] |
Getting a list of all subdirectories in the current directory | 973,473 | <p>Is there a way to return a list of all the subdirectories in the current directory in Python?</p>
<p>I know you can do this with files, but I need to get the list of directories instead.</p>
| 179 | 2009-06-10T02:48:21Z | 38,245,063 | <p>Although this question is answered a long time ago. I want to recommend to use the <a href="https://docs.python.org/3.4/library/pathlib.html#pathlib.Path" rel="nofollow"><code>pathlib</code></a> module since this is a robust way to work on Windows and Unix OS.</p>
<p>So to get all paths in a specific directory incl... | 1 | 2016-07-07T12:06:46Z | [
"python",
"directory",
"subdirectory"
] |
Getting a list of all subdirectories in the current directory | 973,473 | <p>Is there a way to return a list of all the subdirectories in the current directory in Python?</p>
<p>I know you can do this with files, but I need to get the list of directories instead.</p>
| 179 | 2009-06-10T02:48:21Z | 39,222,660 | <h1>Listing Out only directories</h1>
<pre><code>print "\nWe are listing out only the directories in current directory -"
directories_in_curdir = filter(os.path.isdir, os.listdir(os.curdir))
print directories_in_curdir
</code></pre>
<h1>Listing Out only files in current directory</h1>
<pre><code>files = filter(os.... | 0 | 2016-08-30T08:40:44Z | [
"python",
"directory",
"subdirectory"
] |
Dynamic Table Creation and ORM mapping in SqlAlchemy | 973,481 | <p>I'm fairly new to using relational databases, so I prefer using a good ORM to simplify things. I spent time evaluating different Python ORMs and I think SQLAlchemy is what I need. However, I've come to a mental dead end.</p>
<p>I need to create a new table to go along with each instance of a player I create in my... | 7 | 2009-06-10T02:51:11Z | 973,564 | <p>May be look at sql soup , which is layer over sqlalchemy
<a href="http://www.sqlalchemy.org/trac/wiki/SqlSoup" rel="nofollow">http://www.sqlalchemy.org/trac/wiki/SqlSoup</a></p>
<p>or elixir (again a wrapper over sqlalchemy)
<a href="http://elixir.ematia.de/trac/wiki" rel="nofollow">http://elixir.ematia.de/trac/wik... | 3 | 2009-06-10T03:29:30Z | [
"python",
"database",
"sqlalchemy"
] |
Dynamic Table Creation and ORM mapping in SqlAlchemy | 973,481 | <p>I'm fairly new to using relational databases, so I prefer using a good ORM to simplify things. I spent time evaluating different Python ORMs and I think SQLAlchemy is what I need. However, I've come to a mental dead end.</p>
<p>I need to create a new table to go along with each instance of a player I create in my... | 7 | 2009-06-10T02:51:11Z | 973,567 | <p>We are absolutely spoiled by SqlAlchemy. <br />
What follows below is taken directly from the <a href="http://www.sqlalchemy.org/docs/05/ormtutorial.html">tutorial</a>, <br />
and is really easy to setup and get working.</p>
<p>And because it is done so often, <br />
Mike Bayer has made this even easier <br />
wit... | 17 | 2009-06-10T03:30:15Z | [
"python",
"database",
"sqlalchemy"
] |
Dynamic Table Creation and ORM mapping in SqlAlchemy | 973,481 | <p>I'm fairly new to using relational databases, so I prefer using a good ORM to simplify things. I spent time evaluating different Python ORMs and I think SQLAlchemy is what I need. However, I've come to a mental dead end.</p>
<p>I need to create a new table to go along with each instance of a player I create in my... | 7 | 2009-06-10T02:51:11Z | 1,052,559 | <p>you can use declarative method for dynamically creating tables in database</p>
<pre><code>from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey
Base = declarative_base()
class Language(Base):
__tablename__ = 'languages'
id = ... | 1 | 2009-06-27T10:15:08Z | [
"python",
"database",
"sqlalchemy"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.