title stringlengths 10 172 | question_id int64 469 40.1M | question_body stringlengths 22 48.2k | question_score int64 -44 5.52k | question_date stringlengths 20 20 | answer_id int64 497 40.1M | answer_body stringlengths 18 33.9k | answer_score int64 -38 8.38k | answer_date stringlengths 20 20 | tags list |
|---|---|---|---|---|---|---|---|---|---|
How to create PDF files in Python | 2,252,726 | <p>I'm working on a project which takes some images from user and then creates a PDF file which contains all of these images.</p>
<p>Is there any way or any tool to do this in Python? E.g. to create a PDF file (or eps, ps) from image1 + image 2 + image 3 -> PDF file?</p>
| 104 | 2010-02-12T15:12:44Z | 2,253,246 | <p>It depends on what format your image files are in, but for a project here at work I used the tiff2pdf tool in LibTIFF from <a href="http://www.remotesensing.org/libtiff/" rel="nofollow">RemoteSensing.org</a>.
Basically just used subprocess to call tiff2pdf.exe with the appropriate argument to read the kind of tiff I... | 1 | 2010-02-12T16:19:51Z | [
"python",
"pdf"
] |
How to create PDF files in Python | 2,252,726 | <p>I'm working on a project which takes some images from user and then creates a PDF file which contains all of these images.</p>
<p>Is there any way or any tool to do this in Python? E.g. to create a PDF file (or eps, ps) from image1 + image 2 + image 3 -> PDF file?</p>
| 104 | 2010-02-12T15:12:44Z | 2,253,409 | <p>I have done this quite a bit in PyQt and it works very well. Qt has extensive support for images, fonts, styles, etc and all of those can be written out to pdf documents.</p>
| 6 | 2010-02-12T16:39:51Z | [
"python",
"pdf"
] |
How to create PDF files in Python | 2,252,726 | <p>I'm working on a project which takes some images from user and then creates a PDF file which contains all of these images.</p>
<p>Is there any way or any tool to do this in Python? E.g. to create a PDF file (or eps, ps) from image1 + image 2 + image 3 -> PDF file?</p>
| 104 | 2010-02-12T15:12:44Z | 15,747,362 | <p>I believe that matplotlib has the ability to serialize graphics, text and other objects to a pdf document.</p>
| 2 | 2013-04-01T16:35:39Z | [
"python",
"pdf"
] |
How to create PDF files in Python | 2,252,726 | <p>I'm working on a project which takes some images from user and then creates a PDF file which contains all of these images.</p>
<p>Is there any way or any tool to do this in Python? E.g. to create a PDF file (or eps, ps) from image1 + image 2 + image 3 -> PDF file?</p>
| 104 | 2010-02-12T15:12:44Z | 16,632,518 | <p>Here is my experience after following the hints on this page.</p>
<ol>
<li><p>pyPDF can't embed images into files. It can only split and merge. (Source: Ctrl+F through its <a href="http://pybrary.net/pyPdf/pythondoc-pyPdf.pdf.html">documentation page</a>)
Which is great, but not if you have images that are not alre... | 61 | 2013-05-19T07:56:25Z | [
"python",
"pdf"
] |
How to create PDF files in Python | 2,252,726 | <p>I'm working on a project which takes some images from user and then creates a PDF file which contains all of these images.</p>
<p>Is there any way or any tool to do this in Python? E.g. to create a PDF file (or eps, ps) from image1 + image 2 + image 3 -> PDF file?</p>
| 104 | 2010-02-12T15:12:44Z | 22,286,441 | <p>fpdf works well for me. Much simpler than ReportLab and really free. Works with UTF-8.</p>
| -6 | 2014-03-09T18:44:07Z | [
"python",
"pdf"
] |
How to create PDF files in Python | 2,252,726 | <p>I'm working on a project which takes some images from user and then creates a PDF file which contains all of these images.</p>
<p>Is there any way or any tool to do this in Python? E.g. to create a PDF file (or eps, ps) from image1 + image 2 + image 3 -> PDF file?</p>
| 104 | 2010-02-12T15:12:44Z | 31,931,852 | <p>I use <a href="https://github.com/rst2pdf/rst2pdf" rel="nofollow">rst2pdf</a> to create a pdf file, since I am more familiar with RST than with HTML. It supports embedding almost any kind of raster or vector images.</p>
<p>It requires <a href="https://www.reportlab.com/" rel="nofollow">reportlab</a>, but I found re... | 2 | 2015-08-11T01:38:53Z | [
"python",
"pdf"
] |
How to create PDF files in Python | 2,252,726 | <p>I'm working on a project which takes some images from user and then creates a PDF file which contains all of these images.</p>
<p>Is there any way or any tool to do this in Python? E.g. to create a PDF file (or eps, ps) from image1 + image 2 + image 3 -> PDF file?</p>
| 104 | 2010-02-12T15:12:44Z | 33,481,270 | <p>I suggest pdfkit @ <a href="https://github.com/JazzCore/python-pdfkit">https://github.com/JazzCore/python-pdfkit</a></p>
<p>It creates pdf from html files. I chose it to create pdf in 2 steps from my Python Pyramid stack:</p>
<ol>
<li>rendering server-side with mako templates with the style and markup you want for... | 3 | 2015-11-02T15:33:59Z | [
"python",
"pdf"
] |
How to create PDF files in Python | 2,252,726 | <p>I'm working on a project which takes some images from user and then creates a PDF file which contains all of these images.</p>
<p>Is there any way or any tool to do this in Python? E.g. to create a PDF file (or eps, ps) from image1 + image 2 + image 3 -> PDF file?</p>
| 104 | 2010-02-12T15:12:44Z | 34,220,390 | <p>fpdf is python (too). And often used. See PyPI / pip search. But maybe it was renamed from pyfpdf to fpdf. From features:
PNG, GIF and JPG support (including transparency and alpha channel)</p>
| 1 | 2015-12-11T09:44:08Z | [
"python",
"pdf"
] |
How to create PDF files in Python | 2,252,726 | <p>I'm working on a project which takes some images from user and then creates a PDF file which contains all of these images.</p>
<p>Is there any way or any tool to do this in Python? E.g. to create a PDF file (or eps, ps) from image1 + image 2 + image 3 -> PDF file?</p>
| 104 | 2010-02-12T15:12:44Z | 35,798,037 | <p>Here is a solution that works with only the standard packages. <code>matplotlib</code> has a PDF backend to save figures to PDF. You can create a figures with subplots, where each subplot is one of your images. You have full freedom to mess with the figure: Adding titles, play with position, etc. Once your figure is... | 1 | 2016-03-04T14:03:56Z | [
"python",
"pdf"
] |
How to create PDF files in Python | 2,252,726 | <p>I'm working on a project which takes some images from user and then creates a PDF file which contains all of these images.</p>
<p>Is there any way or any tool to do this in Python? E.g. to create a PDF file (or eps, ps) from image1 + image 2 + image 3 -> PDF file?</p>
| 104 | 2010-02-12T15:12:44Z | 39,762,192 | <p>You can actually try xhtml2pdf <a href="http://flask.pocoo.org/snippets/68/" rel="nofollow">http://flask.pocoo.org/snippets/68/</a></p>
| 0 | 2016-09-29T05:38:22Z | [
"python",
"pdf"
] |
How to run command line python script in django view? | 2,252,741 | <p>I have a .py file that a php file runs like this: </p>
<pre><code>$link = exec(dirname(__FILE__) . /xxx.py ' .excapeshellarg($url) . '2>&1', $output, $exit_code);
</code></pre>
<p>I want to run the <code>xxx.py</code> in my django view and asign the output to a variable. The xxx.py file has a def main(url) ... | 3 | 2010-02-12T15:14:28Z | 2,252,798 | <blockquote>
<p>Is there a way I can edit the xxx.py file and call the def main function from my view?</p>
</blockquote>
<p>Yes. Modify the <code>main</code> function so that it returns its results as a string rather than printing it to <code>stdout</code>, which is what it appears to be doing at the moment.</p>
<... | 2 | 2010-02-12T15:25:17Z | [
"python",
"django",
"command-line",
"scripting"
] |
How to create graphs in Delphi application | 2,252,779 | <p>I need to create graphs on the fly about specific process, with some informative texts and colors.</p>
<p>In the Unix world there's Graphviz including 'dot' for layout generation, is there something similar which could be used with Delphi?</p>
<p>I'm using Delphi 2007.</p>
<p>Also Python alternative could be cons... | 3 | 2010-02-12T15:21:26Z | 2,252,900 | <p>@Harriv, You can try <a href="http://wingraphviz.sourceforge.net/wingraphviz/" rel="nofollow">WinGraphviz</a> wich is a COM Wrapper for <a href="http://www.graphviz.org/" rel="nofollow">Graphviz</a>.</p>
<p>check this <a href="http://kylecordes.com/2003/11/24/graphviz-delphi/" rel="nofollow">link</a> for more info.... | 3 | 2010-02-12T15:36:08Z | [
"python",
"delphi",
"graph"
] |
How to create graphs in Delphi application | 2,252,779 | <p>I need to create graphs on the fly about specific process, with some informative texts and colors.</p>
<p>In the Unix world there's Graphviz including 'dot' for layout generation, is there something similar which could be used with Delphi?</p>
<p>I'm using Delphi 2007.</p>
<p>Also Python alternative could be cons... | 3 | 2010-02-12T15:21:26Z | 2,253,128 | <p>You can use SimpleGraph from <a href="http://www.delphiarea.com/products/delphi-components/simplegraph/" rel="nofollow">DelphiArea</a>.<br>
A have test and use it and it's a great component. Freeware with sources. </p>
<p><img src="http://www.delphiarea.com/wp-content/uploads/simplegraph1.gif" alt="alt text"></p>
... | 6 | 2010-02-12T16:05:32Z | [
"python",
"delphi",
"graph"
] |
How to create graphs in Delphi application | 2,252,779 | <p>I need to create graphs on the fly about specific process, with some informative texts and colors.</p>
<p>In the Unix world there's Graphviz including 'dot' for layout generation, is there something similar which could be used with Delphi?</p>
<p>I'm using Delphi 2007.</p>
<p>Also Python alternative could be cons... | 3 | 2010-02-12T15:21:26Z | 2,253,385 | <p>TMS also have a <a href="http://www.tmssoftware.com/site/diagram.asp" rel="nofollow">diagram studio</a> and a <a href="http://www.tmssoftware.com/site/workflow.asp" rel="nofollow">workflow studio</a></p>
<p>and a post about the ways to make <a href="http://www.tmssoftware.com/site/blog.asp?post=151" rel="nofollow">... | 1 | 2010-02-12T16:37:00Z | [
"python",
"delphi",
"graph"
] |
How to create graphs in Delphi application | 2,252,779 | <p>I need to create graphs on the fly about specific process, with some informative texts and colors.</p>
<p>In the Unix world there's Graphviz including 'dot' for layout generation, is there something similar which could be used with Delphi?</p>
<p>I'm using Delphi 2007.</p>
<p>Also Python alternative could be cons... | 3 | 2010-02-12T15:21:26Z | 2,254,357 | <p>Steema Software has a Delphi VCL TeeChart product that you may find interesting depending on your needs.</p>
<p><a href="http://www.steema.com/teechart/vcl" rel="nofollow">Steema Software TeeChart VCL</a></p>
<p>I have experimented with the trial version of this. I was able to create some very nice looking graphs.... | 1 | 2010-02-12T19:01:01Z | [
"python",
"delphi",
"graph"
] |
In python, what is more efficient? Modifying lists or strings? | 2,253,234 | <p>Regardless of ease of use, which is more computationally efficient? Constantly slicing lists and appending to them? Or taking substrings and doing the same?</p>
<p>As an example, let's say I have two binary strings "11011" and "01001". If I represent these as lists, I'll be choosing a random "slice" point. Let'... | 1 | 2010-02-12T16:18:32Z | 2,253,291 | <p>In general, modifying lists is more efficient than modifying strings, because strings are immutable.</p>
| 4 | 2010-02-12T16:25:19Z | [
"python",
"list",
"string"
] |
In python, what is more efficient? Modifying lists or strings? | 2,253,234 | <p>Regardless of ease of use, which is more computationally efficient? Constantly slicing lists and appending to them? Or taking substrings and doing the same?</p>
<p>As an example, let's say I have two binary strings "11011" and "01001". If I represent these as lists, I'll be choosing a random "slice" point. Let'... | 1 | 2010-02-12T16:18:32Z | 2,253,326 | <pre><code>>>> a = "11011"
>>> b = "01001"
>>> import timeit
>>> def strslice():
return a[:3] + b[3:]
>>> def lstslice():
return list(a)[:3] + list(b)[3:]
>>> c = list(a)
>>> d = list(b)
>>> def lsts():
return c[:3] + d[3:]
>>&g... | 7 | 2010-02-12T16:29:01Z | [
"python",
"list",
"string"
] |
In python, what is more efficient? Modifying lists or strings? | 2,253,234 | <p>Regardless of ease of use, which is more computationally efficient? Constantly slicing lists and appending to them? Or taking substrings and doing the same?</p>
<p>As an example, let's say I have two binary strings "11011" and "01001". If I represent these as lists, I'll be choosing a random "slice" point. Let'... | 1 | 2010-02-12T16:18:32Z | 2,253,413 | <p><code>timeit</code> is a good tool for micro-benchmarking, but it needs to be used with the utmost care when the operations you want to compare may involve in-place alterations -- in this case, you need to include extra operations designed to make needed copies. Then, first time just the "extra" overhead:</p>
<pre... | 5 | 2010-02-12T16:40:23Z | [
"python",
"list",
"string"
] |
In python, what is more efficient? Modifying lists or strings? | 2,253,234 | <p>Regardless of ease of use, which is more computationally efficient? Constantly slicing lists and appending to them? Or taking substrings and doing the same?</p>
<p>As an example, let's say I have two binary strings "11011" and "01001". If I represent these as lists, I'll be choosing a random "slice" point. Let'... | 1 | 2010-02-12T16:18:32Z | 2,254,173 | <p>It really depends on actual use cases, and as others have said, profile it, but in general, appending to lists will be better, because it can be done in place, whereas "appending to strings" actually creates a new string that concatenates the old strings. This can rapidly eat up memory. (Which is a different issue... | 0 | 2010-02-12T18:28:08Z | [
"python",
"list",
"string"
] |
Passing param to DB .execute for WHERE IN... INT list | 2,253,494 | <p>With Python's DB API spec you can pass an argument of parameters to the execute() method. Part of my statement is a WHERE IN clause and I've been using a tuple to populate the IN. For example:</p>
<pre><code>params = ((3, 2, 1), )
stmt = "SELECT * FROM table WHERE id IN %s"
db.execute(stmt, params)
</code></pre>
<... | 7 | 2010-02-12T16:50:20Z | 2,253,544 | <p>The error is coming from the comma after the 3. Just leave it off for the single values and you're set.</p>
<pre><code>params = ((3), ... )
stmt = "SELECT * FROM table WHERE id IN %s"
db.execute(stmt, params)
</code></pre>
| 1 | 2010-02-12T16:58:38Z | [
"python",
"postgresql"
] |
Passing param to DB .execute for WHERE IN... INT list | 2,253,494 | <p>With Python's DB API spec you can pass an argument of parameters to the execute() method. Part of my statement is a WHERE IN clause and I've been using a tuple to populate the IN. For example:</p>
<pre><code>params = ((3, 2, 1), )
stmt = "SELECT * FROM table WHERE id IN %s"
db.execute(stmt, params)
</code></pre>
<... | 7 | 2010-02-12T16:50:20Z | 2,253,879 | <p>Edit: Please, as @rspeer mentions in a comment, do take precautions to protect yourself from SQL injection attack.</p>
<p>Testing with <a href="http://pybrary.net/pg8000/index.html" rel="nofollow">pg8000</a> (a DB-API 2.0 compatible Pure-Python interface to the PostgreSQL database engine):</p>
<p>This is the recom... | 7 | 2010-02-12T17:48:51Z | [
"python",
"postgresql"
] |
Passing param to DB .execute for WHERE IN... INT list | 2,253,494 | <p>With Python's DB API spec you can pass an argument of parameters to the execute() method. Part of my statement is a WHERE IN clause and I've been using a tuple to populate the IN. For example:</p>
<pre><code>params = ((3, 2, 1), )
stmt = "SELECT * FROM table WHERE id IN %s"
db.execute(stmt, params)
</code></pre>
<... | 7 | 2010-02-12T16:50:20Z | 38,985,249 | <p>This may not be an answer to exactly the question you asked, but I think it may solve the problem you have.</p>
<p>Python's DB-API doesn't seem to give you a way to pass tuples as safely substituted parameters. The accepted answer from bernie is using the Python <code>%</code> operator for substitution, which is un... | 1 | 2016-08-16T22:07:36Z | [
"python",
"postgresql"
] |
Sharing scripts that require a virtualenv to be activated | 2,253,712 | <p>I have virtualenv and virtualenvwrapper installed on a shared Linux server with default settings (virtualenvs are in ~/.virtualenvs). I have several Python scripts that can only be run when the correct virtualenv is activated.</p>
<p>Now I want to <strong>share</strong> those scripts with other users on the server... | 24 | 2010-02-12T17:22:58Z | 2,253,847 | <p>I would vote for adding a shebang line in <code>scriptname</code> pointing to the correct virtualenv python. You just tell your users the full path to <code>scriptname</code> (or put it in their PATH), and they don't even need to know it is a Python script.</p>
<p>If your users are programmers, then I don't see why... | 6 | 2010-02-12T17:45:04Z | [
"python",
"virtualenv"
] |
Sharing scripts that require a virtualenv to be activated | 2,253,712 | <p>I have virtualenv and virtualenvwrapper installed on a shared Linux server with default settings (virtualenvs are in ~/.virtualenvs). I have several Python scripts that can only be run when the correct virtualenv is activated.</p>
<p>Now I want to <strong>share</strong> those scripts with other users on the server... | 24 | 2010-02-12T17:22:58Z | 2,254,286 | <p>If it's only on one server, then flexibility is irrelevant. Modify the shebang. If you're worried about that, make a packaged, installed copy on the dev server that doesn't use the virtualenv. Once it's out of develepment, whether that's for local users or users in guatemala, virtualenv is no longer the right too... | 1 | 2010-02-12T18:48:17Z | [
"python",
"virtualenv"
] |
Sharing scripts that require a virtualenv to be activated | 2,253,712 | <p>I have virtualenv and virtualenvwrapper installed on a shared Linux server with default settings (virtualenvs are in ~/.virtualenvs). I have several Python scripts that can only be run when the correct virtualenv is activated.</p>
<p>Now I want to <strong>share</strong> those scripts with other users on the server... | 24 | 2010-02-12T17:22:58Z | 2,255,961 | <p>Use the following magic(5) at the start of the script.</p>
<pre><code>#!/usr/bin/env python
</code></pre>
<p>Change which virtualenv is active and it'll use the python from that virtualenv.
Deactivate the virtualenv, it still runs.</p>
| 71 | 2010-02-13T00:21:43Z | [
"python",
"virtualenv"
] |
cron job and Long process problem | 2,253,714 | <p>Via django iam launching a thread (via middle ware the moment the first request comes) which continously fetches the twitter public steam and puts it down into the database.Assume the thread name is twitterthread.</p>
<p>I also have have several <strong>cron jobs</strong> which periodically interacts with other thi... | 0 | 2010-02-12T17:23:03Z | 3,487,091 | <p>I'd advice to avoid launching threads inside the django application. Most of the times you can run the thread as a separate application.</p>
<p>If you deploy the app in a Apache server and you don't control it properly each Apache process will assume that a request is the first one and you could end up with more th... | 0 | 2010-08-15T11:04:48Z | [
"python",
"django",
"cron"
] |
Python strange exception. Have I found my first Python bug or is this a noob mistake? | 2,253,816 | <p>Let me start by saying, I also get the same error whey defining <code>__init__</code> and running <code>super()</code>'s <code>__init__</code>. I only simplified it down to this custom method to see if the error still happened.</p>
<pre><code>import HTMLParser
class Spider(HTMLParser):
"""
Just a subclass.... | 18 | 2010-02-12T17:39:38Z | 2,253,824 | <p>And the answer is that I'm a complete noob. This is a module, not a class, but I'll leave this up here in case other noobs run into the same problem.</p>
<p>Solution:</p>
<pre><code>from HTMLParser import HTMLParser
</code></pre>
<p>Each time I think I'm starting to become a pro, something like this happens :(</p... | 32 | 2010-02-12T17:41:40Z | [
"python"
] |
Python: ball isn't defined | 2,254,009 | <p>I get this error:</p>
<pre><code>Traceback (most recent call last):
File "D:/Python26/PYTHON-PROGRAMME/049 bam", line 9, in <module>
ball[i][j]=sphere()
NameError: name 'ball' is not defined
</code></pre>
<p>when I run this code. But the ball is defined ( ball[i][j]=sphere() ). Isn`t it?</p>
<pre><cod... | 0 | 2010-02-12T18:08:30Z | 2,254,025 | <p>Python doesn't know that <code>ball</code> is a list. Before using it (in the first <code>for</code> loop), you'll have to initialize it as</p>
<pre><code>ball = []
</code></pre>
<p>so Python knows to treat it as a list.</p>
| 1 | 2010-02-12T18:10:11Z | [
"python",
"arrays"
] |
Python: ball isn't defined | 2,254,009 | <p>I get this error:</p>
<pre><code>Traceback (most recent call last):
File "D:/Python26/PYTHON-PROGRAMME/049 bam", line 9, in <module>
ball[i][j]=sphere()
NameError: name 'ball' is not defined
</code></pre>
<p>when I run this code. But the ball is defined ( ball[i][j]=sphere() ). Isn`t it?</p>
<pre><cod... | 0 | 2010-02-12T18:08:30Z | 2,254,029 | <p>no <code>ball</code> is not defined. this line: <code>ball[i][j]=sphere()</code> assigns value to an element of object <code>ball</code> points to. There is nothing <code>ball</code> points to therefore it's not possible to assign anything.</p>
| 1 | 2010-02-12T18:10:30Z | [
"python",
"arrays"
] |
Python: ball isn't defined | 2,254,009 | <p>I get this error:</p>
<pre><code>Traceback (most recent call last):
File "D:/Python26/PYTHON-PROGRAMME/049 bam", line 9, in <module>
ball[i][j]=sphere()
NameError: name 'ball' is not defined
</code></pre>
<p>when I run this code. But the ball is defined ( ball[i][j]=sphere() ). Isn`t it?</p>
<pre><cod... | 0 | 2010-02-12T18:08:30Z | 2,254,032 | <p>No, <code>ball</code> is not defined. You need to create a <code>list()</code> before you can start assigning to the list's indices. Similarly the nested lists need to be created before you assign to them. Try this:</p>
<pre><code>ball = [None] * 5
for i in range(5):
ball[i] = [None] * 5
for j in range(5)... | 3 | 2010-02-12T18:10:53Z | [
"python",
"arrays"
] |
Python: ball isn't defined | 2,254,009 | <p>I get this error:</p>
<pre><code>Traceback (most recent call last):
File "D:/Python26/PYTHON-PROGRAMME/049 bam", line 9, in <module>
ball[i][j]=sphere()
NameError: name 'ball' is not defined
</code></pre>
<p>when I run this code. But the ball is defined ( ball[i][j]=sphere() ). Isn`t it?</p>
<pre><cod... | 0 | 2010-02-12T18:08:30Z | 2,254,035 | <p>When you say <code>ball[i][j]</code>, you have to already have some object <code>ball</code> so that you can index (twice) into it. Try this segment instead:</p>
<pre><code>ball = []
for i in range(5):
ball.append([])
for y in range(5):
ball[i].append(sphere())
</code></pre>
| 3 | 2010-02-12T18:11:17Z | [
"python",
"arrays"
] |
Python: ball isn't defined | 2,254,009 | <p>I get this error:</p>
<pre><code>Traceback (most recent call last):
File "D:/Python26/PYTHON-PROGRAMME/049 bam", line 9, in <module>
ball[i][j]=sphere()
NameError: name 'ball' is not defined
</code></pre>
<p>when I run this code. But the ball is defined ( ball[i][j]=sphere() ). Isn`t it?</p>
<pre><cod... | 0 | 2010-02-12T18:08:30Z | 2,254,119 | <p>In your program, <code>ball</code> is just a name that doesn't refer to anything. Using indexing like <code>a[i]</code> requires that <code>a</code> refer to an object that already supports indexing. Similarly, <code>a[i][j]</code> requires that <code>a[i]</code> refer to an object that supports indexing.</p>
<p>It... | 1 | 2010-02-12T18:20:45Z | [
"python",
"arrays"
] |
tarfile: determine compression of an open tarball | 2,254,017 | <p>I am on working on a Python script which is supposed to process a tarball and output new one, trying to keep the format of the original. Thus, I am looking for a way to lookup the compression method used in an open tarball to open the new one with same compression.</p>
<p>AFAICS <code>TarFile</code> class doesn't p... | 1 | 2010-02-12T18:09:07Z | 2,254,074 | <p>Tar doesn't compress, it concatenates (which is why TarFile won't tell you what compression method is used, because there isn't one). </p>
<p>Are you trying to find out if it's a tar.gz, tar.bz2, or tar.Z ?</p>
| 1 | 2010-02-12T18:15:09Z | [
"python",
"tarfile"
] |
tarfile: determine compression of an open tarball | 2,254,017 | <p>I am on working on a Python script which is supposed to process a tarball and output new one, trying to keep the format of the original. Thus, I am looking for a way to lookup the compression method used in an open tarball to open the new one with same compression.</p>
<p>AFAICS <code>TarFile</code> class doesn't p... | 1 | 2010-02-12T18:09:07Z | 2,254,178 | <p>When you open the tarfile, you can choose the mode. From the <a href="http://docs.python.org/library/tarfile.html" rel="nofollow">docs</a>:</p>
<blockquote>
<p>If mode is not suitable to open a certain (compressed) file for reading, ReadError is raised.</p>
</blockquote>
<p>So why not try opening the file as a <... | 1 | 2010-02-12T18:28:38Z | [
"python",
"tarfile"
] |
tarfile: determine compression of an open tarball | 2,254,017 | <p>I am on working on a Python script which is supposed to process a tarball and output new one, trying to keep the format of the original. Thus, I am looking for a way to lookup the compression method used in an open tarball to open the new one with same compression.</p>
<p>AFAICS <code>TarFile</code> class doesn't p... | 1 | 2010-02-12T18:09:07Z | 2,255,217 | <p>Ok, I have found a better solution.</p>
<pre><code>f = t.fileobj.__class__(newfn, 'w')
</code></pre>
| 2 | 2010-02-12T21:23:02Z | [
"python",
"tarfile"
] |
Django flatpages and a catchall startpage | 2,254,366 | <p>I'm using django 1.1 and flatpages. It works pretty well, but I didn't manage to get a catchall or default page running.</p>
<p>As soon as I add a entry to url.py for my startpage, the flatpages aren't displayed anymore.</p>
<pre><code>(r'^', 'myproject.mysite.views.startpage'),
</code></pre>
<p>I know flatpages ... | 0 | 2010-02-12T19:02:21Z | 2,254,407 | <p>This regex matches everything, so no wonder that flatpages are not working - they are only fallback, activated on 404 error. And with this regex you don't give a chance for 404 error to show.</p>
<p>So, what you want to do is not possible with such regex catchall and flatpages.
Personally, if I want to do catch-all... | 2 | 2010-02-12T19:07:12Z | [
"python",
"django",
"django-flatpages"
] |
Django flatpages and a catchall startpage | 2,254,366 | <p>I'm using django 1.1 and flatpages. It works pretty well, but I didn't manage to get a catchall or default page running.</p>
<p>As soon as I add a entry to url.py for my startpage, the flatpages aren't displayed anymore.</p>
<pre><code>(r'^', 'myproject.mysite.views.startpage'),
</code></pre>
<p>I know flatpages ... | 0 | 2010-02-12T19:02:21Z | 2,254,415 | <p>I believe this is what you want (with a <code>$</code>):</p>
<pre><code>(r'^$', 'myproject.mysite.views.startpage')
</code></pre>
<p>It should catch only empty requests.</p>
| 4 | 2010-02-12T19:08:21Z | [
"python",
"django",
"django-flatpages"
] |
Django-tinymce not working; Getting a normal textarea instead | 2,254,398 | <p>I'm trying to use <code>django-tinymce</code> to make fields that are editable through Django's admin with a TinyMCE field. I am using <code>tinymce.models.HTMLField</code> as the field for this.</p>
<p>The problem is it's not working. I get a normal textarea. I check the HTML source, and it seems like all the code... | 1 | 2010-02-12T19:06:38Z | 2,254,470 | <p>What are your webserver and web browser. Perhaps it is trying to set the gzip/bzip header and the server isn't processing it... so it goes out plaintext but the client expects compressed?</p>
| 0 | 2010-02-12T19:15:35Z | [
"javascript",
"python",
"django",
"django-admin",
"tinymce"
] |
How do I emulate keyboard-interactive ssh login with paramiko? | 2,254,673 | <p>I'm trying to automate a ssh connection and control of a network device, that for some reason, only allows keyboard-interactive authentication. It doesn't appear that paramiko supports this by default or with the standard sshclient() object.</p>
<p>I've spent the past couple of days going through the paramiko docu... | 2 | 2010-02-12T19:50:48Z | 2,418,383 | <p>What you want is pxssh from the pxpect project. Look at the sshls.py and ssh_tunnel.py examples.</p>
<p><a href="http://www.noah.org/wiki/Pexpect" rel="nofollow">http://www.noah.org/wiki/Pexpect</a></p>
| 1 | 2010-03-10T16:01:59Z | [
"python",
"authentication",
"ssh",
"paramiko"
] |
Options for storing metadata about CUPS print jobs? | 2,254,693 | <p>I'm writing a print system that puts a simplified interface on top of CUPS. Users drop jobs into one queue, the system processes them in various ways (statistics, page quotas, etc.), and then offers the user a web interface to dispatch the job to one of multiple printers. </p>
<p>Since there may be several user ki... | 0 | 2010-02-12T19:55:40Z | 2,256,741 | <p>Have you considered <a href="http://www.sqlite.org/" rel="nofollow">sqlite</a> or <a href="http://code.google.com/p/redis/" rel="nofollow">redis</a>? Both of those are low overhead and easy to spin up, especially when you're not really dealing with complex datasets.</p>
| 0 | 2010-02-13T06:45:25Z | [
"python",
"concurrency",
"cups",
"ipp-protocol"
] |
SCons - convert all images in a directory | 2,254,707 | <p>I'd like to write an SConstruct file that will convert (e.g.) all the JPEG files in a directory into PNGs.</p>
<p>I think I have the Builder alright:</p>
<pre><code>ConvToPNG = Builder(action = 'convert $SOURCE $TARGET',
suffix = '.png',
src_suffix = '.jpg')
env['BUILDERS']['ConvToPNG'] = ConvToPNG... | 1 | 2010-02-12T19:57:36Z | 2,256,649 | <p>Scanners are for <em>implicit</em> dependencies. </p>
<p>e.g. you want to build <code>foo</code> which depends on <code>foo.c</code> which does a <code>#include</code> of <code>bar.c</code>. Thus, when you tell SCons to build <code>foo</code> with dependency <code>foo.c</code>, the <a href="http://www.scons.org/do... | 1 | 2010-02-13T06:01:39Z | [
"python",
"scons"
] |
SCons - convert all images in a directory | 2,254,707 | <p>I'd like to write an SConstruct file that will convert (e.g.) all the JPEG files in a directory into PNGs.</p>
<p>I think I have the Builder alright:</p>
<pre><code>ConvToPNG = Builder(action = 'convert $SOURCE $TARGET',
suffix = '.png',
src_suffix = '.jpg')
env['BUILDERS']['ConvToPNG'] = ConvToPNG... | 1 | 2010-02-12T19:57:36Z | 2,260,510 | <p>Your steps seems fine, but Alias node you need to pass to the AlwaysBuild function:</p>
<pre><code>env.AlwaysBuild(env.Alias('convert_all', pix_conversions))
</code></pre>
<p>So the end result would be:</p>
<pre><code>ConvToPNG = Builder(action = 'convert $SOURCE $TARGET',
suffix = '.png',
src_suf... | 1 | 2010-02-14T08:22:38Z | [
"python",
"scons"
] |
Python Import and 'object has no attribute' with Qt | 2,254,708 | <p>From research on Stack Overflow and other sites I'm 99% sure that the problem I'm having is due to incorrect importing. Below is a QLabel sub class that I'm using to respond to some mouse events:</p>
<pre><code>import Qt
import sys
class ASMovableLabel(Qt.QLabel):
def mouseReleaseEvent(self, event):
... | 0 | 2010-02-12T19:57:41Z | 2,254,735 | <p>Try</p>
<pre><code>self.frameRect().setTopLeft(Qt.QPoint(event.x, event.y))
</code></pre>
<p>instead of</p>
<pre><code>self.frameRect.setTopLeft(Qt.QPoint(event.x, event.y))
</code></pre>
| 1 | 2010-02-12T20:01:31Z | [
"python",
"qt",
"import",
"pyqt"
] |
Receive output of python script from PHP? | 2,254,827 | <p>I want to launch a python script similar to <a href="http://www.eventlet.net/doc/examples.html#web-crawler-example" rel="nofollow">this web crawler</a>, wait for it to finish, process the data in php, then return the results to the user.</p>
<p>From what I hear, getting the output from python is trivial, but the ab... | 0 | 2010-02-12T20:16:19Z | 2,254,871 | <p>I suggest a file, you can dump structured data for example to JSON or YAML (both is easily writable and readable in both Python and PHP).</p>
<p>Why is "printing stuff as it finishes" not usable? Writing file and then reading it is basically the same. You don't have to use only <code>print</code> in Python, you can... | 1 | 2010-02-12T20:22:35Z | [
"php",
"python"
] |
Pylons: Routes information availability from templates | 2,255,026 | <p>I'm building a Pylons application using evoque as our templating engine, though I think my question is relevant to other template engines. I have a base template that I'm using for our pages, and that base template does all the includes for CSS and Javascript files. I'd like to perform conditional test to include/ex... | 0 | 2010-02-12T20:49:34Z | 2,255,936 | <p>You can pull the controller and action information from environ['pylons.routes_dict']['controller'] and ['action'].</p>
<p>I'm not sure if environ is passed into the tmpl_context by default, but if not, you can just add something like this to the BaseController._<em>before</em>_ method:</p>
<pre><code>c.routes_dic... | 2 | 2010-02-13T00:11:20Z | [
"python",
"templates",
"routes",
"pylons"
] |
Finding the exponent of n = 2**x using bitwise operations [logarithm in base 2 of n] | 2,255,177 | <p>Is there a straightforward way to extracting the exponent from a power of 2 using bitwise operations only?</p>
<p><strong>EDIT:</strong> Although the question was originally about bitwise operations, the thread is a good read also if you are wondering <strong>"What's the fastest way to find X given Y = 2**X <em>in ... | 14 | 2010-02-12T21:16:56Z | 2,255,199 | <p>There is a page with a lot of these types of tricks and hacks. It's written for C, but many of them should work in Python too (though the performance will obviously be different). The bit you want is <a href="http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogObvious" rel="nofollow">here</a> and onwards.<... | 4 | 2010-02-12T21:20:30Z | [
"python",
"bit-manipulation",
"primes",
"bitwise-operators",
"logarithm"
] |
Finding the exponent of n = 2**x using bitwise operations [logarithm in base 2 of n] | 2,255,177 | <p>Is there a straightforward way to extracting the exponent from a power of 2 using bitwise operations only?</p>
<p><strong>EDIT:</strong> Although the question was originally about bitwise operations, the thread is a good read also if you are wondering <strong>"What's the fastest way to find X given Y = 2**X <em>in ... | 14 | 2010-02-12T21:16:56Z | 2,255,229 | <p>You can do it in O(lg s) time for arbitrary length integers using a binsearch. </p>
<pre><code>import sys
def floorlg(n):
if n < 1:
return -1
low=0
high=sys.getsizeof(n)*8 # not the best upper-bound guesstimate, but...
while True:
mid = (low+high)//2
i = n >> mid
... | 3 | 2010-02-12T21:24:34Z | [
"python",
"bit-manipulation",
"primes",
"bitwise-operators",
"logarithm"
] |
Finding the exponent of n = 2**x using bitwise operations [logarithm in base 2 of n] | 2,255,177 | <p>Is there a straightforward way to extracting the exponent from a power of 2 using bitwise operations only?</p>
<p><strong>EDIT:</strong> Although the question was originally about bitwise operations, the thread is a good read also if you are wondering <strong>"What's the fastest way to find X given Y = 2**X <em>in ... | 14 | 2010-02-12T21:16:56Z | 2,255,282 | <p>"language agnostic" and worrying about performance are pretty much incompatible concepts. </p>
<p>Most modern processors have a CLZ instruction, "count leading zeros". In GCC you can get to it with __builtin_clz(x) (which also produces reasonable, if not the fastest, code for targets that lack clz). Note that this ... | 6 | 2010-02-12T21:36:12Z | [
"python",
"bit-manipulation",
"primes",
"bitwise-operators",
"logarithm"
] |
Finding the exponent of n = 2**x using bitwise operations [logarithm in base 2 of n] | 2,255,177 | <p>Is there a straightforward way to extracting the exponent from a power of 2 using bitwise operations only?</p>
<p><strong>EDIT:</strong> Although the question was originally about bitwise operations, the thread is a good read also if you are wondering <strong>"What's the fastest way to find X given Y = 2**X <em>in ... | 14 | 2010-02-12T21:16:56Z | 2,259,769 | <h1>Short answer</h1>
<p>As far as python is concerned:</p>
<ul>
<li>The <strong>fastest method of all</strong> to find the exponent of 2**x is by looking up in a dictionary whose hashes are the powers of 2 (see "<em>hashlookup</em>" in the code)</li>
<li>The <strong>fastest bitwise method</strong> is the one called ... | 5 | 2010-02-14T01:00:33Z | [
"python",
"bit-manipulation",
"primes",
"bitwise-operators",
"logarithm"
] |
Finding the exponent of n = 2**x using bitwise operations [logarithm in base 2 of n] | 2,255,177 | <p>Is there a straightforward way to extracting the exponent from a power of 2 using bitwise operations only?</p>
<p><strong>EDIT:</strong> Although the question was originally about bitwise operations, the thread is a good read also if you are wondering <strong>"What's the fastest way to find X given Y = 2**X <em>in ... | 14 | 2010-02-12T21:16:56Z | 2,263,231 | <p>It seems like the range is known. Let's assume it goes up to 1<<20, just to make it more interesting:</p>
<pre><code>max_log2=20
</code></pre>
<p>So make a list that (in effect) maps an integer to its base 2 logarithm. The following will do the trick:</p>
<pre><code>log2s_table=[0]*((1<<max_log2)+1)
f... | 1 | 2010-02-14T23:07:30Z | [
"python",
"bit-manipulation",
"primes",
"bitwise-operators",
"logarithm"
] |
Finding the exponent of n = 2**x using bitwise operations [logarithm in base 2 of n] | 2,255,177 | <p>Is there a straightforward way to extracting the exponent from a power of 2 using bitwise operations only?</p>
<p><strong>EDIT:</strong> Although the question was originally about bitwise operations, the thread is a good read also if you are wondering <strong>"What's the fastest way to find X given Y = 2**X <em>in ... | 14 | 2010-02-12T21:16:56Z | 2,263,321 | <p><em>This is actually a comment to the performance test posted by mac. I post this as an answer to have proper code formatting and indenting</em></p>
<p>mac, could you try a unrolled implementation of the bitseach suggested by Mark Byers? Maybe it's just the array access that slows it down. In theory this approach s... | 1 | 2010-02-14T23:36:16Z | [
"python",
"bit-manipulation",
"primes",
"bitwise-operators",
"logarithm"
] |
Return all non-overlapping matches of pattern in string | 2,255,302 | <p>In Python I can use re.findall(pattern, string) to return all non-overlapping matches of pattern in a string.</p>
<p>For example, in the following SVG path command:</p>
<pre><code>import re
spam = "M317.0,169.7C311.1,170.5 285.7,146.8 300.7,178.57 L 321.4,175.01"
eggs = re.findall("([A-Za-z]|-?[0-9]+\.?[0-9]*(?:e-... | 2 | 2010-02-12T21:39:26Z | 2,255,313 | <p>You'll need a C++ regular expression library. There are a number of them but they will create a dependency. C++ has no native (or STL) regular expression support.</p>
| 2 | 2010-02-12T21:42:17Z | [
"c++",
"python",
"regex",
"pattern-matching"
] |
Return all non-overlapping matches of pattern in string | 2,255,302 | <p>In Python I can use re.findall(pattern, string) to return all non-overlapping matches of pattern in a string.</p>
<p>For example, in the following SVG path command:</p>
<pre><code>import re
spam = "M317.0,169.7C311.1,170.5 285.7,146.8 300.7,178.57 L 321.4,175.01"
eggs = re.findall("([A-Za-z]|-?[0-9]+\.?[0-9]*(?:e-... | 2 | 2010-02-12T21:39:26Z | 2,255,408 | <p><strong>SLRE - Super Light Regular Expression library</strong></p>
<p><a href="http://slre.sourceforge.net/" rel="nofollow">SLRE</a> is an ANSI C library that implements a tiny subset of Perl regular expressions. It is primarily targeted for developers who want to parse configuation files, where speed is unimportan... | 4 | 2010-02-12T22:01:26Z | [
"c++",
"python",
"regex",
"pattern-matching"
] |
Extra data about objects in django templates | 2,255,488 | <p>I have django objects:</p>
<pre><code>class Event(models.Model):
title = models.CharField(max_length=255)
event_start_date = models.DateField(null=True, blank='true')
...
class RegistrationDate(models.Model):
event = models.ForeignKey(tblEvents)
date_type = models.CharField(max_length=10, choices=... | 0 | 2010-02-12T22:14:46Z | 2,255,505 | <p>I think you can make that function you wrote a class method of Event. Then you can just call it from the template. For example...</p>
<pre><code>{% if event %}
event.getStatus
{% endif %}
</code></pre>
<p>...but I haven't done Django in a little while.</p>
| 2 | 2010-02-12T22:17:25Z | [
"python",
"django",
"django-models",
"django-templates"
] |
Extra data about objects in django templates | 2,255,488 | <p>I have django objects:</p>
<pre><code>class Event(models.Model):
title = models.CharField(max_length=255)
event_start_date = models.DateField(null=True, blank='true')
...
class RegistrationDate(models.Model):
event = models.ForeignKey(tblEvents)
date_type = models.CharField(max_length=10, choices=... | 0 | 2010-02-12T22:14:46Z | 2,255,517 | <p>Add a property to your <code>Event</code> class e.g.:</p>
<pre><code>class Event:
# stuff here
@property
def status(self):
# do the same thing here as in your status function
return status
</code></pre>
<p>The you can do in your template:</p>
<pre><code>{{ event.status }}
</code></pre>
| 5 | 2010-02-12T22:19:30Z | [
"python",
"django",
"django-models",
"django-templates"
] |
Different results from converting a file from iso-8859-1 to utf-8 iconv in shell vs calling it from python with subprocess | 2,255,509 | <p>Well, this could be a simple question, to be frank I'm a little confused with encodings an all those things.</p>
<p>Let's suppose I have the file <code>01234.txt</code> which is iso-8859-1. </p>
<p>When I do:</p>
<p><code>iconv --from-code=iso-8859-1 --to-code=utf-8 01234.txt > 01234_utf8.txt</code></p>
<p>It... | 1 | 2010-02-12T22:18:14Z | 2,255,828 | <p>You wrote: "In the python file I've used coding: utf-8 and coding: iso-8859-1."</p>
<p>Only the first of those will be used. Secondly, that specifies the encoding of the Python source file in which it appears, so that the Python compiler can do its job. Consequently it is absolutely nothing to do with the encodings... | 1 | 2010-02-12T23:41:51Z | [
"python",
"subprocess",
"iconv"
] |
How can I import a C++ python extension into a module in another directory? | 2,255,543 | <p>Here is the directory structure:</p>
<pre><code>app/
__init__.py
sub1/
__init__.py
mod1.py
sub2/
__init__.py
sub2.so
test_sub2.py
</code></pre>
<ul>
<li>The folder app is on my PYTHONPATH</li>
<li>All of the _<em>init</em>_.py files are empty.</li>
<li>The shared... | 1 | 2010-02-12T22:24:54Z | 2,255,567 | <p>The way to import it is to import <code>app.sub2.sub2</code>, from any source file. Your test should actually live outside of <code>app</code> and use that module-path to get to the extension module.</p>
| 2 | 2010-02-12T22:30:01Z | [
"python",
"import",
"module"
] |
How can I import a C++ python extension into a module in another directory? | 2,255,543 | <p>Here is the directory structure:</p>
<pre><code>app/
__init__.py
sub1/
__init__.py
mod1.py
sub2/
__init__.py
sub2.so
test_sub2.py
</code></pre>
<ul>
<li>The folder app is on my PYTHONPATH</li>
<li>All of the _<em>init</em>_.py files are empty.</li>
<li>The shared... | 1 | 2010-02-12T22:24:54Z | 2,255,593 | <p>Try </p>
<pre><code>import .app.sub2.sub2
</code></pre>
<p>in your mod1.py file</p>
| 0 | 2010-02-12T22:35:47Z | [
"python",
"import",
"module"
] |
How can I import a C++ python extension into a module in another directory? | 2,255,543 | <p>Here is the directory structure:</p>
<pre><code>app/
__init__.py
sub1/
__init__.py
mod1.py
sub2/
__init__.py
sub2.so
test_sub2.py
</code></pre>
<ul>
<li>The folder app is on my PYTHONPATH</li>
<li>All of the _<em>init</em>_.py files are empty.</li>
<li>The shared... | 1 | 2010-02-12T22:24:54Z | 2,255,600 | <p>Use relative imports:</p>
<pre><code>from ..sub2.sub2 import A
</code></pre>
<p>This is similar to a relative path "../sub2/sub2.so".</p>
| 0 | 2010-02-12T22:36:58Z | [
"python",
"import",
"module"
] |
hash functions family generator in python | 2,255,604 | <p>I am looking for a hash functions family generator that could generate a family of hash functions given a set of parameters. I haven't found any such generator so far.
Is there a way to do that with the <code>hashlib</code> package ?</p>
<p>For example I'd like to do something like :</p>
<pre><code>h1 = hash_funct... | 6 | 2010-02-12T22:37:45Z | 2,255,636 | <p>I'd just do something like (if you don't need thread-safety -- not hard to alter if you DO need thread safety -- and assuming a 32-bit Python version):</p>
<pre><code>import random
_memomask = {}
def hash_function(n):
mask = _memomask.get(n)
if mask is None:
random.seed(n)
mask = _memomask[n] = random... | 4 | 2010-02-12T22:44:56Z | [
"python",
"hash",
"generator"
] |
hash functions family generator in python | 2,255,604 | <p>I am looking for a hash functions family generator that could generate a family of hash functions given a set of parameters. I haven't found any such generator so far.
Is there a way to do that with the <code>hashlib</code> package ?</p>
<p>For example I'd like to do something like :</p>
<pre><code>h1 = hash_funct... | 6 | 2010-02-12T22:37:45Z | 25,104,055 | <p>You should consider using universal hashing. My answer and code can be found here: <a href="http://stackoverflow.com/a/25104050/207661">http://stackoverflow.com/a/25104050/207661</a></p>
| 0 | 2014-08-03T11:08:28Z | [
"python",
"hash",
"generator"
] |
Script access to WebGoat urls? | 2,255,721 | <p>I've been solving a couple of the WebGoat exampels for a uni-lab thing. In one of the exercises I tried to use a python script with urllib2 to do automated "tests" so I didnt manually have to used ascii(substr(first_name,3,1)) > 97 etc.</p>
<p>But I seem to get the same page eventhough I try different urls when usi... | 2 | 2010-02-12T23:07:57Z | 2,257,023 | <p>Is the user agent being checked? I've had to specify a user agent for a typical browser before to get past checks like that. You have one listed in your "data" variable but it looks like you don't actually apply it in any way.</p>
| 2 | 2010-02-13T09:04:53Z | [
"python",
"security"
] |
Script access to WebGoat urls? | 2,255,721 | <p>I've been solving a couple of the WebGoat exampels for a uni-lab thing. In one of the exercises I tried to use a python script with urllib2 to do automated "tests" so I didnt manually have to used ascii(substr(first_name,3,1)) > 97 etc.</p>
<p>But I seem to get the same page eventhough I try different urls when usi... | 2 | 2010-02-12T23:07:57Z | 2,258,055 | <p>Woohoo!
Found out</p>
<p>The ID of the page I'm trying to find is regenerated on every session. So i need to look at the data returned before choosing a screenId:</p>
<pre><code>import urllib2
import urllib
import cookielib
import re
def write_f_to_f(fname,f):
f1 = open(fname,"w")
f1.write(f.read())
... | 0 | 2010-02-13T15:31:19Z | [
"python",
"security"
] |
Making PostgreSQL respect the order of the inputted parameters? | 2,255,837 | <p>This question has a little history — <a href="http://stackoverflow.com/questions/2247892/is-there-a-way-to-make-a-query-respect-the-order-of-the-inputted-parameters">http://stackoverflow.com/questions/2247892/is-there-a-way-to-make-a-query-respect-the-order-of-the-inputted-parameters</a></p>
<p>I'm new to bui... | 5 | 2010-02-12T23:44:13Z | 2,256,078 | <p>Query results will be returned in non-deterministic order unless you specify an <code>ORDER BY</code> clause. </p>
<p>If you really want to do the query in the manner you are requesting, then you could construct such a clause. Here's an example using part of your data.</p>
<pre><code>create table artists (
id in... | 5 | 2010-02-13T01:03:37Z | [
"python",
"postgresql"
] |
Making PostgreSQL respect the order of the inputted parameters? | 2,255,837 | <p>This question has a little history — <a href="http://stackoverflow.com/questions/2247892/is-there-a-way-to-make-a-query-respect-the-order-of-the-inputted-parameters">http://stackoverflow.com/questions/2247892/is-there-a-way-to-make-a-query-respect-the-order-of-the-inputted-parameters</a></p>
<p>I'm new to bui... | 5 | 2010-02-12T23:44:13Z | 2,256,443 | <p>I suggest you let PostGreSQL return the set in any arbitrary order (especially since it's difficult to do fine-grained SQL-level control from a Django interface), then sort it in the way you wish in <em>Python</em> -- <code>theresultset.sort(key=yourlistofids.index)</code> should do fine (when <code>theresultset</co... | 2 | 2010-02-13T04:16:43Z | [
"python",
"postgresql"
] |
Making PostgreSQL respect the order of the inputted parameters? | 2,255,837 | <p>This question has a little history — <a href="http://stackoverflow.com/questions/2247892/is-there-a-way-to-make-a-query-respect-the-order-of-the-inputted-parameters">http://stackoverflow.com/questions/2247892/is-there-a-way-to-make-a-query-respect-the-order-of-the-inputted-parameters</a></p>
<p>I'm new to bui... | 5 | 2010-02-12T23:44:13Z | 18,529,857 | <p>Another way:</p>
<pre><code>SELECT *
FROM artists
WHERE id IN (8, 1, 2, 15, 14, 3, 13, 31, 16, 5, 4, 7, 32, 9, 37)
ORDER BY POSITION(id::text in '(8, 1, 2, 15, 14, 3, 13, 31, 16, 5, 4, 7, 32, 9, 37)');
</code></pre>
| 0 | 2013-08-30T09:45:41Z | [
"python",
"postgresql"
] |
What does `**` mean in the expression `dict(d1, **d2)`? | 2,255,878 | <p>I am intrigued by the following python expression:</p>
<pre><code>d3 = dict(d1, **d2)
</code></pre>
<p>The task is to merge 2 dictionaries into a third one, and the above expression accomplishes the task just fine. I am interested in the ** operator and what exactly is it doing to the expression. I thought that **... | 22 | 2010-02-12T23:57:13Z | 2,255,886 | <p>In Python, any function can accept multiple arguments with *;<br>
or multiple <a href="http://docs.python.org/tutorial/controlflow.html#keyword-arguments"><strong>keyword arguments</strong></a> with **.</p>
<p>Receiving-side example:</p>
<pre><code>>>> def fn(**kwargs):
... for kwarg in kwargs:
... ... | 8 | 2010-02-12T23:59:48Z | [
"python",
"syntax",
"dictionary",
"operators",
"set-operations"
] |
What does `**` mean in the expression `dict(d1, **d2)`? | 2,255,878 | <p>I am intrigued by the following python expression:</p>
<pre><code>d3 = dict(d1, **d2)
</code></pre>
<p>The task is to merge 2 dictionaries into a third one, and the above expression accomplishes the task just fine. I am interested in the ** operator and what exactly is it doing to the expression. I thought that **... | 22 | 2010-02-12T23:57:13Z | 2,255,892 | <p><code>**</code> in argument lists has a special meaning, as covered in <a href="http://docs.python.org/tutorial/controlflow.html#more-on-defining-functions">section 4.7 of the tutorial</a>. The dictionary (or dictionary-like) object passed with <code>**kwargs</code> is expanded into keyword arguments to the callable... | 25 | 2010-02-13T00:00:29Z | [
"python",
"syntax",
"dictionary",
"operators",
"set-operations"
] |
What does `**` mean in the expression `dict(d1, **d2)`? | 2,255,878 | <p>I am intrigued by the following python expression:</p>
<pre><code>d3 = dict(d1, **d2)
</code></pre>
<p>The task is to merge 2 dictionaries into a third one, and the above expression accomplishes the task just fine. I am interested in the ** operator and what exactly is it doing to the expression. I thought that **... | 22 | 2010-02-12T23:57:13Z | 2,255,897 | <p>The ** turns the dictionary into keyword parameters:</p>
<pre><code>>>> d1 = {'a': 1, 'b': 2}
>>> d2 = {'c': 3, 'd': 4}
>>> d3 = dict(d1, **d2)
</code></pre>
<p>Becomes:</p>
<pre><code>>>> d3 = dict(d1, c=3, d=4)
</code></pre>
| 6 | 2010-02-13T00:01:43Z | [
"python",
"syntax",
"dictionary",
"operators",
"set-operations"
] |
What does `**` mean in the expression `dict(d1, **d2)`? | 2,255,878 | <p>I am intrigued by the following python expression:</p>
<pre><code>d3 = dict(d1, **d2)
</code></pre>
<p>The task is to merge 2 dictionaries into a third one, and the above expression accomplishes the task just fine. I am interested in the ** operator and what exactly is it doing to the expression. I thought that **... | 22 | 2010-02-12T23:57:13Z | 2,255,903 | <p>That operator is used to unpack argument list:
<a href="http://docs.python.org/tutorial/controlflow.html#unpacking-argument-lists" rel="nofollow">http://docs.python.org/tutorial/controlflow.html#unpacking-argument-lists</a></p>
| 1 | 2010-02-13T00:03:48Z | [
"python",
"syntax",
"dictionary",
"operators",
"set-operations"
] |
What does `**` mean in the expression `dict(d1, **d2)`? | 2,255,878 | <p>I am intrigued by the following python expression:</p>
<pre><code>d3 = dict(d1, **d2)
</code></pre>
<p>The task is to merge 2 dictionaries into a third one, and the above expression accomplishes the task just fine. I am interested in the ** operator and what exactly is it doing to the expression. I thought that **... | 22 | 2010-02-12T23:57:13Z | 2,255,970 | <p>you have got your answer of the ** operator. here's another way to add dictionaries</p>
<pre><code>>>> d1 = {'a': 1, 'b': 2}
>>> d2 = {'c': 3, 'd': 4}
>>> d3=d1.copy()
>>> d3.update(d2)
>>> d3
{'a': 1, 'c': 3, 'b': 2, 'd': 4}
</code></pre>
| 1 | 2010-02-13T00:24:55Z | [
"python",
"syntax",
"dictionary",
"operators",
"set-operations"
] |
What does `**` mean in the expression `dict(d1, **d2)`? | 2,255,878 | <p>I am intrigued by the following python expression:</p>
<pre><code>d3 = dict(d1, **d2)
</code></pre>
<p>The task is to merge 2 dictionaries into a third one, and the above expression accomplishes the task just fine. I am interested in the ** operator and what exactly is it doing to the expression. I thought that **... | 22 | 2010-02-12T23:57:13Z | 2,257,003 | <p>It's also worth mentioning the mechanics of the dict constructor. It takes an initial dictionary as its first argument and can also take keyword arguments, each representing a new member to add to the newly created dictionary.</p>
| 3 | 2010-02-13T08:53:00Z | [
"python",
"syntax",
"dictionary",
"operators",
"set-operations"
] |
How do I interact with MATLAB from Python? | 2,255,942 | <p>A friend asked me about creating a small web interface that accepts some inputs, sends them to MATLAB for number crunching and outputs the results. I'm a Python/Django developer by trade, so I can handle the web interface, but I am clueless when it comes to MATLAB. Specifically:</p>
<ul>
<li>I'd <strong>really</str... | 19 | 2010-02-13T00:12:37Z | 2,255,953 | <p>Perhaps you'll find useful information here</p>
<p><a href="http://claymore.engineer.gvsu.edu/~steriana/Python/pymat.html" rel="nofollow">PyMat - An interface between Python and MATLAB</a></p>
| -1 | 2010-02-13T00:17:55Z | [
"python",
"matlab",
"ctypes"
] |
How do I interact with MATLAB from Python? | 2,255,942 | <p>A friend asked me about creating a small web interface that accepts some inputs, sends them to MATLAB for number crunching and outputs the results. I'm a Python/Django developer by trade, so I can handle the web interface, but I am clueless when it comes to MATLAB. Specifically:</p>
<ul>
<li>I'd <strong>really</str... | 19 | 2010-02-13T00:12:37Z | 2,255,958 | <p>Take a look at <a href="http://mlabwrap.sourceforge.net/">mlabwrap</a> which allows you to call Matlab via a python API</p>
| 10 | 2010-02-13T00:20:02Z | [
"python",
"matlab",
"ctypes"
] |
How do I interact with MATLAB from Python? | 2,255,942 | <p>A friend asked me about creating a small web interface that accepts some inputs, sends them to MATLAB for number crunching and outputs the results. I'm a Python/Django developer by trade, so I can handle the web interface, but I am clueless when it comes to MATLAB. Specifically:</p>
<ul>
<li>I'd <strong>really</str... | 19 | 2010-02-13T00:12:37Z | 2,257,221 | <p>Regarding OS compatibility, if you use the matlab version for Linux, the scripts written in windows should work without any changes.
If possible, you may also consider the possibility of doing everything with python. Scipy/numpy with Matplotlib provide a complete Matlab replacement.</p>
| 1 | 2010-02-13T10:51:45Z | [
"python",
"matlab",
"ctypes"
] |
How do I interact with MATLAB from Python? | 2,255,942 | <p>A friend asked me about creating a small web interface that accepts some inputs, sends them to MATLAB for number crunching and outputs the results. I'm a Python/Django developer by trade, so I can handle the web interface, but I am clueless when it comes to MATLAB. Specifically:</p>
<ul>
<li>I'd <strong>really</str... | 19 | 2010-02-13T00:12:37Z | 11,467,773 | <p>There is a <a href="https://github.com/jaderberg/python-matlab-bridge">python-matlab bridge</a> which is unique in the sense that Matlab runs in the background as a server so you don't have the startup cost each time you call a Matlab function.</p>
<p>it's as easy as downloading and the following code:</p>
<pre><c... | 11 | 2012-07-13T09:30:39Z | [
"python",
"matlab",
"ctypes"
] |
How do I interact with MATLAB from Python? | 2,255,942 | <p>A friend asked me about creating a small web interface that accepts some inputs, sends them to MATLAB for number crunching and outputs the results. I'm a Python/Django developer by trade, so I can handle the web interface, but I am clueless when it comes to MATLAB. Specifically:</p>
<ul>
<li>I'd <strong>really</str... | 19 | 2010-02-13T00:12:37Z | 36,221,046 | <p>As an alternative, since Matlab R2014b, a Python library is provided to call Matlab from Python using the <a href="http://nl.mathworks.com/help/matlab/matlab-engine-for-python.html" rel="nofollow">MATLAB Engine API for Python</a>.</p>
| 0 | 2016-03-25T13:38:52Z | [
"python",
"matlab",
"ctypes"
] |
Python: Help with UnboundLocalError: local variable referenced before assignment | 2,256,056 | <p>I keep getting this error for a portion of my code.</p>
<pre><code>Traceback (most recent call last):
File "./mang.py", line 1688, in <module>
files, tsize = logger()
File "./mang.py", line 1466, in logger
nl = sshfile(list, "nl")
UnboundLocalError: local variable 'sshfile' referenced before assignment
</code... | 2 | 2010-02-13T00:56:18Z | 2,256,068 | <p>You probably haven't imported the file which contains the definition of <code>sshfile</code>, or you need to qualify the class name with the package name. It depends on how you imported it.</p>
<p>What package does it come from? Where is it defined?</p>
<hr>
<p><strong>Update</strong></p>
<p>For anyone else read... | 1 | 2010-02-13T00:59:41Z | [
"python",
"multithreading"
] |
Testing python methods that call class methods | 2,256,063 | <p>I have a very simple method:</p>
<pre><code>Class Team(models.Model):
def sides(self):
return SideNames.objects.filter(team=self)
</code></pre>
<p>SideNames is another model defined in the same file as Team, </p>
<p>Which when I try and test:</p>
<pre><code>self.assertEquals(len(t.sides()), 2)
</code><... | -1 | 2010-02-13T00:57:59Z | 2,256,080 | <p>In the module that defines the test, you're importing the name <code>SideNames</code> from some other module. In the module where that <code>sides</code> method is defined, the name <code>SideNames</code> is not defined or imported.</p>
| 1 | 2010-02-13T01:04:32Z | [
"python",
"unit-testing",
"pyunit"
] |
Testing python methods that call class methods | 2,256,063 | <p>I have a very simple method:</p>
<pre><code>Class Team(models.Model):
def sides(self):
return SideNames.objects.filter(team=self)
</code></pre>
<p>SideNames is another model defined in the same file as Team, </p>
<p>Which when I try and test:</p>
<pre><code>self.assertEquals(len(t.sides()), 2)
</code><... | -1 | 2010-02-13T00:57:59Z | 2,257,394 | <p>By any chance, does your test do something like this:</p>
<pre><code>from myapp import models
...
models.SideNames = None
</code></pre>
<p>since that's the only explanation I can think of for why SideNames should be None in the context of that method.</p>
<p>As an aside, the method itself is pointless, as backw... | 1 | 2010-02-13T12:03:21Z | [
"python",
"unit-testing",
"pyunit"
] |
python Client hangs when no data to receive from server and hangs in that thread w/o letting client send | 2,256,113 | <p>I am trying to figure out how to get my client to send and receive data 'simultaneously' and am using threads. My problem is that, depending on the way I set it up, the way here it waits for data from the server in the recieveFromServer function which is in its own thread and cannot stop it when nothing will be sen... | 0 | 2010-02-13T01:19:10Z | 2,256,172 | <p>I think you want to try and set the socket to non-blocking mode:</p>
<p><a href="http://docs.python.org/library/socket.html#socket.socket.setblocking" rel="nofollow">http://docs.python.org/library/socket.html#socket.socket.setblocking</a></p>
<blockquote>
<p>Set blocking or non-blocking mode of
the socket: if ... | 1 | 2010-02-13T01:40:52Z | [
"python",
"multithreading",
"client",
"locking"
] |
Options for read-only binary flat-file storage using Python | 2,256,256 | <p>I have been tasked with setting up a flat-file SKU database for use on embedded devices with limited storage and processor speed.</p>
<p>Basically the data I need to store consists of the following:</p>
<p>SKU
Description
Location
Price
Qty</p>
<p>The file will consist of several million records.</p>
<p>The most... | 1 | 2010-02-13T02:25:59Z | 2,256,260 | <p>How about <a href="http://www.sqlite.org/" rel="nofollow">SQLite</a> with Python bindings? It has a little more than you need, but it's standard software and well-tested.</p>
| 4 | 2010-02-13T02:27:27Z | [
"python",
"data-structures",
"flat-file",
"minimum-size"
] |
Options for read-only binary flat-file storage using Python | 2,256,256 | <p>I have been tasked with setting up a flat-file SKU database for use on embedded devices with limited storage and processor speed.</p>
<p>Basically the data I need to store consists of the following:</p>
<p>SKU
Description
Location
Price
Qty</p>
<p>The file will consist of several million records.</p>
<p>The most... | 1 | 2010-02-13T02:25:59Z | 2,256,264 | <p>How about <a href="http://code.google.com/p/h5py/" rel="nofollow">HDF</a>? If you don't need SQL and require fast access to your data, there's nothing faster... in Python... for numerical or structured data.</p>
<p>Take a look at the <a href="http://wiki.python.org/moin/DatabaseInterfaces" rel="nofollow">DatabaseIn... | 1 | 2010-02-13T02:30:21Z | [
"python",
"data-structures",
"flat-file",
"minimum-size"
] |
Options for read-only binary flat-file storage using Python | 2,256,256 | <p>I have been tasked with setting up a flat-file SKU database for use on embedded devices with limited storage and processor speed.</p>
<p>Basically the data I need to store consists of the following:</p>
<p>SKU
Description
Location
Price
Qty</p>
<p>The file will consist of several million records.</p>
<p>The most... | 1 | 2010-02-13T02:25:59Z | 2,256,302 | <p>A simple solution is <a href="http://docs.python.org/library/pickle.html" rel="nofollow">CPickle</a>. You can also find <a href="http://stackoverflow.com/questions/890485/python-how-do-i-write-a-list-to-file-and-then-pull-it-back-into-memory-dict-rep">similar questions</a> on SO.</p>
| 0 | 2010-02-13T02:53:40Z | [
"python",
"data-structures",
"flat-file",
"minimum-size"
] |
Options for read-only binary flat-file storage using Python | 2,256,256 | <p>I have been tasked with setting up a flat-file SKU database for use on embedded devices with limited storage and processor speed.</p>
<p>Basically the data I need to store consists of the following:</p>
<p>SKU
Description
Location
Price
Qty</p>
<p>The file will consist of several million records.</p>
<p>The most... | 1 | 2010-02-13T02:25:59Z | 2,256,361 | <p>The old way would be to use a simple key/value data table like gdbm module. Python comes with support for that, but it's not built into the default Python installation on my machine.</p>
<p>In general, use SQLite. As others wrote, it comes standard with Python, and it's used in a lot of embedded systems already.</p... | 4 | 2010-02-13T03:27:19Z | [
"python",
"data-structures",
"flat-file",
"minimum-size"
] |
Options for read-only binary flat-file storage using Python | 2,256,256 | <p>I have been tasked with setting up a flat-file SKU database for use on embedded devices with limited storage and processor speed.</p>
<p>Basically the data I need to store consists of the following:</p>
<p>SKU
Description
Location
Price
Qty</p>
<p>The file will consist of several million records.</p>
<p>The most... | 1 | 2010-02-13T02:25:59Z | 2,256,415 | <p>A variation of Andrew Dalke's answer (so you can still use binary search to locate the SKU quickly) which may reduce the space requirements would be to have fixed sized records at the start of the file (one per SKU) and then all the Descriptions and Locations (as null terminated strings say)</p>
<p>You get to save ... | 0 | 2010-02-13T04:01:55Z | [
"python",
"data-structures",
"flat-file",
"minimum-size"
] |
Options for read-only binary flat-file storage using Python | 2,256,256 | <p>I have been tasked with setting up a flat-file SKU database for use on embedded devices with limited storage and processor speed.</p>
<p>Basically the data I need to store consists of the following:</p>
<p>SKU
Description
Location
Price
Qty</p>
<p>The file will consist of several million records.</p>
<p>The most... | 1 | 2010-02-13T02:25:59Z | 2,256,493 | <p>May I suggest <a href="http://cr.yp.to/cdb.html" rel="nofollow">cdb</a>? (Python bindings: <a href="http://pypi.python.org/pypi/python-cdb/" rel="nofollow">python-cdb</a>.)</p>
<p>It's a format used for read-only data, like you have; it's basically 256 giant hash tables, each able to have a different number of buck... | 1 | 2010-02-13T04:39:32Z | [
"python",
"data-structures",
"flat-file",
"minimum-size"
] |
Teleporting Traveler, Optimal Profit over time Problem | 2,256,589 | <p>I'm new to the whole traveling-salesman problem as well as stackoverflow so let me know if I say something that isn't quite right. </p>
<p><strong>Intro:</strong></p>
<p>I'm trying to code a profit/time-optimized multiple-trade algorithm for a game which involves multiple cities (nodes) within multiple countries (... | 7 | 2010-02-13T05:24:54Z | 2,256,631 | <p>If this is a game where you are playing against humans I would assume the total size of the data space is actually quite limited. If so I would be inclined to throw out all the fancy pruning as I doubt it's worth it.</p>
<p>Instead, how about a simple breadth-first search?</p>
<p>Build a list of all cities, mark ... | 2 | 2010-02-13T05:48:11Z | [
"python",
"algorithm",
"routing",
"heuristics",
"traveling-salesman"
] |
Teleporting Traveler, Optimal Profit over time Problem | 2,256,589 | <p>I'm new to the whole traveling-salesman problem as well as stackoverflow so let me know if I say something that isn't quite right. </p>
<p><strong>Intro:</strong></p>
<p>I'm trying to code a profit/time-optimized multiple-trade algorithm for a game which involves multiple cities (nodes) within multiple countries (... | 7 | 2010-02-13T05:24:54Z | 2,268,706 | <p>I think you've defined something that fits into a class of problems called inventory - routing problems. I assume since you have both goods and coin, the traveller is both buying and selling along the chosen route. Let's first assume that EVERYTHING is deterministic - all quantities of goods in demand, supply avai... | 1 | 2010-02-15T20:31:52Z | [
"python",
"algorithm",
"routing",
"heuristics",
"traveling-salesman"
] |
wxPython - Drawing an unfilled rectangle with the DC | 2,256,722 | <pre><code>dc.SetPen(wx.Pen(wx.BLACK, 0))
dc.SetBrush(wx.Brush("C0C0C0"))
dc.DrawRectangle(50,50,50,50)
</code></pre>
<p>This is my best attempt at drawing a 50x50, gray box with no border. However, setting the pen width to 0 doesn't seem to accomplish anything, and setting the brush only changes the fill from pure wh... | 2 | 2010-02-13T06:36:05Z | 2,257,520 | <p>This makes a grey rectangle:</p>
<pre><code>import wx
class MyPanel(wx.Panel):
""" class MyPanel creates a panel to draw on, inherits wx.Panel """
def __init__(self, parent, id):
# create a panel
wx.Panel.__init__(self, parent, id)
self.SetBackgroundColour("white")
self.Bind... | 3 | 2010-02-13T12:42:41Z | [
"python",
"user-interface",
"wxpython"
] |
wxPython - Drawing an unfilled rectangle with the DC | 2,256,722 | <pre><code>dc.SetPen(wx.Pen(wx.BLACK, 0))
dc.SetBrush(wx.Brush("C0C0C0"))
dc.DrawRectangle(50,50,50,50)
</code></pre>
<p>This is my best attempt at drawing a 50x50, gray box with no border. However, setting the pen width to 0 doesn't seem to accomplish anything, and setting the brush only changes the fill from pure wh... | 2 | 2010-02-13T06:36:05Z | 39,129,160 | <p>In order to draw a non-filled rectangle you need to set brush transparent as the brush does the filling and the pen draws the outline. The example below draws a blue non-filled rectangle alongside a red filled one.</p>
<pre><code>import wx
class MyPanel(wx.Panel):
""" class MyPanel creates a panel to draw on, ... | 0 | 2016-08-24T17:01:41Z | [
"python",
"user-interface",
"wxpython"
] |
GtkTreeView's row-activated and cursor-changed signals | 2,256,794 | <p>I have a treeview and I am watching for the <code>cursor-changed</code> and <code>row-activated</code> signals. The problem is that in order to trigger the row-activate I first have to click on the row (triggering <code>cursor-changed</code>) and then do the double click, requiring 3 clicks.</p>
<p>Is there a way ... | 1 | 2010-02-13T07:09:18Z | 3,099,281 | <p>It's not very clear what you're trying to achieve. I guess you're trying to respond to the user changing the selection in the treeview.</p>
<p>If this is the case, connect to the <code>[changed][1]</code> signal on the <code>gtk.TreeSelection</code>:</p>
<pre><code>selection = treeview.get_selection()
selection.co... | 4 | 2010-06-23T06:07:58Z | [
"python",
"gtk",
"pygtk",
"gtktreeview"
] |
GtkTreeView's row-activated and cursor-changed signals | 2,256,794 | <p>I have a treeview and I am watching for the <code>cursor-changed</code> and <code>row-activated</code> signals. The problem is that in order to trigger the row-activate I first have to click on the row (triggering <code>cursor-changed</code>) and then do the double click, requiring 3 clicks.</p>
<p>Is there a way ... | 1 | 2010-02-13T07:09:18Z | 3,100,214 | <p>The <code>cursor-changed</code> signal is emitted even when single clicking on the same (selected) row. Still, the <code>row-activated</code> signal is emitted when you double click on a row, whether it was selected before the double click or not. Thus you don't need 3 clicks to trigger a <code>row-activated</code>.... | 2 | 2010-06-23T08:52:15Z | [
"python",
"gtk",
"pygtk",
"gtktreeview"
] |
How can I count words in complex documents (.rtf, .doc, .odt, etc)? | 2,256,881 | <p>I'm trying to write a Python function that, given the path to a document file, returns the number of words in that document. This is fairly easy to do with .txt files, and there are tools that allow me to hack support for a few more complex document formats together, but I want a really comprehensive solution.</p>
... | 4 | 2010-02-13T07:52:55Z | 2,256,953 | <p>This could be not the option for you, but in case it is - you can upload documents to Google Docs and then export in .txt format. Google usually does very nice job for the conversion.</p>
<p>You can find relevant APIs here: <a href="http://code.google.com/intl/pl/apis/documents/docs/1.0/developers_guide_python.html... | 2 | 2010-02-13T08:30:55Z | [
"python",
"document",
"openoffice.org",
"word-count"
] |
How can I count words in complex documents (.rtf, .doc, .odt, etc)? | 2,256,881 | <p>I'm trying to write a Python function that, given the path to a document file, returns the number of words in that document. This is fairly easy to do with .txt files, and there are tools that allow me to hack support for a few more complex document formats together, but I want a really comprehensive solution.</p>
... | 4 | 2010-02-13T07:52:55Z | 2,257,350 | <p><strong>load the documents in a headless OOo</strong>
<strong><em>and call its <a href="http://api.openoffice.org/docs/common/ref/com/sun/star/text/GenericTextDocument.html#WordCount" rel="nofollow">word-count function</a></em></strong></p>
<p><a href="http://www.artofsolving.com/opensource/pyodconverter" rel="nof... | 3 | 2010-02-13T11:45:40Z | [
"python",
"document",
"openoffice.org",
"word-count"
] |
Review Website In Python. Is django right for this? | 2,256,892 | <p>Basically, I misread this but would still really appreciate some assurance. I recently came across the django tutorial (http://djangotutorial.com) and have fell in love with the framework. I have a website that is simply ran on wordpress and a simple plugin at the moment at <a href="http://runningshoesreview.org" re... | 0 | 2010-02-13T08:04:02Z | 2,256,904 | <p>Django is a general-purpose framework and is perfectly fine for your intended uses, although probably an overkill, since adding these features to WordPress is likely simpler, especially if your host doesn't support Python and you'd have to move hosts.</p>
<p>As for the comment you quotes, it simply means that you s... | 0 | 2010-02-13T08:08:43Z | [
"python",
"django"
] |
Review Website In Python. Is django right for this? | 2,256,892 | <p>Basically, I misread this but would still really appreciate some assurance. I recently came across the django tutorial (http://djangotutorial.com) and have fell in love with the framework. I have a website that is simply ran on wordpress and a simple plugin at the moment at <a href="http://runningshoesreview.org" re... | 0 | 2010-02-13T08:04:02Z | 2,256,933 | <p>Django provides an automatically generated admin interface for your models. For your blog you can use this admin interface to create new posts, moderate comments and so on.</p>
<p>However, you should not allow your users to access this interface for security reasons, so when you want normal users to create comments... | 1 | 2010-02-13T08:22:23Z | [
"python",
"django"
] |
Review Website In Python. Is django right for this? | 2,256,892 | <p>Basically, I misread this but would still really appreciate some assurance. I recently came across the django tutorial (http://djangotutorial.com) and have fell in love with the framework. I have a website that is simply ran on wordpress and a simple plugin at the moment at <a href="http://runningshoesreview.org" re... | 0 | 2010-02-13T08:04:02Z | 2,256,973 | <p>The Django admin is for administrator use only.
You could use this for moderation and general admin tasks.</p>
<p>You would create a different interface using django for your users.
Django would be a great framework for your app. I'm developing a service with it now.</p>
<p>There are other great frameworks out the... | 3 | 2010-02-13T08:40:25Z | [
"python",
"django"
] |
Review Website In Python. Is django right for this? | 2,256,892 | <p>Basically, I misread this but would still really appreciate some assurance. I recently came across the django tutorial (http://djangotutorial.com) and have fell in love with the framework. I have a website that is simply ran on wordpress and a simple plugin at the moment at <a href="http://runningshoesreview.org" re... | 0 | 2010-02-13T08:04:02Z | 2,257,108 | <p>Read the first few chapters of <a href="http://www.djangobook.com/en/2.0/" rel="nofollow">The Django Book</a> to give you an idea of how Django works - won't take you long and will open your eyes to the possibilities.</p>
| 1 | 2010-02-13T09:43:45Z | [
"python",
"django"
] |
Review Website In Python. Is django right for this? | 2,256,892 | <p>Basically, I misread this but would still really appreciate some assurance. I recently came across the django tutorial (http://djangotutorial.com) and have fell in love with the framework. I have a website that is simply ran on wordpress and a simple plugin at the moment at <a href="http://runningshoesreview.org" re... | 0 | 2010-02-13T08:04:02Z | 2,257,736 | <p>The django admin area is a backend, an area you have to login first. So it's not the typical website approach for a public review site.
After a user logs in you can restrict the database access (=model editing) to certain parts, but you can't avoid people DROPing the whole content of smth. they have access to.
There... | 0 | 2010-02-13T13:48:11Z | [
"python",
"django"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.