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 |
|---|---|---|---|---|---|---|---|---|---|
Strip all non-numeric characters (except for ".") from a string in Python | 947,776 | <p>I've got a pretty good working snippit of code, but I was wondering if anyone has any better suggestions on how to do this:</p>
<pre><code>val = ''.join([c for c in val if c in '1234567890.'])
</code></pre>
<p>What would you do?</p>
| 37 | 2009-06-03T23:12:00Z | 951,765 | <p>If the set of characters were larger, using sets as below might be faster. As it is, this is a bit slower than a.py.</p>
<pre><code>dec = set('1234567890.')
a = '27893jkasnf8u2qrtq2ntkjh8934yt8.298222rwagasjkijw'
for i in xrange(1000000):
''.join(ch for ch in a if ch in dec)</code></pre>
<p>At least on my sys... | 2 | 2009-06-04T16:49:37Z | [
"python"
] |
Strip all non-numeric characters (except for ".") from a string in Python | 947,776 | <p>I've got a pretty good working snippit of code, but I was wondering if anyone has any better suggestions on how to do this:</p>
<pre><code>val = ''.join([c for c in val if c in '1234567890.'])
</code></pre>
<p>What would you do?</p>
| 37 | 2009-06-03T23:12:00Z | 8,718,713 | <pre><code>import string
filter(lambda c: c in string.digits + '.', s)
</code></pre>
| 2 | 2012-01-03T21:15:16Z | [
"python"
] |
Strip all non-numeric characters (except for ".") from a string in Python | 947,776 | <p>I've got a pretty good working snippit of code, but I was wondering if anyone has any better suggestions on how to do this:</p>
<pre><code>val = ''.join([c for c in val if c in '1234567890.'])
</code></pre>
<p>What would you do?</p>
| 37 | 2009-06-03T23:12:00Z | 35,552,565 | <p>Mine solution is simpler using regex:</p>
<pre><code>import re
re.sub("[^0-9^.]", "", data)
</code></pre>
| 1 | 2016-02-22T11:34:56Z | [
"python"
] |
How can I get an accurate absolute url from get_absolute_url with an included urls.py in Django? | 947,797 | <p>I've building a app right now that I'm trying to keep properly decoupled from the other apps in my Django project (feel free to lecture me on keeping Django apps decoupled, I'd be happy to learn more any/all the time).</p>
<p>My problem is this: <strong>The get_ absolute_url() method I've written is returning a rel... | 0 | 2009-06-03T23:16:41Z | 948,239 | <p>Welp, </p>
<p>It turns out that when I was seeing this:</p>
<pre><code>/slug-is-here
</code></pre>
<p>I should have looked closer. What was really happening was:</p>
<pre><code>/app-pathslug-is-here
</code></pre>
<p>I was missing a trailing slash on my app's regex in my project urls.py.</p>
<p>So yea. let that... | 0 | 2009-06-04T01:52:26Z | [
"python",
"regex",
"django",
"url",
"models"
] |
How to save a Python interactive session? | 947,810 | <p>I find myself frequently using Python's interpreter to work with databases, files, etc -- basically a lot of manual formatting of semi-structured data. I don't properly save and clean up the useful bits as often as I would like. Is there a way to save my input into the shell (db connections, variable assignments, ... | 240 | 2009-06-03T23:21:02Z | 947,820 | <p>There is a <a href="http://docs.python.org/tutorial/interactive.html?highlight=atexit">way</a> to do it. Store the file in <code>~/.pystartup</code>...</p>
<pre><code># Add auto-completion and a stored history file of commands to your Python
# interactive interpreter. Requires Python 2.0+, readline. Autocomplete is... | 68 | 2009-06-03T23:23:20Z | [
"python",
"shell",
"read-eval-print-loop",
"interactive-session"
] |
How to save a Python interactive session? | 947,810 | <p>I find myself frequently using Python's interpreter to work with databases, files, etc -- basically a lot of manual formatting of semi-structured data. I don't properly save and clean up the useful bits as often as I would like. Is there a way to save my input into the shell (db connections, variable assignments, ... | 240 | 2009-06-03T23:21:02Z | 947,846 | <p><a href="http://ipython.scipy.org/moin/">IPython</a> is extremely useful if you like using interactive sessions. For example for your usecase there is the <em>%save</em> magic command, you just input <em>%save my_useful_session 10-20 23</em> to save input lines 10 to 20 and 23 to my_useful_session.py. (to help with ... | 225 | 2009-06-03T23:34:21Z | [
"python",
"shell",
"read-eval-print-loop",
"interactive-session"
] |
How to save a Python interactive session? | 947,810 | <p>I find myself frequently using Python's interpreter to work with databases, files, etc -- basically a lot of manual formatting of semi-structured data. I don't properly save and clean up the useful bits as often as I would like. Is there a way to save my input into the shell (db connections, variable assignments, ... | 240 | 2009-06-03T23:21:02Z | 948,006 | <p>Also, <a href="http://blog.fishsoup.net/2007/11/10/reinteract-better-interactive-python/">reinteract</a> gives you a notebook-like interface to a Python session.</p>
| 11 | 2009-06-04T00:28:21Z | [
"python",
"shell",
"read-eval-print-loop",
"interactive-session"
] |
How to save a Python interactive session? | 947,810 | <p>I find myself frequently using Python's interpreter to work with databases, files, etc -- basically a lot of manual formatting of semi-structured data. I don't properly save and clean up the useful bits as often as I would like. Is there a way to save my input into the shell (db connections, variable assignments, ... | 240 | 2009-06-03T23:21:02Z | 948,082 | <p>In addition to IPython, a similar utility <a href="http://bpython-interpreter.org/">bpython</a> has a "save the code you've entered to a file" feature</p>
| 11 | 2009-06-04T01:03:36Z | [
"python",
"shell",
"read-eval-print-loop",
"interactive-session"
] |
How to save a Python interactive session? | 947,810 | <p>I find myself frequently using Python's interpreter to work with databases, files, etc -- basically a lot of manual formatting of semi-structured data. I don't properly save and clean up the useful bits as often as I would like. Is there a way to save my input into the shell (db connections, variable assignments, ... | 240 | 2009-06-03T23:21:02Z | 9,593,579 | <p>On windows, PythonWin is a lot more productive than that the default python terminal. It has a lot of features that you usually find in IDEs:</p>
<ul>
<li>save the terminal session to a file</li>
<li>colored syntax highlighting</li>
<li>code completion for classes/properties/variables when you press tab. </li>
<li>... | 0 | 2012-03-06T23:29:00Z | [
"python",
"shell",
"read-eval-print-loop",
"interactive-session"
] |
How to save a Python interactive session? | 947,810 | <p>I find myself frequently using Python's interpreter to work with databases, files, etc -- basically a lot of manual formatting of semi-structured data. I don't properly save and clean up the useful bits as often as I would like. Is there a way to save my input into the shell (db connections, variable assignments, ... | 240 | 2009-06-03T23:21:02Z | 9,720,341 | <p><a href="http://www.andrewhjon.es/save-interactive-python-session-history">http://www.andrewhjon.es/save-interactive-python-session-history</a></p>
<pre><code>import readline
readline.write_history_file('/home/ahj/history')
</code></pre>
| 83 | 2012-03-15T13:06:35Z | [
"python",
"shell",
"read-eval-print-loop",
"interactive-session"
] |
How to save a Python interactive session? | 947,810 | <p>I find myself frequently using Python's interpreter to work with databases, files, etc -- basically a lot of manual formatting of semi-structured data. I don't properly save and clean up the useful bits as often as I would like. Is there a way to save my input into the shell (db connections, variable assignments, ... | 240 | 2009-06-03T23:21:02Z | 10,474,449 | <p>Just putting another suggesting in the bowl:
<a href="https://github.com/spyder-ide/spyder" rel="nofollow">Spyder</a></p>
<p><a href="http://i.stack.imgur.com/kh91E.png" rel="nofollow"><img src="http://i.stack.imgur.com/kh91E.png" alt="enter image description here"></a></p>
<p>It has <em>History log</em> and <em>V... | 1 | 2012-05-06T21:25:47Z | [
"python",
"shell",
"read-eval-print-loop",
"interactive-session"
] |
How to save a Python interactive session? | 947,810 | <p>I find myself frequently using Python's interpreter to work with databases, files, etc -- basically a lot of manual formatting of semi-structured data. I don't properly save and clean up the useful bits as often as I would like. Is there a way to save my input into the shell (db connections, variable assignments, ... | 240 | 2009-06-03T23:21:02Z | 17,325,071 | <p>there is another option --- pyslice.
in the "wxpython 2.8 docs demos and tools", there is a open source program named "pyslices".</p>
<p>you can use it like a editor, and it also support using like a console ---- executing each line like a interactive interpreter with immediate echo.</p>
<p>of course, all the blo... | 1 | 2013-06-26T16:03:33Z | [
"python",
"shell",
"read-eval-print-loop",
"interactive-session"
] |
How to save a Python interactive session? | 947,810 | <p>I find myself frequently using Python's interpreter to work with databases, files, etc -- basically a lot of manual formatting of semi-structured data. I don't properly save and clean up the useful bits as often as I would like. Is there a way to save my input into the shell (db connections, variable assignments, ... | 240 | 2009-06-03T23:21:02Z | 25,447,411 | <p>I had to struggle to find an answer, I was very new to iPython environment.</p>
<p>This will work</p>
<p>If your iPython session looks like this </p>
<pre><code>In [1] : import numpy as np
....
In [135]: counter=collections.Counter(mapusercluster[3])
In [136]: counter
Out[136]: Counter({2: 700, 0: 351, 1: 233})
<... | 2 | 2014-08-22T12:47:02Z | [
"python",
"shell",
"read-eval-print-loop",
"interactive-session"
] |
How to save a Python interactive session? | 947,810 | <p>I find myself frequently using Python's interpreter to work with databases, files, etc -- basically a lot of manual formatting of semi-structured data. I don't properly save and clean up the useful bits as often as I would like. Is there a way to save my input into the shell (db connections, variable assignments, ... | 240 | 2009-06-03T23:21:02Z | 26,663,400 | <p>After installing <a href="http://ipython.org/">Ipython</a>, and opening an Ipython session by running the command:</p>
<pre><code>ipython
</code></pre>
<p>from your command line, just run the following Ipython 'magic' command to automatically log your entire Ipython session:</p>
<pre><code>%logstart
</code></pre... | 6 | 2014-10-30T21:12:47Z | [
"python",
"shell",
"read-eval-print-loop",
"interactive-session"
] |
How to save a Python interactive session? | 947,810 | <p>I find myself frequently using Python's interpreter to work with databases, files, etc -- basically a lot of manual formatting of semi-structured data. I don't properly save and clean up the useful bits as often as I would like. Is there a way to save my input into the shell (db connections, variable assignments, ... | 240 | 2009-06-03T23:21:02Z | 29,974,624 | <p>If you are using <a href="http://ipython.org/">IPython</a> you can save to a file all your previous commands using the magic function <em><a href="http://ipython.org/ipython-doc/2/api/generated/IPython.core.magics.history.html#IPython.core.magics.history.HistoryMagics">%history</a></em> with the <em>-f</em> paramete... | 18 | 2015-04-30T17:56:37Z | [
"python",
"shell",
"read-eval-print-loop",
"interactive-session"
] |
How to save a Python interactive session? | 947,810 | <p>I find myself frequently using Python's interpreter to work with databases, files, etc -- basically a lot of manual formatting of semi-structured data. I don't properly save and clean up the useful bits as often as I would like. Is there a way to save my input into the shell (db connections, variable assignments, ... | 240 | 2009-06-03T23:21:02Z | 35,237,125 | <p>There is %history magic for printing and saving the input history (and optionally the output).</p>
<p>To store your current session to a file named <code>my_history.py</code>:</p>
<pre><code>>>> %hist -f my_history.py
</code></pre>
<p>History IPython stores both the commands you enter, and the results it... | 1 | 2016-02-06T03:48:30Z | [
"python",
"shell",
"read-eval-print-loop",
"interactive-session"
] |
How to save a Python interactive session? | 947,810 | <p>I find myself frequently using Python's interpreter to work with databases, files, etc -- basically a lot of manual formatting of semi-structured data. I don't properly save and clean up the useful bits as often as I would like. Is there a way to save my input into the shell (db connections, variable assignments, ... | 240 | 2009-06-03T23:21:02Z | 37,228,036 | <p>As far as Linux goes, one can use <code>script</code> command to record the whole session. It is part of <code>util-linux</code> package so should be on most Linux systems . You can create and alias or function that will call <code>script -c python</code> and that will be saved to a <code>typescript</code> file. ... | 0 | 2016-05-14T14:45:52Z | [
"python",
"shell",
"read-eval-print-loop",
"interactive-session"
] |
How to save a Python interactive session? | 947,810 | <p>I find myself frequently using Python's interpreter to work with databases, files, etc -- basically a lot of manual formatting of semi-structured data. I don't properly save and clean up the useful bits as often as I would like. Is there a way to save my input into the shell (db connections, variable assignments, ... | 240 | 2009-06-03T23:21:02Z | 38,593,747 | <p>Some comments were asking how to save all of the IPython inputs at once. For %save magic in IPython, you can save all of the commands programmatically as shown below, to avoid the prompt message and also to avoid specifying the input numbers.
currentLine = len(In)-1
%save -f my_session 1-$currentLine</p>
<... | 0 | 2016-07-26T15:14:54Z | [
"python",
"shell",
"read-eval-print-loop",
"interactive-session"
] |
Python Opencv Ubuntu not creating Windows | 947,829 | <p>I have a strange problem with opencv running on an Ubuntu.
I installed OpenCV from the apt sources. And most of the Examples work fine.</p>
<p>But in my programs, which are working with Mac OS, no windows are created.</p>
<p>The following code is showing a window and an image in this on my Mac but not on my Ubuntu... | 1 | 2009-06-03T23:27:53Z | 948,018 | <p>The code works if I add a highgui.cvStartWindowThread() call before creating the window. </p>
<p>Now the next question would be why the program works on mac os without starting the windowThread.</p>
| 3 | 2009-06-04T00:35:26Z | [
"python",
"osx",
"ubuntu",
"opencv"
] |
Python Opencv Ubuntu not creating Windows | 947,829 | <p>I have a strange problem with opencv running on an Ubuntu.
I installed OpenCV from the apt sources. And most of the Examples work fine.</p>
<p>But in my programs, which are working with Mac OS, no windows are created.</p>
<p>The following code is showing a window and an image in this on my Mac but not on my Ubuntu... | 1 | 2009-06-03T23:27:53Z | 11,784,815 | <p>For the new binding, I mean <code>cv2</code>. The code is <code>cv2.startWindowThread()</code></p>
| 0 | 2012-08-02T19:55:29Z | [
"python",
"osx",
"ubuntu",
"opencv"
] |
If slicing does not create a copy of a list nor does list() how can I get a real copy of my list? | 948,032 | <p>I am trying to modify a list and since my modifications were getting a bit tricky and my list large I took a slice of my list using the following code</p>
<pre><code>tempList=origList[0:10]
for item in tempList:
item[-1].insert(0 , item[1])
del item[1]
</code></pre>
<p>I did this thinking that all of the m... | 9 | 2009-06-04T00:40:53Z | 948,049 | <p>Slicing creates a shallow copy. In your example, I see that you are calling insert() on item[-1], which means that item is a list of lists. That means that your shallow copies still reference the original objects. You can think of it as making copies of the pointers, not the actual objects.</p>
<p>Your solution lie... | 22 | 2009-06-04T00:48:32Z | [
"python",
"list",
"copy"
] |
If slicing does not create a copy of a list nor does list() how can I get a real copy of my list? | 948,032 | <p>I am trying to modify a list and since my modifications were getting a bit tricky and my list large I took a slice of my list using the following code</p>
<pre><code>tempList=origList[0:10]
for item in tempList:
item[-1].insert(0 , item[1])
del item[1]
</code></pre>
<p>I did this thinking that all of the m... | 9 | 2009-06-04T00:40:53Z | 948,089 | <p>If you copy an object the contents of it are not copied. In probably most cases this is what you want. In your case you have to make sure that the contents are copied by yourself. You could use copy.deepcopy but if you have a list of lists or something similar i would recommend using <code>copy = [l[:] for l in list... | 4 | 2009-06-04T01:04:32Z | [
"python",
"list",
"copy"
] |
Preventing file handle inheritance in multiprocessing lib | 948,119 | <p>Using multiprocessing on windows it appears that any open file handles are inherited by spawned processes. This has the unpleasant side effect of locking them.</p>
<p>I'm interested in either:<br>
1) Preventing the inheritance<br>
2) A way to release the file from the spawned process</p>
<p>Consider the following... | 11 | 2009-06-04T01:12:51Z | 948,144 | <p>After you open a file handle, you can use the SetHandleInformation() function to remove the <code>HANDLE_FLAG_INHERIT</code> flag.</p>
| 0 | 2009-06-04T01:20:52Z | [
"python",
"windows",
"multiprocessing",
"handle"
] |
Preventing file handle inheritance in multiprocessing lib | 948,119 | <p>Using multiprocessing on windows it appears that any open file handles are inherited by spawned processes. This has the unpleasant side effect of locking them.</p>
<p>I'm interested in either:<br>
1) Preventing the inheritance<br>
2) A way to release the file from the spawned process</p>
<p>Consider the following... | 11 | 2009-06-04T01:12:51Z | 948,214 | <p>I don't know about the <em>multiprocessing</em> module, but with the <a href="http://docs.python.org/library/subprocess.html" rel="nofollow"><em>subprocess</em></a> module you can instruct it to not inherit any file descriptors:</p>
<blockquote>
<p>If close_fds is true, all file descriptors except 0, 1 and 2 will... | 0 | 2009-06-04T01:41:10Z | [
"python",
"windows",
"multiprocessing",
"handle"
] |
Preventing file handle inheritance in multiprocessing lib | 948,119 | <p>Using multiprocessing on windows it appears that any open file handles are inherited by spawned processes. This has the unpleasant side effect of locking them.</p>
<p>I'm interested in either:<br>
1) Preventing the inheritance<br>
2) A way to release the file from the spawned process</p>
<p>Consider the following... | 11 | 2009-06-04T01:12:51Z | 984,238 | <p>The <code>fileno()</code> method returns the file number as assigned by the runtime library. Given the file number, you can then call <code>msvcrt.get_osfhandle()</code> to get the Win32 file handle. Use this handle in the call to <code>SetHandleInformation</code>. So something like the following may work:</p>
<pre... | 4 | 2009-06-11T23:05:35Z | [
"python",
"windows",
"multiprocessing",
"handle"
] |
Preventing file handle inheritance in multiprocessing lib | 948,119 | <p>Using multiprocessing on windows it appears that any open file handles are inherited by spawned processes. This has the unpleasant side effect of locking them.</p>
<p>I'm interested in either:<br>
1) Preventing the inheritance<br>
2) A way to release the file from the spawned process</p>
<p>Consider the following... | 11 | 2009-06-04T01:12:51Z | 36,304,219 | <p>I have encountered this issue when using a rotating log and multiprocessing. When the parent process tries to rotate the log, it fails with a </p>
<blockquote>
<p>WindowsError: [Error 32] The process cannot access the file because it is being used by another process</p>
</blockquote>
<p>based on some of the othe... | 0 | 2016-03-30T09:04:36Z | [
"python",
"windows",
"multiprocessing",
"handle"
] |
Sqlalchemy complex in_ clause | 948,212 | <p>I'm trying to find a way to cause sqlalchemy to generate sql of the following form:</p>
<pre>
select * from t where (a,b) in ((a1,b1),(a2,b2));
</pre>
<p>Is this possible?</p>
<p>If not, any suggestions on a way to emulate it?</p>
<p>Thanks kindly!</p>
| 6 | 2009-06-04T01:40:38Z | 948,342 | <p>Standard caveat: I'm no expert in the large and twisty ecosystem that is SQLAlchemy.</p>
<p>So let's say you have a Table named <code>stocks</code> and a Session named <code>session</code>. Then the query would just be something like</p>
<pre><code>x = "(stocks.person, stocks.number) IN ((100, 100), (200, 200))"
s... | 4 | 2009-06-04T02:44:04Z | [
"python",
"sql",
"sqlalchemy"
] |
Sqlalchemy complex in_ clause | 948,212 | <p>I'm trying to find a way to cause sqlalchemy to generate sql of the following form:</p>
<pre>
select * from t where (a,b) in ((a1,b1),(a2,b2));
</pre>
<p>Is this possible?</p>
<p>If not, any suggestions on a way to emulate it?</p>
<p>Thanks kindly!</p>
| 6 | 2009-06-04T01:40:38Z | 951,640 | <p>Well, thanks to Hao Lian above, I came up with a functional if painful solution.</p>
<p>Assume that we have a declarative-style mapped class, <code>Clazz</code>, and a <code>list</code> of tuples of compound primary key values, <code>values</code>
(Edited to use a better (IMO) sql generation style):</p>
<pre>
from... | 3 | 2009-06-04T16:25:35Z | [
"python",
"sql",
"sqlalchemy"
] |
Sqlalchemy complex in_ clause | 948,212 | <p>I'm trying to find a way to cause sqlalchemy to generate sql of the following form:</p>
<pre>
select * from t where (a,b) in ((a1,b1),(a2,b2));
</pre>
<p>Is this possible?</p>
<p>If not, any suggestions on a way to emulate it?</p>
<p>Thanks kindly!</p>
| 6 | 2009-06-04T01:40:38Z | 2,563,927 | <p>see the <a href="http://www.sqlalchemy.org/docs/reference/sqlalchemy/expressions.html?highlight=tuple#sqlalchemy.sql.expression.tuple_" rel="nofollow">tuple_ construct</a> in SQLAlchemy 0.6</p>
| 2 | 2010-04-01T21:51:20Z | [
"python",
"sql",
"sqlalchemy"
] |
Sqlalchemy complex in_ clause | 948,212 | <p>I'm trying to find a way to cause sqlalchemy to generate sql of the following form:</p>
<pre>
select * from t where (a,b) in ((a1,b1),(a2,b2));
</pre>
<p>Is this possible?</p>
<p>If not, any suggestions on a way to emulate it?</p>
<p>Thanks kindly!</p>
| 6 | 2009-06-04T01:40:38Z | 6,724,961 | <p>Use tuple_</p>
<pre><code>keys = [(a1, b1), (a2, b2)]
session.query(T).filter(tuple_(T.a, T.b).in_(keys)).all()
</code></pre>
<p><a href="http://www.sqlalchemy.org/docs/core/expression_api.html">http://www.sqlalchemy.org/docs/core/expression_api.html</a> => Look for tuple_</p>
| 16 | 2011-07-17T15:48:17Z | [
"python",
"sql",
"sqlalchemy"
] |
method for creating a unique validation key/number | 948,493 | <p>I'm using django for a web-magazine with subscriber-content. when a user purchases a subscription, the site will create a validation key, and send it to the user email address.
The validation key would be added to a list of "valid keys" until it is used.</p>
<p>What is the best method for creating a simple yet uni... | 2 | 2009-06-04T03:42:26Z | 948,499 | <p>I'd recommend using a GUID. They are quickly becoming industry standard for this kind of thing.</p>
<p>See how to create them here: <a href="http://stackoverflow.com/questions/534839/how-to-create-a-guid-in-python">http://stackoverflow.com/questions/534839/how-to-create-a-guid-in-python</a></p>
| 2 | 2009-06-04T03:44:46Z | [
"python",
"django",
"validation"
] |
method for creating a unique validation key/number | 948,493 | <p>I'm using django for a web-magazine with subscriber-content. when a user purchases a subscription, the site will create a validation key, and send it to the user email address.
The validation key would be added to a list of "valid keys" until it is used.</p>
<p>What is the best method for creating a simple yet uni... | 2 | 2009-06-04T03:42:26Z | 948,500 | <p>Well, you can always use a GUID. As you said it would be stored as a valid key.</p>
| 0 | 2009-06-04T03:45:05Z | [
"python",
"django",
"validation"
] |
method for creating a unique validation key/number | 948,493 | <p>I'm using django for a web-magazine with subscriber-content. when a user purchases a subscription, the site will create a validation key, and send it to the user email address.
The validation key would be added to a list of "valid keys" until it is used.</p>
<p>What is the best method for creating a simple yet uni... | 2 | 2009-06-04T03:42:26Z | 948,513 | <p>As other posters mentioned, you are looking for a GUID, of which the most popular implemntation UUID (see <a href="http://en.wikipedia.org/wiki/Universally%5FUnique%5FIdentifier" rel="nofollow">here</a>) . Django extensions (see <a href="http://code.google.com/p/django-command-extensions/" rel="nofollow">here</a>) o... | 2 | 2009-06-04T03:49:37Z | [
"python",
"django",
"validation"
] |
IMAP4_SSL with gmail in python | 948,761 | <p>We are retrieving mails from our gmail account using IMAP4_SSL and python.
The email body is retrieved in html format.
We need to convert that to plaintext.
Can anyone help us with that?</p>
| 0 | 2009-06-04T05:49:24Z | 948,805 | <p>Stand on the shoulders of giants...<br />
Peter Bengtsson has worked out a solution to this exact problem <a href="http://www.peterbe.com/plog/html2plaintext" rel="nofollow">here</a>.<br />
Peter's script uses the awesome <a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">BeautifulSoup</a>, by Le... | 2 | 2009-06-04T06:05:17Z | [
"python",
"html",
"gmail"
] |
Python web framework with low barrier to entry | 948,815 | <p>I am looking for a LAMPish/WAMPish experience.</p>
<p>Something very transparent. Write the script, hit F5 and see the results. Very little, if any abstraction.
SQLAlchemy and (maybe) some simple templating engine will be used.</p>
<p>I need simple access to the environment - similar to the PHP way. Something like... | 4 | 2009-06-04T06:09:54Z | 948,836 | <p>Look at:</p>
<ul>
<li><a href="http://www.wsgi.org/wsgi/" rel="nofollow">WSGI</a>, the standard Python API for HTTP servers to call Python code.</li>
<li><a href="http://www.djangoproject.com/" rel="nofollow">Django</a>, a popular, feature-rich, well documented Python web framework</li>
<li><a href="http://webpy.or... | 1 | 2009-06-04T06:18:12Z | [
"python"
] |
Python web framework with low barrier to entry | 948,815 | <p>I am looking for a LAMPish/WAMPish experience.</p>
<p>Something very transparent. Write the script, hit F5 and see the results. Very little, if any abstraction.
SQLAlchemy and (maybe) some simple templating engine will be used.</p>
<p>I need simple access to the environment - similar to the PHP way. Something like... | 4 | 2009-06-04T06:09:54Z | 948,841 | <p>Have you looked into the <a href="http://djangoproject.com" rel="nofollow">Django</a> web framework? Its an MVC framework written in python, and is relatively simple to set up and get started. You can run it with nothing but python, as it can use SQLite and its own development server, or you can set it up to use M... | 1 | 2009-06-04T06:19:28Z | [
"python"
] |
Python web framework with low barrier to entry | 948,815 | <p>I am looking for a LAMPish/WAMPish experience.</p>
<p>Something very transparent. Write the script, hit F5 and see the results. Very little, if any abstraction.
SQLAlchemy and (maybe) some simple templating engine will be used.</p>
<p>I need simple access to the environment - similar to the PHP way. Something like... | 4 | 2009-06-04T06:09:54Z | 948,927 | <p><a href="http://cherrypy.org" rel="nofollow">CherryPy</a> might be what you need. It transparently maps URLs onto Python functions, and handles all the cookie and session stuff (and of course the POST / GET parameters for you).</p>
<p>It's not a full-stack solution like Django or Rails. On the other hand, that me... | 6 | 2009-06-04T06:45:13Z | [
"python"
] |
Python web framework with low barrier to entry | 948,815 | <p>I am looking for a LAMPish/WAMPish experience.</p>
<p>Something very transparent. Write the script, hit F5 and see the results. Very little, if any abstraction.
SQLAlchemy and (maybe) some simple templating engine will be used.</p>
<p>I need simple access to the environment - similar to the PHP way. Something like... | 4 | 2009-06-04T06:09:54Z | 948,972 | <p>What you're describing most resembles <a href="http://pylonshq.com/" rel="nofollow">Pylons</a>, it seems to me. However, the number of web frameworks in/for Python is huge -- see <a href="http://wiki.python.org/moin/WebFrameworks" rel="nofollow">this page</a> for an attempt to list and VERY briefly characterize eac... | 5 | 2009-06-04T06:57:27Z | [
"python"
] |
Python web framework with low barrier to entry | 948,815 | <p>I am looking for a LAMPish/WAMPish experience.</p>
<p>Something very transparent. Write the script, hit F5 and see the results. Very little, if any abstraction.
SQLAlchemy and (maybe) some simple templating engine will be used.</p>
<p>I need simple access to the environment - similar to the PHP way. Something like... | 4 | 2009-06-04T06:09:54Z | 1,267,400 | <p>For low barrier to entry, <a href="http://webpy.org/" rel="nofollow">web.py</a> is very very light and simple. </p>
<p>Features:</p>
<ul>
<li>easy (dev) deploy... copy web.py folder into your app directory, then start the server</li>
<li>regex-based url mapping</li>
<li>very simple class mappings</li>
<li>built-in... | 5 | 2009-08-12T16:55:35Z | [
"python"
] |
Python web framework with low barrier to entry | 948,815 | <p>I am looking for a LAMPish/WAMPish experience.</p>
<p>Something very transparent. Write the script, hit F5 and see the results. Very little, if any abstraction.
SQLAlchemy and (maybe) some simple templating engine will be used.</p>
<p>I need simple access to the environment - similar to the PHP way. Something like... | 4 | 2009-06-04T06:09:54Z | 1,522,835 | <p>Check out <a href="http://web2py.com/" rel="nofollow">web2py</a>. It runs out of the box with no configuration - even from a USB stick. The template language is pure Python and you can develop your entire app through the browser editor (although I find vim faster ;)</p>
| 0 | 2009-10-05T22:57:27Z | [
"python"
] |
Python web framework with low barrier to entry | 948,815 | <p>I am looking for a LAMPish/WAMPish experience.</p>
<p>Something very transparent. Write the script, hit F5 and see the results. Very little, if any abstraction.
SQLAlchemy and (maybe) some simple templating engine will be used.</p>
<p>I need simple access to the environment - similar to the PHP way. Something like... | 4 | 2009-06-04T06:09:54Z | 1,993,396 | <p>Don't forget <a href="http://bottle.paws.de" rel="nofollow">Bottle</a>. It is a single-file micro web framework with no dependencies and very easy to use. Here is an "Hello world" example:</p>
<pre><code>from bottle import route, run
@route('/')
def index():
return 'Hello World!'
run(host='localhost', port=8080... | 1 | 2010-01-03T00:08:06Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 949,110 | <p><strong>First go</strong> (pre-OP-edit): Use sets:</p>
<pre><code>mylist = [1,2,3,4,5,6,7]
goodvals = [1,3,7,8,9]
myset = set(mylist)
goodset = set(goodvals)
print list(myset.intersection(goodset)) # [1, 3, 7]
print list(myset.difference(goodset)) # [2, 4, 5, 6]
</code></pre>
<p>That's good for both readabil... | 13 | 2009-06-04T07:41:20Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 949,121 | <p>Personally, I like the version you cited, assuming you already have a list of <code>goodvals</code> hanging around. If not, something like:</p>
<pre><code>good = filter(lambda x: is_good(x), mylist)
bad = filter(lambda x: not is_good(x), mylist)
</code></pre>
<p>Of course, that's really very similar to using a li... | 5 | 2009-06-04T07:45:43Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 949,139 | <p>For perfomance, try <code>itertools</code>.</p>
<blockquote>
<p>The <a href="http://docs.python.org/library/itertools.html" rel="nofollow">itertools</a> module standardizes a core set of fast, memory efficient tools that are useful by themselves or in combination. Together, they form an âiterator algebraâ mak... | 1 | 2009-06-04T07:51:54Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 949,191 | <p>Problem with all proposed solutions is that it will scan and apply the filtering function twice. I'd make a simple small function like this:</p>
<pre><code>def SplitIntoTwoLists(l, f):
a = []
b = []
for i in l:
if f(i):
a.append(i)
else:
b.append(i)
return (a,b)
</code></pre>
<p>That way... | 20 | 2009-06-04T08:10:50Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 949,490 | <p>Here's the lazy iterator approach:</p>
<pre><code>from itertools import tee
def split_on_condition(seq, condition):
l1, l2 = tee((condition(item), item) for item in seq)
return (i for p, i in l1 if p), (i for p, i in l2 if not p)
</code></pre>
<p>It evaluates the condition once per item and returns two ge... | 72 | 2009-06-04T09:32:23Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 950,207 | <p>If you insist on clever, you could take Winden's solution and just a bit spurious cleverness:</p>
<pre><code>def splay(l, f, d=None):
d = d or {}
for x in l: d.setdefault(f(x), []).append(x)
return d
</code></pre>
| 0 | 2009-06-04T12:25:01Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 950,591 | <blockquote>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way to do this?</p>
</blockquote>
<p>That code is perfectly readable, and extremely clear!</p>
<pre><code># files looks like: [ ('file1.jpg', 33L, '.jpg'), ... | 63 | 2009-06-04T13:28:23Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 950,631 | <p><a href="http://docs.python.org/library/itertools.html#itertools.groupby">itertools.groupby</a> almost does what you want, except it requires the items to be sorted to ensure that you get a single contiguous range, so you need to sort by your key first (otherwise you'll get multiple interleaved groups for each type)... | 6 | 2009-06-04T13:34:29Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 2,799,738 | <p>If you want to make it in FP style:</p>
<pre><code>good, bad = [ sum(x, []) for x in zip(*(([y], []) if y in goodvals else ([], [y])
for y in mylist)) ]
</code></pre>
<p>Not the most readable solution, but at least iterates through mylist only once.</p>
| 3 | 2010-05-10T00:28:43Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 3,281,886 | <p>I basically like Anders' approach as it is very general. Here's a version that puts the categorizer first (to match filter syntax) and uses a defaultdict (assumed imported).</p>
<pre><code>def categorize(func, seq):
"""Return mapping from categories to lists
of categorized items.
"""
d = defaultdic... | 9 | 2010-07-19T14:20:02Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 5,859,746 | <p>Sometimes you won't need that other half of the list.
For example:</p>
<pre><code>import sys
from itertools import ifilter
trustedPeople = sys.argv[1].split(',')
newName = sys.argv[2]
myFriends = ifilter(lambda x: x.startswith('Shi'), trustedPeople)
print '%s is %smy friend.' % (newName, newName not in myFriends... | 1 | 2011-05-02T16:33:47Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 7,881,048 | <p>My take on it. I propose a lazy, single-pass, <code>partition</code> function,
which preserves relative order in the output subsequences.</p>
<h2>1. Requirements</h2>
<p>I assume that the requirements are:</p>
<ul>
<li>maintain elements' relative order (hence, no sets and
dictionaries)</li>
<li>evaluate condition... | 13 | 2011-10-24T19:42:33Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 10,456,007 | <p>If your concern is not to use two lines of code for an operation whose semantics only need once you just wrap some of the approaches above (even your own) in a single function:</p>
<pre><code>def part_with_predicate(l, pred):
return [i for i in l if pred(i)], [i for i in l if not pred(i)]
</code></pre>
<p>It i... | 0 | 2012-05-04T20:53:55Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 12,135,169 | <pre><code>good, bad = [], []
for x in mylist:
(bad, good)[x in goodvals].append(x)
</code></pre>
| 100 | 2012-08-27T00:51:47Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 15,407,422 | <p>Inspired by @gnibbler's <a href="http://stackoverflow.com/a/12135169/182469">great (but terse!) answer</a>, we can apply that approach to map to multiple partitions:</p>
<pre><code>from collections import defaultdict
def splitter(l, mapper):
"""Split an iterable into multiple partitions generated by a callable... | 0 | 2013-03-14T11:03:24Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 20,492,553 | <pre><code>def partition(pred, seq):
return reduce( lambda (yes, no), x: (yes+[x], no) if pred(x) else (yes, no+[x]), seq, ([], []) )
</code></pre>
| -1 | 2013-12-10T10:56:11Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 22,264,716 | <p>Already quite a few solutions here, but yet another way of doing that would be -</p>
<pre><code>anims = []
images = [f for f in files if (lambda t: True if f[2].lower() in IMAGE_TYPES else anims.append(t) and False)(f)]
</code></pre>
<p>Iterates over the list only once, and looks a bit more pythonic and hence read... | 0 | 2014-03-08T03:40:43Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 27,517,204 | <p>I'd take a 2-pass approach, separating evaluation of the predicate from filtering the list:</p>
<pre><code>def partition(pred, iterable):
xs = list(zip(map(pred, iterable), iterable))
return [x[1] for x in xs if x[0]], [x[1] for x in xs if not x[0]]
</code></pre>
<p>What's nice about this, performance-wise... | 0 | 2014-12-17T02:00:27Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 28,692,091 | <pre><code>def partition(pred, iterable):
'Use a predicate to partition entries into false entries and true entries'
# partition(is_odd, range(10)) --> 0 2 4 6 8 and 1 3 5 7 9
t1, t2 = tee(iterable)
return filterfalse(pred, t1), filter(pred, t2)
</code></pre>
<p>Check <a href="https://docs.python... | 3 | 2015-02-24T09:26:53Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 29,913,433 | <h1>solution</h1>
<pre><code>from itertools import tee
def unpack_args(fn):
return lambda t: fn(*t)
def separate(fn, lx):
return map(
unpack_args(
lambda i, ly: filter(
lambda el: bool(i) == fn(el),
ly)),
enumerate(tee(lx, 2)))
</code></pre>
<h1>te... | 0 | 2015-04-28T07:49:17Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 29,990,598 | <p>I think a generalization of splitting a an iterable based on N conditions is handy</p>
<pre><code>from collections import OrderedDict
def partition(iterable,*conditions):
'''Returns a list with the elements that satisfy each of condition.
Conditions are assumed to be exclusive'''
d= OrderedDict((i,li... | 3 | 2015-05-01T16:08:09Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 31,448,772 | <p>Sometimes, it looks like list comprehension is not the best thing to use !</p>
<p>I made a little test based on the answer people gave to this topic, tested on a random generated list. Here is the generation of the list (there's probably a better way to do, but it's not the point) :</p>
<pre><code>good_list = ('.j... | 1 | 2015-07-16T08:12:37Z | [
"python"
] |
Python: split a list based on a condition? | 949,098 | <p>What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:</p>
<pre><code>good = [x for x in mylist if x in goodvals]
bad = [x for x in mylist if x not in goodvals]
</code></pre>
<p>is there a more elegant way... | 132 | 2009-06-04T07:37:18Z | 31,562,455 | <p>Yet another solution to this problem. I needed a solution that is as fast as possible. That means only one iteration over the list and preferably O(1) for adding data to one of the resulting lists. This is very similar to the solution provided by <em>sastanin</em>, except much shorter:</p>
<pre><code>from collectio... | 1 | 2015-07-22T11:58:18Z | [
"python"
] |
ODFPy documentation | 949,171 | <p>I need to manipulate the ODF file format (open document format, the open office's internal format), and I need to do it in Python.</p>
<p>It seem's ODFPy is a wonderful library for this purpose. Unfortunately the official documentation is very poor, almost unuseful. I can't find almost anything online - maybe it is... | 13 | 2009-06-04T08:03:41Z | 950,025 | <p>Okay, here's a quick help:</p>
<ol>
<li><p>Grab odfpy source code:</p>
<pre><code>~$ svn checkout https://svn.forge.osor.eu/svn/odfpy/trunk odfpy
</code></pre></li>
<li><p>Install it:</p>
<pre><code> ~$ cd odfpy
~/odfpy$ python setup.py install
</code></pre></li>
<li><p>Generate the documentation:</p>
<pre><cod... | -1 | 2009-06-04T11:45:14Z | [
"python",
"openoffice.org",
"odf"
] |
ODFPy documentation | 949,171 | <p>I need to manipulate the ODF file format (open document format, the open office's internal format), and I need to do it in Python.</p>
<p>It seem's ODFPy is a wonderful library for this purpose. Unfortunately the official documentation is very poor, almost unuseful. I can't find almost anything online - maybe it is... | 13 | 2009-06-04T08:03:41Z | 2,183,603 | <p>The documentation is unfortunately horrible, and the generated Python wrapper is lousily documented in code, providing lots of functions whose argument lists look like func(*args).</p>
<p>The reference manual <em>is</em> actually useful, but not when you're starting out - it doesn't provide any context of how to us... | 7 | 2010-02-02T11:26:47Z | [
"python",
"openoffice.org",
"odf"
] |
ODFPy documentation | 949,171 | <p>I need to manipulate the ODF file format (open document format, the open office's internal format), and I need to do it in Python.</p>
<p>It seem's ODFPy is a wonderful library for this purpose. Unfortunately the official documentation is very poor, almost unuseful. I can't find almost anything online - maybe it is... | 13 | 2009-06-04T08:03:41Z | 12,596,531 | <p>try <a href="http://pypi.python.org/pypi/ezodf/0.2.1" rel="nofollow">ezodf</a>
they also have a <a href="http://packages.python.org/ezodf/" rel="nofollow">doc</a></p>
| 1 | 2012-09-26T07:19:17Z | [
"python",
"openoffice.org",
"odf"
] |
ODFPy documentation | 949,171 | <p>I need to manipulate the ODF file format (open document format, the open office's internal format), and I need to do it in Python.</p>
<p>It seem's ODFPy is a wonderful library for this purpose. Unfortunately the official documentation is very poor, almost unuseful. I can't find almost anything online - maybe it is... | 13 | 2009-06-04T08:03:41Z | 14,034,221 | <p>I found more documentation (the web site has been reorganized in the past few years) in <a href="https://joinup.ec.europa.eu/sites/default/files/api-for-odfpy.odt" rel="nofollow">api-for-odfpy.odt</a>.</p>
| 2 | 2012-12-25T21:47:02Z | [
"python",
"openoffice.org",
"odf"
] |
ODFPy documentation | 949,171 | <p>I need to manipulate the ODF file format (open document format, the open office's internal format), and I need to do it in Python.</p>
<p>It seem's ODFPy is a wonderful library for this purpose. Unfortunately the official documentation is very poor, almost unuseful. I can't find almost anything online - maybe it is... | 13 | 2009-06-04T08:03:41Z | 19,583,120 | <p>There's a good example of odfpy usage at <a href="http://mashupguide.net/1.0/html/ch17s04.xhtml" rel="nofollow">http://mashupguide.net/1.0/html/ch17s04.xhtml</a></p>
| 4 | 2013-10-25T06:59:24Z | [
"python",
"openoffice.org",
"odf"
] |
ODFPy documentation | 949,171 | <p>I need to manipulate the ODF file format (open document format, the open office's internal format), and I need to do it in Python.</p>
<p>It seem's ODFPy is a wonderful library for this purpose. Unfortunately the official documentation is very poor, almost unuseful. I can't find almost anything online - maybe it is... | 13 | 2009-06-04T08:03:41Z | 28,577,394 | <p>It's outdated, a bit, but could help someone.
I have found only one way to work with ODFPY:</p>
<ol>
<li>generate your ODF document (i.e. f1.ods)</li>
<li>make copy of it and edit in LibreOffice/OpenOffice or other (i.e. f2.odf)</li>
<li>change both files to f1.zip and f2.zip</li>
<li>extract both files.</li>
</ol>... | 1 | 2015-02-18T06:31:49Z | [
"python",
"openoffice.org",
"odf"
] |
How do I infer the class to which a @staticmethod belongs? | 949,259 | <p>I am trying to implement <code>infer_class</code> function that, given a method, figures out the class to which the method belongs.</p>
<p>So far I have something like this:</p>
<pre><code>import inspect
def infer_class(f):
if inspect.ismethod(f):
return f.im_self if f.im_class == type else f.im_class... | 4 | 2009-06-04T08:30:23Z | 949,407 | <p>That's because staticmethods really aren't methods. The staticmethod descriptor returns the original function as is. There is no way to get the class via which the function was accessed. But there is no real reason to use staticmethods for methods anyway, always use classmethods.</p>
<p>The only use that I have fou... | 3 | 2009-06-04T09:09:15Z | [
"python",
"decorator",
"static-methods",
"inspect"
] |
How do I infer the class to which a @staticmethod belongs? | 949,259 | <p>I am trying to implement <code>infer_class</code> function that, given a method, figures out the class to which the method belongs.</p>
<p>So far I have something like this:</p>
<pre><code>import inspect
def infer_class(f):
if inspect.ismethod(f):
return f.im_self if f.im_class == type else f.im_class... | 4 | 2009-06-04T08:30:23Z | 966,095 | <p>I have trouble bringing myself to actually <em>recommend</em> this, but it does seem to work for straightforward cases, at least:</p>
<pre><code>import inspect
def crack_staticmethod(sm):
"""
Returns (class, attribute name) for `sm` if `sm` is a
@staticmethod.
"""
mod = inspect.getmodule(sm)
... | 3 | 2009-06-08T17:55:32Z | [
"python",
"decorator",
"static-methods",
"inspect"
] |
Terminating a Python Program | 949,504 | <p>What command do you use in python to terminate a program?</p>
<p>i.e. the equivalent of "end" in basic, or "quit" in BASH.</p>
<p>I see that "break" takes you out of a loop, and "quit" is all tied up with "class" stuff that I do not comprehend yet.
i tried </p>
<pre><code>import sys
sys.exit()
</code></pre>
<p>b... | 4 | 2009-06-04T09:35:06Z | 949,519 | <p>sys.exit(error_code) </p>
<p>Error_code will be 0 for a normal exit, 1 or some other positive number for an exit due to an error of some kind, e.g. the user has entered the wrong parameters.</p>
<p>sys.exit() "is undefined on some architectures", (although it worked when I tried it on my Linux box!)</p>
<p>The ... | 8 | 2009-06-04T09:37:34Z | [
"python"
] |
Terminating a Python Program | 949,504 | <p>What command do you use in python to terminate a program?</p>
<p>i.e. the equivalent of "end" in basic, or "quit" in BASH.</p>
<p>I see that "break" takes you out of a loop, and "quit" is all tied up with "class" stuff that I do not comprehend yet.
i tried </p>
<pre><code>import sys
sys.exit()
</code></pre>
<p>b... | 4 | 2009-06-04T09:35:06Z | 949,520 | <p>Try running a python interpreter out of your IDE. In my Windows installation the simple command line <code>python.exe</code>, both options work:</p>
<pre><code>>>> import sys
>>> sys.exit()
</code></pre>
<p>or</p>
<pre><code>>>> raise SystemExit
</code></pre>
| 0 | 2009-06-04T09:37:41Z | [
"python"
] |
Terminating a Python Program | 949,504 | <p>What command do you use in python to terminate a program?</p>
<p>i.e. the equivalent of "end" in basic, or "quit" in BASH.</p>
<p>I see that "break" takes you out of a loop, and "quit" is all tied up with "class" stuff that I do not comprehend yet.
i tried </p>
<pre><code>import sys
sys.exit()
</code></pre>
<p>b... | 4 | 2009-06-04T09:35:06Z | 949,923 | <p><code>sys.exit()</code> raises the <code>SystemExit</code> exception.</p>
<p>If you don't catch that exception the program ends.</p>
<p>Since you're getting that output, I'm not sure what is happening, but I guess that you're catching all exceptions and printing them yourself:</p>
<pre><code>try:
...
except:
... | 9 | 2009-06-04T11:19:34Z | [
"python"
] |
Terminating a Python Program | 949,504 | <p>What command do you use in python to terminate a program?</p>
<p>i.e. the equivalent of "end" in basic, or "quit" in BASH.</p>
<p>I see that "break" takes you out of a loop, and "quit" is all tied up with "class" stuff that I do not comprehend yet.
i tried </p>
<pre><code>import sys
sys.exit()
</code></pre>
<p>b... | 4 | 2009-06-04T09:35:06Z | 950,152 | <p>import sys</p>
<p>sys.exit(0)</p>
| 1 | 2009-06-04T12:14:30Z | [
"python"
] |
Terminating a Python Program | 949,504 | <p>What command do you use in python to terminate a program?</p>
<p>i.e. the equivalent of "end" in basic, or "quit" in BASH.</p>
<p>I see that "break" takes you out of a loop, and "quit" is all tied up with "class" stuff that I do not comprehend yet.
i tried </p>
<pre><code>import sys
sys.exit()
</code></pre>
<p>b... | 4 | 2009-06-04T09:35:06Z | 953,385 | <p>You should also consider alternatives to exiting directly. Often <code>return</code> works just as well if you wrap code in a function. (Better, in fact, because it avoids sys.exit() weirdness.)</p>
<pre><code>def main():
...do something...
if something:
return # <----- return tak... | 6 | 2009-06-04T22:08:19Z | [
"python"
] |
Terminating a Python Program | 949,504 | <p>What command do you use in python to terminate a program?</p>
<p>i.e. the equivalent of "end" in basic, or "quit" in BASH.</p>
<p>I see that "break" takes you out of a loop, and "quit" is all tied up with "class" stuff that I do not comprehend yet.
i tried </p>
<pre><code>import sys
sys.exit()
</code></pre>
<p>b... | 4 | 2009-06-04T09:35:06Z | 953,495 | <p>In your case, your error is likely that you have a bare except block that is catching the SystemExit exception, like this:</p>
<pre><code>import sys
try:
sys.exit(return_code)
except:
pass
</code></pre>
<p>The correct way to fix your problem is to remove the <strong>except:</strong> portion, and instead just c... | 0 | 2009-06-04T22:44:10Z | [
"python"
] |
Terminating a Python Program | 949,504 | <p>What command do you use in python to terminate a program?</p>
<p>i.e. the equivalent of "end" in basic, or "quit" in BASH.</p>
<p>I see that "break" takes you out of a loop, and "quit" is all tied up with "class" stuff that I do not comprehend yet.
i tried </p>
<pre><code>import sys
sys.exit()
</code></pre>
<p>b... | 4 | 2009-06-04T09:35:06Z | 14,329,160 | <pre><code>sys.exit() #to exit the program
return #to exit from a function
</code></pre>
| 0 | 2013-01-15T00:16:17Z | [
"python"
] |
Python REPL for a running process | 949,784 | <p>I am currently developing a simple application in python that connects to a server. At the moment, it's single-threaded (as multithreading is not currently required).</p>
<p>However I would like - for debugging, maintenance and such to also be able to have a REPL via stdin.</p>
<p>How do I go about that, if possib... | 5 | 2009-06-04T10:42:26Z | 949,847 | <p>You either need to go non-blocking or use a thread.</p>
<p>I would personally use Twisted for concurrency, which also offers a REPL-protocol which is easy to integrate.</p>
| 3 | 2009-06-04T10:56:59Z | [
"python",
"read-eval-print-loop"
] |
Python REPL for a running process | 949,784 | <p>I am currently developing a simple application in python that connects to a server. At the moment, it's single-threaded (as multithreading is not currently required).</p>
<p>However I would like - for debugging, maintenance and such to also be able to have a REPL via stdin.</p>
<p>How do I go about that, if possib... | 5 | 2009-06-04T10:42:26Z | 949,919 | <p>Maybe <a href="http://stackoverflow.com/questions/132058/getting-stack-trace-from-a-running-python-application">this</a> question could help. You can modify it a bit to create a customized REPL.</p>
| 1 | 2009-06-04T11:18:07Z | [
"python",
"read-eval-print-loop"
] |
Python REPL for a running process | 949,784 | <p>I am currently developing a simple application in python that connects to a server. At the moment, it's single-threaded (as multithreading is not currently required).</p>
<p>However I would like - for debugging, maintenance and such to also be able to have a REPL via stdin.</p>
<p>How do I go about that, if possib... | 5 | 2009-06-04T10:42:26Z | 38,931,278 | <p>There's also <a href="https://github.com/aaiyer/rfoo" rel="nofollow">rfoo</a>. From the README:</p>
<blockquote>
<p>rconsole - included with rfoo package is a remote Python console with
auto completion, which can be used to inspect and modify namespace of a
running script.</p>
<p>To activate in a script ... | 0 | 2016-08-13T09:27:57Z | [
"python",
"read-eval-print-loop"
] |
Error trapping when a user inputs incorect information | 949,941 | <p>So, i have recently started learning python...i am writing a small script that pulls information from a csv and i need to be able to notify a user of an incorrect input</p>
<p>for example</p>
<p>the user is asked for his id number, the id number is anything from r1 to r5
i would like my script to be able to tell ... | 0 | 2009-06-04T11:25:16Z | 950,080 | <p>I'm not sure what are you asking for, but if you wish to check if user entered correct id, you should try regular expressions. Look at <a href="http://docs.python.org/library/re.html" rel="nofollow">Python Documentation on module re</a>. Or ask google for "python re"</p>
<p>Here's an example that will check user's ... | 1 | 2009-06-04T11:57:55Z | [
"python",
"csv",
"reporting",
"user-input"
] |
Error trapping when a user inputs incorect information | 949,941 | <p>So, i have recently started learning python...i am writing a small script that pulls information from a csv and i need to be able to notify a user of an incorrect input</p>
<p>for example</p>
<p>the user is asked for his id number, the id number is anything from r1 to r5
i would like my script to be able to tell ... | 0 | 2009-06-04T11:25:16Z | 950,102 | <p>Seriously, read a tutorial. The <a href="http://docs.python.org/tut" rel="nofollow">official</a> one is pretty good. I also like <a href="http://greenteapress.com/thinkpython/thinkpython.html" rel="nofollow">this book</a> for beginners.</p>
<pre><code>import csv
while True:
id_number = raw_input('(enter to qui... | 1 | 2009-06-04T12:03:23Z | [
"python",
"csv",
"reporting",
"user-input"
] |
Referencing a class' method, not an instance's | 950,053 | <p>I'm writing a function that exponentiates an object, i.e. given a and n, returns a<sup>n</sup>. Since a needs not be a built-in type, the function accepts, as a keyword argument, a function to perform multiplications. If undefined, it defaults to the objects <code>__mul__</code> method, i.e. the object itself is exp... | 0 | 2009-06-04T11:53:40Z | 950,139 | <p>I understand it's the sqr-bit at the end you want to fix. If so, I suggest <code>getattr</code>. Example:</p>
<pre><code>class SquarableThingy:
def __init__(self, i):
self.i = i
def squarify(self):
return self.i**2
class MultipliableThingy:
def __init__(self, i):
self.i = i
def __mul__(self, ... | -1 | 2009-06-04T12:12:30Z | [
"python"
] |
Referencing a class' method, not an instance's | 950,053 | <p>I'm writing a function that exponentiates an object, i.e. given a and n, returns a<sup>n</sup>. Since a needs not be a built-in type, the function accepts, as a keyword argument, a function to perform multiplications. If undefined, it defaults to the objects <code>__mul__</code> method, i.e. the object itself is exp... | 0 | 2009-06-04T11:53:40Z | 950,161 | <p>here's how I'd do it:</p>
<pre><code>import operator
def bin_pow(a, n, **kwargs) :
pow_function = kwargs.pop('pow' ,None)
if pow_function is None:
pow_function = operator.pow
return pow_function(a, n)
</code></pre>
<p>That's the fastest way. See also <a href="http://docs.python.org/reference... | 3 | 2009-06-04T12:17:34Z | [
"python"
] |
Referencing a class' method, not an instance's | 950,053 | <p>I'm writing a function that exponentiates an object, i.e. given a and n, returns a<sup>n</sup>. Since a needs not be a built-in type, the function accepts, as a keyword argument, a function to perform multiplications. If undefined, it defaults to the objects <code>__mul__</code> method, i.e. the object itself is exp... | 0 | 2009-06-04T11:53:40Z | 950,166 | <p>If you want to call the class's method, and not the (possibly overridden) instance's method, you can do</p>
<pre><code>instance.__class__.method(instance)
</code></pre>
<p>instead of</p>
<pre><code>instance.method()
</code></pre>
<p>I'm not sure though if that's what you want.</p>
| 1 | 2009-06-04T12:18:19Z | [
"python"
] |
Referencing a class' method, not an instance's | 950,053 | <p>I'm writing a function that exponentiates an object, i.e. given a and n, returns a<sup>n</sup>. Since a needs not be a built-in type, the function accepts, as a keyword argument, a function to perform multiplications. If undefined, it defaults to the objects <code>__mul__</code> method, i.e. the object itself is exp... | 0 | 2009-06-04T11:53:40Z | 950,362 | <p>You can call unbound methods with the instance as the first parameter:</p>
<pre><code>class A(int):
def sqr(self):
return A(self*self)
sqr = A.sqr
a = A(5)
print sqr(a) # Prints 25
</code></pre>
<p>So in your case you don't actually need to do anything specific, just the following:</p>
<pre><code>bin... | 4 | 2009-06-04T12:50:55Z | [
"python"
] |
Referencing a class' method, not an instance's | 950,053 | <p>I'm writing a function that exponentiates an object, i.e. given a and n, returns a<sup>n</sup>. Since a needs not be a built-in type, the function accepts, as a keyword argument, a function to perform multiplications. If undefined, it defaults to the objects <code>__mul__</code> method, i.e. the object itself is exp... | 0 | 2009-06-04T11:53:40Z | 952,533 | <p>If I understand the design goals of the library function, you want to provide a library "power" function which will raise any object passed to it to the Nth power. But you also want to provide a "shortcut" for efficiency.</p>
<p>The design goals seem a little odd--Python already defines the <strong>mul</strong> me... | 0 | 2009-06-04T19:13:58Z | [
"python"
] |
Embedding a 3-D editor (such as Blender) in a wxPython application | 950,145 | <p>Is it possible to embed a 3-D editor inside my wxPython application? (I'm thinking Blender, but other suggestions are welcome.)</p>
<p>My application opens a wxPython window, and I want to have a 3-D editor inside of it. Of course, I want my program and the 3-D editor to interact with each other.</p>
<p>Possible? ... | 1 | 2009-06-04T12:13:25Z | 950,177 | <p>For <a href="http://www.blender.org" rel="nofollow">Blender</a> specifically, I doubt it. Blender uses a custom UI based on OpenGL, and I'm not sure you can force it to use a pre-existing window. I suggest browsing the code of "Ghost", which is Blender's custom adaption layer (responsible for interacting with the OS... | 0 | 2009-06-04T12:20:06Z | [
"python",
"3d",
"wxpython",
"embedding",
"blender"
] |
Embedding a 3-D editor (such as Blender) in a wxPython application | 950,145 | <p>Is it possible to embed a 3-D editor inside my wxPython application? (I'm thinking Blender, but other suggestions are welcome.)</p>
<p>My application opens a wxPython window, and I want to have a 3-D editor inside of it. Of course, I want my program and the 3-D editor to interact with each other.</p>
<p>Possible? ... | 1 | 2009-06-04T12:13:25Z | 950,196 | <p>Blender has python plugins, you can write a plugin to interract with your program.</p>
| 2 | 2009-06-04T12:23:28Z | [
"python",
"3d",
"wxpython",
"embedding",
"blender"
] |
Embedding a 3-D editor (such as Blender) in a wxPython application | 950,145 | <p>Is it possible to embed a 3-D editor inside my wxPython application? (I'm thinking Blender, but other suggestions are welcome.)</p>
<p>My application opens a wxPython window, and I want to have a 3-D editor inside of it. Of course, I want my program and the 3-D editor to interact with each other.</p>
<p>Possible? ... | 1 | 2009-06-04T12:13:25Z | 950,244 | <p>Perhaps <a href="http://www.blender.org/forum/viewtopic.php?t=1122&sid=3547dbaaf0e412da6ab510870c44ebf7" rel="nofollow">this script</a> might provide some context for your project. It integrates Blender, ActiveX, and wxPython.</p>
<p>Caveat: Windows only.</p>
| 0 | 2009-06-04T12:30:23Z | [
"python",
"3d",
"wxpython",
"embedding",
"blender"
] |
Embedding a 3-D editor (such as Blender) in a wxPython application | 950,145 | <p>Is it possible to embed a 3-D editor inside my wxPython application? (I'm thinking Blender, but other suggestions are welcome.)</p>
<p>My application opens a wxPython window, and I want to have a 3-D editor inside of it. Of course, I want my program and the 3-D editor to interact with each other.</p>
<p>Possible? ... | 1 | 2009-06-04T12:13:25Z | 951,020 | <p>I second Luper Rouch's idea of Blender plugins. But if you must have your own window you need to fork Blender. Take a look at <a href="http://www.makehuman.org/" rel="nofollow">makehuman</a> project. It used to have Blender as a platform. (I'm not sure but I think they have a different infrastructure now)</p>
| 1 | 2009-06-04T14:41:05Z | [
"python",
"3d",
"wxpython",
"embedding",
"blender"
] |
Embedding a 3-D editor (such as Blender) in a wxPython application | 950,145 | <p>Is it possible to embed a 3-D editor inside my wxPython application? (I'm thinking Blender, but other suggestions are welcome.)</p>
<p>My application opens a wxPython window, and I want to have a 3-D editor inside of it. Of course, I want my program and the 3-D editor to interact with each other.</p>
<p>Possible? ... | 1 | 2009-06-04T12:13:25Z | 3,286,201 | <p>For Blender2.5 on linux you can use gtk.Socket, code example is <a href="http://pastebin.com/vYtJmmAC" rel="nofollow">here on pastebin</a> </p>
| 0 | 2010-07-20T00:48:22Z | [
"python",
"3d",
"wxpython",
"embedding",
"blender"
] |
Use Django Framework with Website and Stand-alone App | 950,790 | <p>I'm planning on writing a web crawler and a web-based front end for it (or, at least, the information it finds). I was wondering if it's possible to use the Django framework to let the web crawler use the same MySQL backend as the website (without making the web crawler a "website" in it's self).</p>
| 1 | 2009-06-04T14:03:45Z | 950,874 | <p>Yes, you can use the same database.</p>
<p>Some people use Django on top of a PHP application for its admin functionality, or to build newer features with Django and its ORM.</p>
<p>What I'm trying to say is that if you're putting data from your crawl into the same place that you will let Django store its data, yo... | 4 | 2009-06-04T14:15:19Z | [
"python",
"django"
] |
Use Django Framework with Website and Stand-alone App | 950,790 | <p>I'm planning on writing a web crawler and a web-based front end for it (or, at least, the information it finds). I was wondering if it's possible to use the Django framework to let the web crawler use the same MySQL backend as the website (without making the web crawler a "website" in it's self).</p>
| 1 | 2009-06-04T14:03:45Z | 950,997 | <p>You can use Django ORM outside of an HTTP server.</p>
<p>Basically you need to set <code>DJANGO_SETTINGS_MODULE</code> environment variable. Then you can import and use your django code. Here's an <a href="http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/" rel="nofollow">article on stand-alone Dja... | 3 | 2009-06-04T14:37:20Z | [
"python",
"django"
] |
Create SQL query using SqlAlchemy select and join functions | 950,910 | <p>I have two tables "tags" and "deal_tag", and table definition follows,</p>
<pre><code>Table('tags', metadata,
Column('id', types.Integer(), Sequence('tag_uid_seq'),
primary_key=True),
Column('name', types.String()),
)
Table('deal_tag', metadata,
Column('dealid', ty... | 3 | 2009-06-04T14:21:32Z | 951,136 | <p>Give this a try...</p>
<pre><code>s = select([tags.c.Name, tags.c.id, func.count(deal_tag.dealid)],
tags.c.id == deal_tag.c.tagid).group_by(tags.c.Name, tags.c.id)
</code></pre>
| 2 | 2009-06-04T15:01:22Z | [
"python",
"sqlalchemy"
] |
Create SQL query using SqlAlchemy select and join functions | 950,910 | <p>I have two tables "tags" and "deal_tag", and table definition follows,</p>
<pre><code>Table('tags', metadata,
Column('id', types.Integer(), Sequence('tag_uid_seq'),
primary_key=True),
Column('name', types.String()),
)
Table('deal_tag', metadata,
Column('dealid', ty... | 3 | 2009-06-04T14:21:32Z | 1,052,563 | <p>you can join table in the time of mapping table</p>
<p>in the <strong>orm.mapper()</strong></p>
<p>for more information you can go thru the link</p>
<p>www.sqlalchemy.org/docs/</p>
| 0 | 2009-06-27T10:19:07Z | [
"python",
"sqlalchemy"
] |
Which validating python XML api to use? | 950,974 | <p>I new to xml stuff, so I have no idea which api I should use in python.
Till now I used xmlproc, but I heard it is not developed any more.</p>
<p>I have basically only one requirement: I want to validate against a dtd that I can choose in my program. I can't thrust the doctype thing.</p>
<p>Performance does not re... | 1 | 2009-06-04T14:32:20Z | 951,045 | <p>For my current project, I'm using <a href="http://codespeak.net/lxml/" rel="nofollow">lxml</a>, which is fairly easy to use. Validation with DTD is described on <a href="http://codespeak.net/lxml/validation.html" rel="nofollow">this page</a></p>
| 3 | 2009-06-04T14:45:39Z | [
"python",
"xml",
"validation",
"dtd"
] |
Dynamic loading of python modules | 951,124 | <p>In python how do you dynamically add modules to a package while your programming is running.</p>
<p>I want to be able to add modules to the package directory from an outside process, and be able to use those new modules in my program:</p>
<pre><code>import package
def doSomething(name):
pkg = __import__("pack... | 32 | 2009-06-04T14:59:25Z | 951,142 | <p>Add the module directory to <code>sys.path</code> and use the normal <code>import</code> statement.</p>
| 0 | 2009-06-04T15:02:24Z | [
"python",
"dynamic",
"python-import"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.