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
Python Script to find instances of a set of strings in a set of files
1,483,830
<p>I have a file which I use to centralize all strings used in my application. Lets call it Strings.txt;</p> <pre><code>TITLE="Title" T_AND_C="Accept my terms and conditions please" START_BUTTON="Start" BACK_BUTTON="Back" ... </code></pre> <p>This helps me with I18n, the issue is that my application is now a lot larg...
1
2009-09-27T16:02:19Z
1,483,855
<p>to parse your <code>strings.txt</code> you don't need regular expressions:</p> <pre><code>all_strings = [i.partition('=')[0] for i in open('strings.txt')] </code></pre> <p>to parse your source you could use the dumbest regex:</p> <pre><code>re.search('\bTITLE\b', source) # for each string in all_strings </...
0
2009-09-27T16:18:09Z
[ "python", "find", "internationalization" ]
Python Script to find instances of a set of strings in a set of files
1,483,830
<p>I have a file which I use to centralize all strings used in my application. Lets call it Strings.txt;</p> <pre><code>TITLE="Title" T_AND_C="Accept my terms and conditions please" START_BUTTON="Start" BACK_BUTTON="Back" ... </code></pre> <p>This helps me with I18n, the issue is that my application is now a lot larg...
1
2009-09-27T16:02:19Z
1,483,979
<p>You should consider using <a href="http://www.yaml.org/" rel="nofollow">YAML</a>: easy to use, human readable.</p>
0
2009-09-27T17:13:07Z
[ "python", "find", "internationalization" ]
Python Script to find instances of a set of strings in a set of files
1,483,830
<p>I have a file which I use to centralize all strings used in my application. Lets call it Strings.txt;</p> <pre><code>TITLE="Title" T_AND_C="Accept my terms and conditions please" START_BUTTON="Start" BACK_BUTTON="Back" ... </code></pre> <p>This helps me with I18n, the issue is that my application is now a lot larg...
1
2009-09-27T16:02:19Z
1,483,983
<p>You are re-inventing <a href="http://docs.python.org/library/gettext.html" rel="nofollow">gettext</a>, the standard for translating programs in the Free Software sphere (even outside python).</p> <p>Gettext works with, in principle, large files with strings like these :-). Helper programs exist to merge in new mark...
0
2009-09-27T17:16:55Z
[ "python", "find", "internationalization" ]
Djapian - filtering results
1,483,874
<p>I use Djapian to search for object by keywords, but I want to be able to filter results. It would be nice to use Django's QuerySet API for this, for example:</p> <pre><code>if query.strip(): results = Model.indexer.search(query).prefetch() else: results = Model.objects.all() results = results.filter(somefie...
1
2009-09-27T16:27:35Z
1,484,011
<p>I dont know Djapian, but i am familiar with xapian. In Xapian you can filter the results with a <a href="http://xapian.org/docs/apidoc/html/classXapian%5F1%5F1MatchDecider.html" rel="nofollow">MatchDecider</a>.</p> <p>The decision function of the match decider gets called on every document which matches the search ...
0
2009-09-27T17:26:02Z
[ "python", "django", "search", "full-text-search", "xapian" ]
Djapian - filtering results
1,483,874
<p>I use Djapian to search for object by keywords, but I want to be able to filter results. It would be nice to use Django's QuerySet API for this, for example:</p> <pre><code>if query.strip(): results = Model.indexer.search(query).prefetch() else: results = Model.objects.all() results = results.filter(somefie...
1
2009-09-27T16:27:35Z
1,485,009
<p>I went through its source and found that Djapian has a filter method that can be applied to its results. I have just tried the below code and it seems to be working. </p> <p>My indexer is as follows:</p> <pre><code>class MarketIndexer( djapian.Indexer ): fields = [ 'name', 'description', 'tags_string', 'state...
4
2009-09-28T01:21:39Z
[ "python", "django", "search", "full-text-search", "xapian" ]
python PIL - background displayed opaque instead of transparent
1,484,101
<p>I want to generate 32x32 sized thumbnails from uploaded images (actually avatars). </p> <p>To prevent a thumbnail from being smaller than that size, I want to create a transparent 32x32 background and paste the thumbnail on it. </p> <p>The code below tries to do so. However, the avatar is displayed on a black and ...
3
2009-09-27T18:12:52Z
1,484,110
<p>You're generating a JPG image. JPEGs don't support background transparency. You need to generate a PNG image to support transparencies.</p>
5
2009-09-27T18:18:15Z
[ "python", "django", "image" ]
python PIL - background displayed opaque instead of transparent
1,484,101
<p>I want to generate 32x32 sized thumbnails from uploaded images (actually avatars). </p> <p>To prevent a thumbnail from being smaller than that size, I want to create a transparent 32x32 background and paste the thumbnail on it. </p> <p>The code below tries to do so. However, the avatar is displayed on a black and ...
3
2009-09-27T18:12:52Z
1,484,113
<p>That is because JPEG cannot save transparency informations which are contained in a RGBA image. You may want to save the avatar to a format like PNG which is able to keep these informations.</p>
5
2009-09-27T18:19:45Z
[ "python", "django", "image" ]
Replace/delete field using sqlalchemy
1,484,235
<p>Using postgres in python,</p> <ol> <li><p>How do I replace all fields from the same column that match a specified value? For example, let's say I want to replace any fields that match "green" with "red" in the "Color" column.</p></li> <li><p>How to delete all fields from the same column that match a specified valu...
7
2009-09-27T19:17:05Z
1,484,267
<p>Ad1. You need something like this:</p> <pre><code>session.query(Foo).filter_by(color = 'green').update({ 'color': 'red' }) session.commit() </code></pre> <p>Ad2. Similarly:</p> <pre><code>session.query(Foo).filter_by(color = 'green').delete() session.commit() </code></pre> <p>You can find the querying documentat...
9
2009-09-27T19:39:37Z
[ "python", "postgresql", "replace", "sqlalchemy" ]
How do I use PyMock and Nose with Django models?
1,484,293
<p>I'm trying to do TDD with PyMock, but I keep getting error when I use Nose and execute core.py from command line:</p> <p>"ERROR: Failure: ImportError (Settings cannot be imported, because environment variable DJA NGO_SETTINGS_MODULE is undefined.)"</p> <p>If I remove "from cms.models import Entry" from the unit te...
2
2009-09-27T19:48:42Z
1,484,428
<p>You <strong>do</strong> need <code>DJANGO_SETTINGS_MODULE</code> defined in order to run <code>core.py</code> -- why don't you just <code>export DJANGO_SETTINGS_MODULE=whatever</code> in your bash session before starting nose?</p>
4
2009-09-27T20:41:18Z
[ "python", "django", "unit-testing", "nose" ]
Python process pool and scope
1,484,310
<p>I am trying to run autogenerated code (which might potentially not terminate) in a loop, for genetic programming. I'm trying to use multiprocessing pool for this, since I don't want the big performance overhead of creating a new process each time, and I can terminate the pool process if it runs too long (which i can...
0
2009-09-27T19:55:03Z
1,484,409
<p>Did you read <a href="http://docs.python.org/library/multiprocessing.html#multiprocessing-programming" rel="nofollow">the programming guidelines</a>? There is lots of stuff in there about global variables. There are even more limitations under Windows. You don't say which platform you are running on, but this cou...
3
2009-09-27T20:33:21Z
[ "python", "pool" ]
Python process pool and scope
1,484,310
<p>I am trying to run autogenerated code (which might potentially not terminate) in a loop, for genetic programming. I'm trying to use multiprocessing pool for this, since I don't want the big performance overhead of creating a new process each time, and I can terminate the pool process if it runs too long (which i can...
0
2009-09-27T19:55:03Z
1,484,423
<p><code>Process</code> (via pool or otherwise) won't have a <code>__name__</code> of <code>'__main__'</code>, so it will not execute anything that depends on that condition -- including the <code>exec</code> statements that you depend on in order to find your <code>meth</code>, of course.</p> <p>Why are you so keen o...
2
2009-09-27T20:39:21Z
[ "python", "pool" ]
Python process pool and scope
1,484,310
<p>I am trying to run autogenerated code (which might potentially not terminate) in a loop, for genetic programming. I'm trying to use multiprocessing pool for this, since I don't want the big performance overhead of creating a new process each time, and I can terminate the pool process if it runs too long (which i can...
0
2009-09-27T19:55:03Z
1,484,579
<p>As I commented above, all your examples are working as you expect on my Linux box (Debian Lenny, Python2.5, processing 0.52, see test code below).</p> <p>There seems to be many restrictions on windows on objects you can transmit from one process to another. Reading the doc pointed out by Nick it seems that on windo...
0
2009-09-27T21:51:38Z
[ "python", "pool" ]
Wildcard for PyGTK States
1,484,339
<p>How do I combine:</p> <pre><code>button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("Green")) button.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.color_parse("Green")) button.modify_bg(gtk.STATE_SELECTED, gtk.gdk.color_parse("Green")) </code></pre> <p>etc.</p> <p>Into a one-liner wildcard covering all of the possible ...
0
2009-09-27T20:04:24Z
1,484,536
<p>I do not think you can do that. You can still do it with fewer lines though:</p> <pre><code>states = [gtk.STATE_NORMAL, gtk.STATE_ACTIVE, gtk.STATE_PRELIGHT, gtk.STATE_SELECTED, gtk.STATE_INSENSITIVE] for state in states: button.modify_bg(state, gtk.gdk.color_parse("Green")) </code></pre>
1
2009-09-27T21:33:14Z
[ "python", "pygtk", "state" ]
Wildcard for PyGTK States
1,484,339
<p>How do I combine:</p> <pre><code>button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("Green")) button.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.color_parse("Green")) button.modify_bg(gtk.STATE_SELECTED, gtk.gdk.color_parse("Green")) </code></pre> <p>etc.</p> <p>Into a one-liner wildcard covering all of the possible ...
0
2009-09-27T20:04:24Z
1,485,699
<p>EDIT:</p> <p>Maybe this comes in handy: <a href="http://faq.pygtk.org/index.py?req=show&amp;file=faq04.006.htp" rel="nofollow">http://faq.pygtk.org/index.py?req=show&amp;file=faq04.006.htp</a></p>
0
2009-09-28T06:36:01Z
[ "python", "pygtk", "state" ]
how % applies to this method in Python?
1,484,375
<p>From my studying of python, I've found two uses for %. It can be used as what's called a modulo, meaning it will divide the value to the left of it and the value to the right of it and spit back the remainder.</p> <p>The other use is a string formatter. So I can do something like <code>'Hi there %s' % name</code>, ...
2
2009-09-27T20:17:37Z
1,484,388
<p>The string % operator is simpler than you are imagining. It takes a string on the left side, and a variety of things on the right side. The left side doesn't have to be a literal string, it can be a variable, or the result of another computation. Any expression that results in a string is valid for the left side ...
4
2009-09-27T20:24:06Z
[ "python", "class", "string-formatting" ]
how % applies to this method in Python?
1,484,375
<p>From my studying of python, I've found two uses for %. It can be used as what's called a modulo, meaning it will divide the value to the left of it and the value to the right of it and spit back the remainder.</p> <p>The other use is a string formatter. So I can do something like <code>'Hi there %s' % name</code>, ...
2
2009-09-27T20:17:37Z
1,484,389
<pre><code>def tostr(self, x): if x is None: return 'None' return self.fmt%self.toval(x) </code></pre> <p>The <code>%</code> in this is a string formatter, definitely. Pass the <code>tostr</code> method a formatter, eg <code>"%s"</code> or <code>"%r"</code> to see what happens</p> <p>I think the <code>'%r'</...
0
2009-09-27T20:24:28Z
[ "python", "class", "string-formatting" ]
how % applies to this method in Python?
1,484,375
<p>From my studying of python, I've found two uses for %. It can be used as what's called a modulo, meaning it will divide the value to the left of it and the value to the right of it and spit back the remainder.</p> <p>The other use is a string formatter. So I can do something like <code>'Hi there %s' % name</code>, ...
2
2009-09-27T20:17:37Z
1,484,390
<p>The code: return self.fmt % self.toval(x)</p> <p>Is the "string formatting" use of the % operator, just like you suspected.</p> <p>The class is handed format, which is a string containing the formatting, and when tostr(x) is called, it will return the string % x.</p> <p>This is just like using % directly, on...
0
2009-09-27T20:25:16Z
[ "python", "class", "string-formatting" ]
how % applies to this method in Python?
1,484,375
<p>From my studying of python, I've found two uses for %. It can be used as what's called a modulo, meaning it will divide the value to the left of it and the value to the right of it and spit back the remainder.</p> <p>The other use is a string formatter. So I can do something like <code>'Hi there %s' % name</code>, ...
2
2009-09-27T20:17:37Z
1,484,391
<p>In</p> <pre><code>return self.fmt%self.toval(x) </code></pre> <p><code>self.fmt</code> is a string, and that string presumably has a percent-sign placeholder in it.</p> <p><code>%r</code> in a format string is like <code>%s</code> but it prints the <code>repr()</code> of the string, so it'll have quotes and backs...
3
2009-09-27T20:25:16Z
[ "python", "class", "string-formatting" ]
how % applies to this method in Python?
1,484,375
<p>From my studying of python, I've found two uses for %. It can be used as what's called a modulo, meaning it will divide the value to the left of it and the value to the right of it and spit back the remainder.</p> <p>The other use is a string formatter. So I can do something like <code>'Hi there %s' % name</code>, ...
2
2009-09-27T20:17:37Z
1,484,396
<p>% has more than one use in string formatting. One use is in %s, %d, etc.</p> <p>Another use is to separate 'string in which we use %d and %s' from int-value and string-value.</p> <p>For example </p> <pre><code>'string in which we use %d and %s' % (17, 'blue') </code></pre> <p>would result in </p> <pre><code>'s...
0
2009-09-27T20:27:03Z
[ "python", "class", "string-formatting" ]
Ñ not displayed in google app engine website
1,484,427
<p>I'm using google app engine to build a website and I'm having problems with special characters. I think I've reduced the problem to this two code samples:</p> <pre><code>request = urlfetch.fetch( url=self.WWW_INFO, payload=urllib.urlencode(inputs), method=urlfetch.POST, headers={'Content-Typ...
0
2009-09-27T20:41:09Z
1,484,439
<p>You need to get the <code>charset</code> from the <code>content-type</code> header in the fetch's result, use it to decode the bytes into Unicode, then, on the response, set the header with your favorite encoding (I do suggest utf-8 -- no good reason to do otherwise) and emit the encoding of the Unicode text via tha...
1
2009-09-27T20:47:15Z
[ "python", "google-app-engine", "unicode", "utf-8" ]
HTML tag replacement using regex and python
1,484,575
<p>I have a Python script that will look at an HTML file that has the following format:</p> <pre><code>&lt;DOC&gt; &lt;HTML&gt; ... &lt;/HTML&gt; &lt;/DOC&gt; &lt;DOC&gt; &lt;HTML&gt; ... &lt;/HTML&gt; &lt;/DOC&gt; </code></pre> <p>How do I remove all HTML tags (replace the tags with '') with the exception of the ope...
1
2009-09-27T21:49:34Z
1,484,584
<p>search and replace with this regex: search for: &lt;.*?> replace with: " </p>
1
2009-09-27T21:53:42Z
[ "python", "html", "regex", "tags" ]
HTML tag replacement using regex and python
1,484,575
<p>I have a Python script that will look at an HTML file that has the following format:</p> <pre><code>&lt;DOC&gt; &lt;HTML&gt; ... &lt;/HTML&gt; &lt;/DOC&gt; &lt;DOC&gt; &lt;HTML&gt; ... &lt;/HTML&gt; &lt;/DOC&gt; </code></pre> <p>How do I remove all HTML tags (replace the tags with '') with the exception of the ope...
1
2009-09-27T21:49:34Z
1,485,191
<p>Check out <a href="http://codespeak.net/lxml/" rel="nofollow">lxml</a>, a really nice python library for dealing with xml. You can use drop_tag to accomplish what you are looking for.</p> <pre> from lxml import html h = html.fragment_fromstring('&lt;doc&gt;Hello &lt;b&gt;World!&lt;/b&gt;&lt;/doc&gt;') h.find('*')....
2
2009-09-28T02:54:23Z
[ "python", "html", "regex", "tags" ]
HTML tag replacement using regex and python
1,484,575
<p>I have a Python script that will look at an HTML file that has the following format:</p> <pre><code>&lt;DOC&gt; &lt;HTML&gt; ... &lt;/HTML&gt; &lt;/DOC&gt; &lt;DOC&gt; &lt;HTML&gt; ... &lt;/HTML&gt; &lt;/DOC&gt; </code></pre> <p>How do I remove all HTML tags (replace the tags with '') with the exception of the ope...
1
2009-09-27T21:49:34Z
1,485,230
<p>For what you are trying to accomplish I would use BeautifulSoup rather than regex.</p> <p><a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">http://www.crummy.com/software/BeautifulSoup/</a></p>
3
2009-09-28T03:11:57Z
[ "python", "html", "regex", "tags" ]
How to build a mini-network of small programs feeding each other data?
1,484,658
<p>I'm trying to simulate a real-time network where nodes are consumers and producers of different rates. How would I quickly implement a sample of this with Python? I was imagining that I'd write a simple program for each node, but I'm not sure how to connect them to each other.</p>
6
2009-09-27T22:32:20Z
1,484,676
<p>Look into <a href="http://networkx.lanl.gov/" rel="nofollow">NetworkX</a> <strong>a Python library for creating and manipulating networks</strong>. Edit: Attention, nearby/related to NetworkX, and also hosted at Los Alamos NL, is PyGraphviz, a utility to display graphs. Thank you to las3jrock to point out that I ...
1
2009-09-27T22:44:18Z
[ "python", "simulation" ]
How to build a mini-network of small programs feeding each other data?
1,484,658
<p>I'm trying to simulate a real-time network where nodes are consumers and producers of different rates. How would I quickly implement a sample of this with Python? I was imagining that I'd write a simple program for each node, but I'm not sure how to connect them to each other.</p>
6
2009-09-27T22:32:20Z
1,484,680
<p>Here's how to make a basic client/server program: <a href="http://wdvl.internet.com/Authoring/python/client/watts06152009.html" rel="nofollow">http://wdvl.internet.com/Authoring/python/client/watts06152009.html</a></p> <p>For the data to send from one to another, I'd recommend <a href="http://json.org/" rel="nofoll...
0
2009-09-27T22:45:28Z
[ "python", "simulation" ]
How to build a mini-network of small programs feeding each other data?
1,484,658
<p>I'm trying to simulate a real-time network where nodes are consumers and producers of different rates. How would I quickly implement a sample of this with Python? I was imagining that I'd write a simple program for each node, but I'm not sure how to connect them to each other.</p>
6
2009-09-27T22:32:20Z
1,484,681
<p>Inter-process communication is a generally hard thing to get right. You may want to consider if another approach would meet your needs, like a discrete events simulator.</p> <p>In a DES, you don't actually do the work of each node, just simulate how long each node would take to get the work done. You can use a prio...
2
2009-09-27T22:45:31Z
[ "python", "simulation" ]
How to build a mini-network of small programs feeding each other data?
1,484,658
<p>I'm trying to simulate a real-time network where nodes are consumers and producers of different rates. How would I quickly implement a sample of this with Python? I was imagining that I'd write a simple program for each node, but I'm not sure how to connect them to each other.</p>
6
2009-09-27T22:32:20Z
1,484,705
<h3>Stick with traditional simulation structures, at least at first</h3> <p>Is it your goal to write an asynchronous system as an exercise? If so, then I guess you have to implement at least a multi-threaded if not multi-process or network system.</p> <p>But if it's really a simulation, and what you want are the anal...
5
2009-09-27T22:59:00Z
[ "python", "simulation" ]
How to build a mini-network of small programs feeding each other data?
1,484,658
<p>I'm trying to simulate a real-time network where nodes are consumers and producers of different rates. How would I quickly implement a sample of this with Python? I was imagining that I'd write a simple program for each node, but I'm not sure how to connect them to each other.</p>
6
2009-09-27T22:32:20Z
1,484,763
<p>Two things come to mind:</p> <p>1- You could write one or more daemons with Twisted Python. (Be warned, twisted can get a little overwhelming , since its an event-driven async system ). Each daemon can bind to a port and make itself available to other daemons. Alternately, you could just run everything within one...
0
2009-09-27T23:27:40Z
[ "python", "simulation" ]
How to build a mini-network of small programs feeding each other data?
1,484,658
<p>I'm trying to simulate a real-time network where nodes are consumers and producers of different rates. How would I quickly implement a sample of this with Python? I was imagining that I'd write a simple program for each node, but I'm not sure how to connect them to each other.</p>
6
2009-09-27T22:32:20Z
1,484,764
<p>I like @DigitalRoss's and dcrosta's suggestions of a discrete-even simulation, and I'd like to point out that the <a href="http://docs.python.org/library/sched.html" rel="nofollow">sched</a> module in the Python standard library is just what you need at the core of such a system (no need to rebuild the core on top o...
2
2009-09-27T23:28:34Z
[ "python", "simulation" ]
How to build a mini-network of small programs feeding each other data?
1,484,658
<p>I'm trying to simulate a real-time network where nodes are consumers and producers of different rates. How would I quickly implement a sample of this with Python? I was imagining that I'd write a simple program for each node, but I'm not sure how to connect them to each other.</p>
6
2009-09-27T22:32:20Z
1,486,960
<p>Just use Stackless Python, create tasklets, connect them with channels, and everything will work. It is extremely simple.</p>
0
2009-09-28T13:12:07Z
[ "python", "simulation" ]
How to build a mini-network of small programs feeding each other data?
1,484,658
<p>I'm trying to simulate a real-time network where nodes are consumers and producers of different rates. How would I quickly implement a sample of this with Python? I was imagining that I'd write a simple program for each node, but I'm not sure how to connect them to each other.</p>
6
2009-09-27T22:32:20Z
1,487,634
<p>This is something Stackless does very well.</p> <p>Also, you could use generators / co-routines.</p> <p>Interesting links:</p> <p><a href="http://www.python.org/dev/peps/pep-0342/" rel="nofollow">http://www.python.org/dev/peps/pep-0342/</a></p> <p>New users can only post 1 hyper link... so here is the other one<...
0
2009-09-28T15:17:48Z
[ "python", "simulation" ]
How do I Access File Properties on Windows Vista with Python?
1,484,746
<p>The question is as simple as in the title, how do I access windows file properties like date-modifed, and more specifically tags, with Python? For a program I'm doing, I need to get lists of all the tags on various files in a particular folder, and I'm not sure on how to do this. I have the win32 module, but I don't...
2
2009-09-27T23:17:31Z
1,484,750
<p>You can use <a href="http://docs.python.org/library/os.html#os.stat">os.stat</a> with <a href="http://docs.python.org/library/stat.html">stat</a></p> <pre><code>import os import stat import time def get_info(file_name): time_format = "%m/%d/%Y %I:%M:%S %p" file_stats = os.stat(file_name) modification_t...
6
2009-09-27T23:20:16Z
[ "python", "winapi", "windows-vista", "properties" ]
How do I Access File Properties on Windows Vista with Python?
1,484,746
<p>The question is as simple as in the title, how do I access windows file properties like date-modifed, and more specifically tags, with Python? For a program I'm doing, I need to get lists of all the tags on various files in a particular folder, and I'm not sure on how to do this. I have the win32 module, but I don't...
2
2009-09-27T23:17:31Z
1,484,768
<p>Example: </p> <pre><code>import time, datetime fstat = os.stat(FILENAME) st_mtime = fstat.st_mtime # Date modified a,b,c,d,e,f,g,h,i = time.localtime(st_mtime) print datetime.datetime(a,b,c,d,e,f,g) </code></pre>
1
2009-09-27T23:30:28Z
[ "python", "winapi", "windows-vista", "properties" ]
How do I Access File Properties on Windows Vista with Python?
1,484,746
<p>The question is as simple as in the title, how do I access windows file properties like date-modifed, and more specifically tags, with Python? For a program I'm doing, I need to get lists of all the tags on various files in a particular folder, and I'm not sure on how to do this. I have the win32 module, but I don't...
2
2009-09-27T23:17:31Z
1,512,536
<p>Apparently, you need to use the <a href="http://msdn.microsoft.com/en-us/library/bb331575%28VS.85%29.aspx" rel="nofollow">Windows Search API</a> looking for <a href="http://msdn.microsoft.com/en-us/library/bb787519%28VS.85%29.aspx" rel="nofollow">System.Keywords</a> -- you can access the API directly via <a href="ht...
3
2009-10-03T01:37:05Z
[ "python", "winapi", "windows-vista", "properties" ]
How do I Access File Properties on Windows Vista with Python?
1,484,746
<p>The question is as simple as in the title, how do I access windows file properties like date-modifed, and more specifically tags, with Python? For a program I'm doing, I need to get lists of all the tags on various files in a particular folder, and I'm not sure on how to do this. I have the win32 module, but I don't...
2
2009-09-27T23:17:31Z
5,846,160
<p>(You might notice a longer version of the following response given on <a href="http://stackoverflow.com/questions/1512435/how-do-you-retrieve-the-tags-of-a-file-in-a-list-with-python-windows-vista/5846091">another</a> of your threads.)</p> <ol> <li>Download and install the <a href="http://sourceforge.net/projects/p...
0
2011-05-01T03:08:26Z
[ "python", "winapi", "windows-vista", "properties" ]
how are these two variables unpacked?
1,484,748
<p>Through tutorials I had learned that you can define two variables in the same statement, e.g.:</p> <pre><code>In [15]: a, b = 'hello', 'hi!' In [16]: a Out[16]: 'hello' In [17]: b Out[17]: 'hi!' </code></pre> <p>well how does that apply to here?</p> <pre><code>fh, opened = cbook.to_filehandle(fname, 'w', return...
1
2009-09-27T23:19:54Z
1,484,758
<p>My guess is that the function internally looks something like this:</p> <pre><code>def to_filehandle(filename, mode, return_opened=False): # do something to open the file and set opened # to True if it worked, False otherwise if return_opened: return the_filehandle, opened else: retu...
2
2009-09-27T23:25:44Z
[ "python", "variables" ]
how are these two variables unpacked?
1,484,748
<p>Through tutorials I had learned that you can define two variables in the same statement, e.g.:</p> <pre><code>In [15]: a, b = 'hello', 'hi!' In [16]: a Out[16]: 'hello' In [17]: b Out[17]: 'hi!' </code></pre> <p>well how does that apply to here?</p> <pre><code>fh, opened = cbook.to_filehandle(fname, 'w', return...
1
2009-09-27T23:19:54Z
1,484,772
<p>In Python, a function have more than one return value. In this case, the function '<code>cbook.to_filehandle</code>' return the two value.</p> <p>About the error, I think we cannot tell much about it until we know what '<code>cbook.to_filehandle</code>' supposes to do or see it code.</p>
0
2009-09-27T23:31:17Z
[ "python", "variables" ]
how are these two variables unpacked?
1,484,748
<p>Through tutorials I had learned that you can define two variables in the same statement, e.g.:</p> <pre><code>In [15]: a, b = 'hello', 'hi!' In [16]: a Out[16]: 'hello' In [17]: b Out[17]: 'hi!' </code></pre> <p>well how does that apply to here?</p> <pre><code>fh, opened = cbook.to_filehandle(fname, 'w', return...
1
2009-09-27T23:19:54Z
1,484,774
<p>With tuple assignment, the right side doesn't need to be an explicit tuple:</p> <pre><code>x = 1, 0 a, b = x </code></pre> <p>does the same thing as:</p> <pre><code>a, b = 1, 0 </code></pre> <p>If a function returns a tuple, you can unpack it with tuple assignment:</p> <pre><code>def my_fn(): return 1, 0 a...
2
2009-09-27T23:31:29Z
[ "python", "variables" ]
how are these two variables unpacked?
1,484,748
<p>Through tutorials I had learned that you can define two variables in the same statement, e.g.:</p> <pre><code>In [15]: a, b = 'hello', 'hi!' In [16]: a Out[16]: 'hello' In [17]: b Out[17]: 'hi!' </code></pre> <p>well how does that apply to here?</p> <pre><code>fh, opened = cbook.to_filehandle(fname, 'w', return...
1
2009-09-27T23:19:54Z
1,484,781
<p>Unpacking is not a magic process : every tuple (for example, <code>(1, 2, 3)</code> is a tuple with three values) can be unpacked into three values. But the tuple itself is also a value, so you can assign it to a variable or return it from a function :</p> <pre><code>x = (1, 2, 3) a, b, c = x # Or, for example : d...
1
2009-09-27T23:33:01Z
[ "python", "variables" ]
how are these two variables unpacked?
1,484,748
<p>Through tutorials I had learned that you can define two variables in the same statement, e.g.:</p> <pre><code>In [15]: a, b = 'hello', 'hi!' In [16]: a Out[16]: 'hello' In [17]: b Out[17]: 'hi!' </code></pre> <p>well how does that apply to here?</p> <pre><code>fh, opened = cbook.to_filehandle(fname, 'w', return...
1
2009-09-27T23:19:54Z
1,484,792
<p>As @dcrosta says, there is nothing magical about the variable names. To better see what's going on, try:</p> <pre><code>result = cbook.to_filehandle(fname, 'w', return_opened=True) </code></pre> <p>and examine <code>result</code>, <code>type(result)</code>, etc: you'll see it's a tuple (could conceivably be a list...
2
2009-09-27T23:35:30Z
[ "python", "variables" ]
There’s PyQuery… is there one for Ruby?
1,484,963
<p>You guys know <a href="http://pypi.python.org/pypi/pyquery" rel="nofollow">PyQuery</a>?</p> <p>I was wondering if there’s an equivalent for Ruby.</p>
1
2009-09-28T00:56:35Z
1,484,996
<p>There's JRails, but it's outdated. If you're just looking for a way to use JQuery with Rails though: <a href="http://railscasts.com/episodes/136-jquery" rel="nofollow">http://railscasts.com/episodes/136-jquery</a></p>
1
2009-09-28T01:11:24Z
[ "python", "ruby" ]
There’s PyQuery… is there one for Ruby?
1,484,963
<p>You guys know <a href="http://pypi.python.org/pypi/pyquery" rel="nofollow">PyQuery</a>?</p> <p>I was wondering if there’s an equivalent for Ruby.</p>
1
2009-09-28T00:56:35Z
1,500,608
<p>Hpricot - <a href="http://stackoverflow.com/questions/1223793/most-jquery-like-html-parser-for-ruby">http://stackoverflow.com/questions/1223793/most-jquery-like-html-parser-for-ruby</a></p>
1
2009-09-30T20:54:47Z
[ "python", "ruby" ]
Putting in extra restrictions when filtering on foreignkey in django-admin
1,485,103
<p>When getting members based on Unit, I only want to get the ones who are <em>actually in that unit as of now</em>.</p> <p>I've got a model looking like this:</p> <pre><code>class Member(models.Model): name = models.CharField(max_length=256) unit = models.ManyToManyField(Unit, through='Membership') class Me...
1
2009-09-28T02:03:53Z
1,485,173
<p>So you're trying to get the members of a specific Unit, right?</p> <pre><code>unit = Unit.objects.select_related().get(id=some_id) </code></pre> <p>This will pull the unit out of the database for you, along with the Memberships and Users that belong to it. You can access and filter the users by:</p> <pre><code>fo...
0
2009-09-28T02:44:46Z
[ "python", "django", "filter", "django-admin", "many-to-many" ]
Putting in extra restrictions when filtering on foreignkey in django-admin
1,485,103
<p>When getting members based on Unit, I only want to get the ones who are <em>actually in that unit as of now</em>.</p> <p>I've got a model looking like this:</p> <pre><code>class Member(models.Model): name = models.CharField(max_length=256) unit = models.ManyToManyField(Unit, through='Membership') class Me...
1
2009-09-28T02:03:53Z
1,491,167
<p>One way to certainly achieve this is by adding a denormalized field for <code>has_open_ended_membership</code>.</p> <p>To do this just add a BooleaneField like that to the Member and <strong>make sure it's consistent</strong>.</p> <p>From the django documentation this seems to be the only way without writing spec...
0
2009-09-29T08:06:36Z
[ "python", "django", "filter", "django-admin", "many-to-many" ]
Putting in extra restrictions when filtering on foreignkey in django-admin
1,485,103
<p>When getting members based on Unit, I only want to get the ones who are <em>actually in that unit as of now</em>.</p> <p>I've got a model looking like this:</p> <pre><code>class Member(models.Model): name = models.CharField(max_length=256) unit = models.ManyToManyField(Unit, through='Membership') class Me...
1
2009-09-28T02:03:53Z
1,517,792
<p>I fixed it with putting in a denormalized field in member, with a foreign-key to the active unit. Then, to make it work and be automatically updated in the admin, I made the specialized save-function for Membership.</p> <pre><code>class Member(models.Model): name = models.CharField(max_length=256) unit = models...
0
2009-10-05T00:40:05Z
[ "python", "django", "filter", "django-admin", "many-to-many" ]
How to pack a tkinter widget underneath an existing widget that has been packed to the left side?
1,485,408
<p>I'm attempting to write a basic Tkinter GUI that has a <code>Text</code> widget at the top, then a <code>Button</code> widget left aligned under it, then another <code>Text</code> widget underneath the button. The problem I'm having is, after packing the <code>Button</code> widget to the left, when I then go to pac...
5
2009-09-28T04:25:57Z
1,485,522
<p>Packing happens in the order the .pack methods are called, so once x has "claimed" the left side, that's it -- it will take up the left portion of its parent and everything else within its parent will be to its right. You need a Frame to "mediate", e.g....:</p> <pre><code>from Tkinter import * root = Tk() w = Bu...
2
2009-09-28T05:15:17Z
[ "python", "widget", "tkinter", "pack" ]
How to pack a tkinter widget underneath an existing widget that has been packed to the left side?
1,485,408
<p>I'm attempting to write a basic Tkinter GUI that has a <code>Text</code> widget at the top, then a <code>Button</code> widget left aligned under it, then another <code>Text</code> widget underneath the button. The problem I'm having is, after packing the <code>Button</code> widget to the left, when I then go to pac...
5
2009-09-28T04:25:57Z
1,485,677
<p>I was initially misunderstanding how packing worked and didn't realise that the entire left side was being "claimed" when i did <code>x.pack(side=LEFT)</code>. What I found after reading <a href="http://www.ferg.org/thinking%5Fin%5Ftkinter/tt100%5Fpy.txt">this</a> and the answer by Alex here is that I was not reall...
5
2009-09-28T06:22:03Z
[ "python", "widget", "tkinter", "pack" ]
How to pack a tkinter widget underneath an existing widget that has been packed to the left side?
1,485,408
<p>I'm attempting to write a basic Tkinter GUI that has a <code>Text</code> widget at the top, then a <code>Button</code> widget left aligned under it, then another <code>Text</code> widget underneath the button. The problem I'm having is, after packing the <code>Button</code> widget to the left, when I then go to pac...
5
2009-09-28T04:25:57Z
1,492,025
<p>There are generally two solutions to layout problems:</p> <ol> <li><p>switch to using grid. It becomes real easy to do layouts like what you are trying to accomplish. Grid can solve probably 95% of all layout issues (it's amazing when you think about it -- Tk does with one manager what most toolkits need half a doz...
10
2009-09-29T11:40:58Z
[ "python", "widget", "tkinter", "pack" ]
Resize image twice in Django using PIL
1,485,569
<p>I have a function in which I'm trying to resize a photo twice from request.FILES['image']. I'm using the image.thumbnail() with the Parser as well. This works fine when I create one thumbnail, but in my view if I repeat the exact same thing again, it fails in the parser via IOError cannot parse image. I'm very confu...
1
2009-09-28T05:39:33Z
1,485,904
<p>I'm assuming it's failing on the <code>image = parser.close()</code> line with an <code>IOError</code>. so there's probably something wrong with the way <code>ImageFile</code> is getting the image data. Have you tried making reading from a local file instead?</p> <blockquote> <p>If the parser managed to decode an...
0
2009-09-28T07:54:06Z
[ "python", "django", "image-manipulation", "python-imaging-library" ]
Resize image twice in Django using PIL
1,485,569
<p>I have a function in which I'm trying to resize a photo twice from request.FILES['image']. I'm using the image.thumbnail() with the Parser as well. This works fine when I create one thumbnail, but in my view if I repeat the exact same thing again, it fails in the parser via IOError cannot parse image. I'm very confu...
1
2009-09-28T05:39:33Z
1,485,913
<p>If this works once, as you say, the image you retrieved is just fine. There are at least two different ways to get multiple thumbnails out of single PIL images.</p> <ol> <li>You can use PIL's <code>resize</code> method, which will return a resized copy of the original. You just have to calculate the dimensions you'...
2
2009-09-28T07:57:57Z
[ "python", "django", "image-manipulation", "python-imaging-library" ]
Resize image twice in Django using PIL
1,485,569
<p>I have a function in which I'm trying to resize a photo twice from request.FILES['image']. I'm using the image.thumbnail() with the Parser as well. This works fine when I create one thumbnail, but in my view if I repeat the exact same thing again, it fails in the parser via IOError cannot parse image. I'm very confu...
1
2009-09-28T05:39:33Z
1,781,378
<p>A simpler solution than copying the original image is to instead reset the file pointer between calls to thumbnail(...) like so:</p> <pre><code>original.seek(0) </code></pre>
2
2009-11-23T06:11:41Z
[ "python", "django", "image-manipulation", "python-imaging-library" ]
Using mechanize to visit a site that requires SSL
1,485,571
<p>I need to visit a site (https://*) that requires me to install two certificates in Firefox before I can visit it successfully. One I can export as a .p12 file (Client Certificate), and one is a .crt file (CA Certificate). If I try accessing this site without these certificates, I get a "failed handshake error".</p> ...
2
2009-09-28T05:40:23Z
1,486,139
<p>I'd suggest you use <a href="http://code.google.com/p/webdriver/" rel="nofollow">webdriver</a> to automate Firefox. It has a Python interface too.</p>
1
2009-09-28T09:22:37Z
[ "python", "ssl", "ssl-certificate", "mechanize" ]
Return a list of dictionaries that match the corresponding list of values in python
1,485,660
<p>For example, this is my list of dictionaries: </p> <pre><code>[{'name': 'John', 'color': 'red' }, {'name': 'Bob', 'color': 'green'}, {'name': 'Tom', 'color': 'blue' }] </code></pre> <p>Based on the list <code>['blue', 'red', 'green']</code> I want to return the following:</p> <pre><code>[{'name': 'Tom', 'co...
2
2009-09-28T06:15:14Z
1,485,695
<p>Update:</p> <pre><code>&gt;&gt;&gt; list_ = [{'c': 3}, {'c': 2}, {'c': 5}] &gt;&gt;&gt; mp = [3, 5, 2] &gt;&gt;&gt; sorted(list_, cmp=lambda x, y: cmp(mp.index(x.get('c')), mp.index(y.get('c')))) [{'c': 3}, {'c': 5}, {'c': 2}] </code></pre>
2
2009-09-28T06:32:46Z
[ "python", "dictionary" ]
Return a list of dictionaries that match the corresponding list of values in python
1,485,660
<p>For example, this is my list of dictionaries: </p> <pre><code>[{'name': 'John', 'color': 'red' }, {'name': 'Bob', 'color': 'green'}, {'name': 'Tom', 'color': 'blue' }] </code></pre> <p>Based on the list <code>['blue', 'red', 'green']</code> I want to return the following:</p> <pre><code>[{'name': 'Tom', 'co...
2
2009-09-28T06:15:14Z
1,485,698
<p>Here is a simple loop function:</p> <pre><code># Heres the people: people = [{'name':'John', 'color':'red'}, {'name':'Bob', 'color':'green'}, {'name':'Tom', 'color':'blue'}] # Now we can make a method to get people out in order by color: def orderpeople(order): for color in order: ...
0
2009-09-28T06:35:07Z
[ "python", "dictionary" ]
Return a list of dictionaries that match the corresponding list of values in python
1,485,660
<p>For example, this is my list of dictionaries: </p> <pre><code>[{'name': 'John', 'color': 'red' }, {'name': 'Bob', 'color': 'green'}, {'name': 'Tom', 'color': 'blue' }] </code></pre> <p>Based on the list <code>['blue', 'red', 'green']</code> I want to return the following:</p> <pre><code>[{'name': 'Tom', 'co...
2
2009-09-28T06:15:14Z
1,485,721
<p>Given:</p> <pre><code>people = [{'name':'John', 'color':'red'}, {'name':'Bob', 'color':'green'}, {'name':'Tom', 'color':'blue'}] colors = ['blue', 'red', 'green'] </code></pre> <p>you can do something like this: </p> <pre><code>def people_by_color(people, colors): index = {} for person in people: if pe...
0
2009-09-28T06:41:57Z
[ "python", "dictionary" ]
Return a list of dictionaries that match the corresponding list of values in python
1,485,660
<p>For example, this is my list of dictionaries: </p> <pre><code>[{'name': 'John', 'color': 'red' }, {'name': 'Bob', 'color': 'green'}, {'name': 'Tom', 'color': 'blue' }] </code></pre> <p>Based on the list <code>['blue', 'red', 'green']</code> I want to return the following:</p> <pre><code>[{'name': 'Tom', 'co...
2
2009-09-28T06:15:14Z
1,485,722
<p>This might be a little naieve, but it works:</p> <pre><code>data = [ {'name':'John', 'color':'red'}, {'name':'Bob', 'color':'green'}, {'name':'Tom', 'color':'blue'} ] colors = ['blue', 'red', 'green'] result = [] for c in colors: result.extend([d for d in data if d['color'] == c]) print result </c...
4
2009-09-28T06:42:11Z
[ "python", "dictionary" ]
Return a list of dictionaries that match the corresponding list of values in python
1,485,660
<p>For example, this is my list of dictionaries: </p> <pre><code>[{'name': 'John', 'color': 'red' }, {'name': 'Bob', 'color': 'green'}, {'name': 'Tom', 'color': 'blue' }] </code></pre> <p>Based on the list <code>['blue', 'red', 'green']</code> I want to return the following:</p> <pre><code>[{'name': 'Tom', 'co...
2
2009-09-28T06:15:14Z
1,487,244
<p>You can <a href="http://docs.python.org/library/functions.html#sorted" rel="nofollow">sort</a> using any custom key function.</p> <pre><code>&gt;&gt;&gt; people = [ {'name': 'John', 'color': 'red'}, {'name': 'Bob', 'color': 'green'}, {'name': 'Tom', 'color': 'blue'}, ] &gt;&gt;&gt; colors = ['blue', 're...
1
2009-09-28T14:09:36Z
[ "python", "dictionary" ]
Return a list of dictionaries that match the corresponding list of values in python
1,485,660
<p>For example, this is my list of dictionaries: </p> <pre><code>[{'name': 'John', 'color': 'red' }, {'name': 'Bob', 'color': 'green'}, {'name': 'Tom', 'color': 'blue' }] </code></pre> <p>Based on the list <code>['blue', 'red', 'green']</code> I want to return the following:</p> <pre><code>[{'name': 'Tom', 'co...
2
2009-09-28T06:15:14Z
1,488,578
<p>Riffing on Harto's solution:</p> <pre><code>&gt;&gt;&gt; from pprint import pprint &gt;&gt;&gt; [{'color': 'red', 'name': 'John'}, ... {'color': 'green', 'name': 'Bob'}, ... {'color': 'blue', 'name': 'Tom'}] [{'color': 'red', 'name': 'John'}, {'color': 'green', 'name': 'Bob'}, {'color': 'blue', 'name': 'Tom'}] &g...
1
2009-09-28T18:26:14Z
[ "python", "dictionary" ]
Behaviour of increment and decrement operators in Python
1,485,841
<p>I notice that a pre-increment/decrement operator can be applied on a variable (like <code>++count</code>). It compiles, but it does not actually change the value of the variable!</p> <p>What is the behavior of the pre-increment/decrement operators (++/--) in Python? </p> <p>Why does Python deviate from the behavio...
397
2009-09-28T07:33:19Z
1,485,854
<p><code>++</code> is not an operator. It is two <code>+</code> operators. The <code>+</code> operator is the <strong>identity</strong> operator, which does nothing. (Clarification: the <code>+</code> and <code>-</code> unary operators only work on numbers, but I presume that you wouldn't expect a hypothetical <code>++...
529
2009-09-28T07:39:36Z
[ "python", "operators", "increment", "decrement" ]
Behaviour of increment and decrement operators in Python
1,485,841
<p>I notice that a pre-increment/decrement operator can be applied on a variable (like <code>++count</code>). It compiles, but it does not actually change the value of the variable!</p> <p>What is the behavior of the pre-increment/decrement operators (++/--) in Python? </p> <p>Why does Python deviate from the behavio...
397
2009-09-28T07:33:19Z
1,486,086
<p>When you want to increment or decrement, you typically want to do that on an integer. Like so:</p> <pre><code>b++ </code></pre> <p>But in Python, integers are <strong>immutable</strong>. That is you can't change them. This is because the integer objects can be used under several names. Try this:</p> <pre><code>&g...
251
2009-09-28T09:05:01Z
[ "python", "operators", "increment", "decrement" ]
Behaviour of increment and decrement operators in Python
1,485,841
<p>I notice that a pre-increment/decrement operator can be applied on a variable (like <code>++count</code>). It compiles, but it does not actually change the value of the variable!</p> <p>What is the behavior of the pre-increment/decrement operators (++/--) in Python? </p> <p>Why does Python deviate from the behavio...
397
2009-09-28T07:33:19Z
8,537,187
<blockquote> <p>In Python, a distinction between expressions and statements is rigidly enforced, in contrast to languages such as Common Lisp, Scheme, or Ruby.</p> </blockquote> <p><a href="http://en.wikipedia.org/wiki/Python_%28programming_language%29#Expressions" rel="nofollow">Wikipedia</a></p> <p>So by intr...
3
2011-12-16T16:33:46Z
[ "python", "operators", "increment", "decrement" ]
Behaviour of increment and decrement operators in Python
1,485,841
<p>I notice that a pre-increment/decrement operator can be applied on a variable (like <code>++count</code>). It compiles, but it does not actually change the value of the variable!</p> <p>What is the behavior of the pre-increment/decrement operators (++/--) in Python? </p> <p>Why does Python deviate from the behavio...
397
2009-09-28T07:33:19Z
11,210,198
<p>While the others answers are correct in so far as they show what a mere <code>+</code> usually does (namely, leave the number as it is, if it is one), they are incomplete in so far as they don't explain what happens.</p> <p>To be exact, <code>+x</code> evaluates to <code>x.__pos__()</code> and <code>++x</code> to <...
30
2012-06-26T14:59:33Z
[ "python", "operators", "increment", "decrement" ]
Behaviour of increment and decrement operators in Python
1,485,841
<p>I notice that a pre-increment/decrement operator can be applied on a variable (like <code>++count</code>). It compiles, but it does not actually change the value of the variable!</p> <p>What is the behavior of the pre-increment/decrement operators (++/--) in Python? </p> <p>Why does Python deviate from the behavio...
397
2009-09-28T07:33:19Z
26,204,203
<p>Python does not have these operators, but if you really need them you can write a function having the same functionality.</p> <pre><code>def PreIncrement(name, local={}): #Equivalent to ++name if name in local: local[name]+=1 return local[name] globals()[name]+=1 return globals()[nam...
4
2014-10-05T15:37:15Z
[ "python", "operators", "increment", "decrement" ]
Behaviour of increment and decrement operators in Python
1,485,841
<p>I notice that a pre-increment/decrement operator can be applied on a variable (like <code>++count</code>). It compiles, but it does not actually change the value of the variable!</p> <p>What is the behavior of the pre-increment/decrement operators (++/--) in Python? </p> <p>Why does Python deviate from the behavio...
397
2009-09-28T07:33:19Z
30,335,713
<p>Yeah, I missed ++ and -- functionality as well. A few million lines of c code engrained that kind of thinking in my old head, and rather than fight it... Here's a class I cobbled up that implements:</p> <pre><code>pre- and post-increment, pre- and post-decrement, addition, subtraction, multiplication, division, res...
1
2015-05-19T20:40:43Z
[ "python", "operators", "increment", "decrement" ]
Get django-paypal working with pycrypto?
1,485,903
<p>I would like to use the button encryption in django-paypal, but it requires M2Crypto which will not build on webfaction servers. Tech support at Webfaction told me that pycrypto is already installed on the system, but I am too dumb to translate from M2Crypto to pycrypto.</p> <p>Can anyone tell me how to convert th...
1
2009-09-28T07:53:53Z
1,486,435
<p>pycrypto is very incomplete. It does not support the padding schemes and formats that you need. Adding support for those formats is not trivial and will require a lot of time.</p>
1
2009-09-28T10:52:09Z
[ "python", "django", "encryption", "paypal" ]
Get django-paypal working with pycrypto?
1,485,903
<p>I would like to use the button encryption in django-paypal, but it requires M2Crypto which will not build on webfaction servers. Tech support at Webfaction told me that pycrypto is already installed on the system, but I am too dumb to translate from M2Crypto to pycrypto.</p> <p>Can anyone tell me how to convert th...
1
2009-09-28T07:53:53Z
1,509,462
<p>You may be able to set up a virtual machine locally and duplicate enough of the webfaction server environment to build it yourself. Then upload to somewhere on your pythonpath</p>
0
2009-10-02T13:18:50Z
[ "python", "django", "encryption", "paypal" ]
Get django-paypal working with pycrypto?
1,485,903
<p>I would like to use the button encryption in django-paypal, but it requires M2Crypto which will not build on webfaction servers. Tech support at Webfaction told me that pycrypto is already installed on the system, but I am too dumb to translate from M2Crypto to pycrypto.</p> <p>Can anyone tell me how to convert th...
1
2009-09-28T07:53:53Z
1,723,932
<p>I was able to get it to build. Here is all you need to do to make it happen:</p> <pre><code>cat &gt;&gt; ~/.pydistutils.cfg &lt;&lt; EOF [build_ext] include_dirs=/usr/include/openssl EOF easy_install-2.5 --install-dir=$HOME/lib/python2.5 --script-dir=$HOME/bin m2crypto </code></pre>
2
2009-11-12T17:24:22Z
[ "python", "django", "encryption", "paypal" ]
an auth method over HTTP(s) and/or REST with libraries for Python and/or C++
1,486,056
<p>Because I don't exactly know how any auth method works I want to write my own. So, what I want to do is the following. A client sends over HTTPs username+password(or SHA1(username+password)) the server gets the username+password and generates a big random number and stores it in a table called TOKENS(in some datab...
0
2009-09-28T08:57:06Z
1,486,073
<p>If you are implementing such authentication system over ordinary HTTP, you are vulnerable to replay attacks. Attacker could sniff out the SHA1(username+password) and just resend it every time he/she wants to log in. To make such authentication system work, you will need to use a <a href="http://en.wikipedia.org/wiki...
0
2009-09-28T09:01:34Z
[ "c++", "python", "http", "authentication", "rest" ]
an auth method over HTTP(s) and/or REST with libraries for Python and/or C++
1,486,056
<p>Because I don't exactly know how any auth method works I want to write my own. So, what I want to do is the following. A client sends over HTTPs username+password(or SHA1(username+password)) the server gets the username+password and generates a big random number and stores it in a table called TOKENS(in some datab...
0
2009-09-28T08:57:06Z
1,607,123
<blockquote> <p>Because I don't exactly know how any auth method works I want to write my own</p> </blockquote> <p>How could you ever write something you don't understand? Learn at least one, the underlaying concepts are similar in every library.</p> <p>Python has <a href="http://what.repoze.org/docs/1.x/" rel="nof...
0
2009-10-22T13:17:54Z
[ "c++", "python", "http", "authentication", "rest" ]
an auth method over HTTP(s) and/or REST with libraries for Python and/or C++
1,486,056
<p>Because I don't exactly know how any auth method works I want to write my own. So, what I want to do is the following. A client sends over HTTPs username+password(or SHA1(username+password)) the server gets the username+password and generates a big random number and stores it in a table called TOKENS(in some datab...
0
2009-09-28T08:57:06Z
1,656,178
<p>I would highly recommend <a href="http://oauth.net/" rel="nofollow">OAuth</a> here, for which many open source <a href="http://oauth.net/code" rel="nofollow">libraries</a> are available.</p>
0
2009-11-01T02:09:34Z
[ "c++", "python", "http", "authentication", "rest" ]
Python PIL cannot locate my "libjpeg"
1,486,157
<p>I cannot use PIL because it cannot find my libjpeg!</p> <p>First, I installed PIL default. And when I ran the <code>selftest.py</code>, it gave me:</p> <pre><code>IOError: decoder jpeg not available 1 items had failures: 1 of 57 in selftest.testimage ***Test Failed*** 1 failures. *** 1 tests of 57 failed. </co...
11
2009-09-28T09:29:42Z
1,486,262
<p>You need the libjpeg headers as well, not only the library itself. Those packages are typically called something ending in headers or dev, depending on what distribution you have.</p>
3
2009-09-28T10:00:17Z
[ "python", "python-imaging-library" ]
Python PIL cannot locate my "libjpeg"
1,486,157
<p>I cannot use PIL because it cannot find my libjpeg!</p> <p>First, I installed PIL default. And when I ran the <code>selftest.py</code>, it gave me:</p> <pre><code>IOError: decoder jpeg not available 1 items had failures: 1 of 57 in selftest.testimage ***Test Failed*** 1 failures. *** 1 tests of 57 failed. </co...
11
2009-09-28T09:29:42Z
1,489,390
<p>There at least 3 header sets that you will want to install. 1 more if you want to deal with Tiff's</p> <p>freetype, libjpeg, zlib all of which will be in the following packages on CentOS:</p> <p>== 32 Bit: zlib-devel.i386 libjpeg-devel.i386 freetype-devel.i386</p> <p>== 64 Bit: zlib-devel.x86_64 libjpeg...
19
2009-09-28T21:09:49Z
[ "python", "python-imaging-library" ]
Python PIL cannot locate my "libjpeg"
1,486,157
<p>I cannot use PIL because it cannot find my libjpeg!</p> <p>First, I installed PIL default. And when I ran the <code>selftest.py</code>, it gave me:</p> <pre><code>IOError: decoder jpeg not available 1 items had failures: 1 of 57 in selftest.testimage ***Test Failed*** 1 failures. *** 1 tests of 57 failed. </co...
11
2009-09-28T09:29:42Z
7,839,593
<p>Today I was facing the same problem, and I've found the solution. Basically it involves remove the PIL, install lipjpeg through Fink and re-install the PIL.</p> <p>I wrote an <a href="http://marciogarcia.com/?p=289" rel="nofollow">article</a> telling step by step how to do that. If interesting check this out.</p>
0
2011-10-20T17:11:33Z
[ "python", "python-imaging-library" ]
Python PIL cannot locate my "libjpeg"
1,486,157
<p>I cannot use PIL because it cannot find my libjpeg!</p> <p>First, I installed PIL default. And when I ran the <code>selftest.py</code>, it gave me:</p> <pre><code>IOError: decoder jpeg not available 1 items had failures: 1 of 57 in selftest.testimage ***Test Failed*** 1 failures. *** 1 tests of 57 failed. </co...
11
2009-09-28T09:29:42Z
9,573,684
<p>I had the same issue. In my case, I need to set:</p> <pre><code>JPEG_ROOT="/usr/lib64/" </code></pre> <p>instead of:</p> <pre><code>JPEG_ROOT="/usr/lib/" </code></pre> <p>Good luck.</p>
3
2012-03-05T20:42:49Z
[ "python", "python-imaging-library" ]
Python PIL cannot locate my "libjpeg"
1,486,157
<p>I cannot use PIL because it cannot find my libjpeg!</p> <p>First, I installed PIL default. And when I ran the <code>selftest.py</code>, it gave me:</p> <pre><code>IOError: decoder jpeg not available 1 items had failures: 1 of 57 in selftest.testimage ***Test Failed*** 1 failures. *** 1 tests of 57 failed. </co...
11
2009-09-28T09:29:42Z
15,498,524
<p>You could also try to use <a href="https://pypi.python.org/pypi/Pillow" rel="nofollow">Pillow</a> instead of PIL. </p> <p>Pillow is a PIL fork to "foster active development of PIL". In versions 1.7.0 and 1.7.1 they made some changes to support multi-arch (see the <a href="https://pypi.python.org/pypi/Pillow/2.0.0#c...
1
2013-03-19T11:41:54Z
[ "python", "python-imaging-library" ]
pyinotify.ThreadedNotifier, process_* not called
1,486,271
<p>I have a problem with pyinotify: the methods <code>process_*()</code> of the <code>ProcessEvent</code> are not called</p> <p>The code</p> <pre><code>import sys, time, syslog from pyinotify import WatchManager, Notifier, ThreadedNotifier, ProcessEvent, EventsCodes from daemon import Daemon class PTmp(ProcessEvent...
3
2009-09-28T10:02:14Z
1,486,845
<p>The problem was missing the import of IN_*, which has to be done manually. I've found that out after calling </p> <pre><code>daemon.run() </code></pre> <p>instead of </p> <pre><code>daemon.start() </code></pre> <p>thus making the script run in foreground.</p>
1
2009-09-28T12:50:21Z
[ "python", "inotify", "pyinotify" ]
pyinotify.ThreadedNotifier, process_* not called
1,486,271
<p>I have a problem with pyinotify: the methods <code>process_*()</code> of the <code>ProcessEvent</code> are not called</p> <p>The code</p> <pre><code>import sys, time, syslog from pyinotify import WatchManager, Notifier, ThreadedNotifier, ProcessEvent, EventsCodes from daemon import Daemon class PTmp(ProcessEvent...
3
2009-09-28T10:02:14Z
8,779,752
<p>masks are defined in EventCodes.ALL_FLAGS</p> <pre><code> mask = EventsCodes.ALL_FLAGS['IN_DELETE'] mask = EventsCodes.ALL_FLAGS['ALL_EVENTS'] </code></pre>
1
2012-01-08T17:47:04Z
[ "python", "inotify", "pyinotify" ]
Parsing commandline output progression containing carriage returns in real time with python
1,486,305
<p>I am able to transform carriage returns into new lines. The problem however is to get it running in nearly 'real time'. It will be quite stupid looking if progres bar only values are 0 and 100 :-)</p> <p>This code returns output at once:</p> <pre><code>import subprocess p = subprocess.Popen(['mplayer', '/home/use...
1
2009-09-28T10:13:33Z
1,486,561
<p>You need to do two things:</p> <ol> <li><p>You must make sure that <code>mplayer</code> flushes the output for every line (should happen with progress output that gets printed into the same line).</p></li> <li><p>You must read the output line by line. Instead of calling <code>communicate()</code>, you must close th...
-1
2009-09-28T11:26:35Z
[ "python", "parsing", "real-time", "carriage-return" ]
Parsing commandline output progression containing carriage returns in real time with python
1,486,305
<p>I am able to transform carriage returns into new lines. The problem however is to get it running in nearly 'real time'. It will be quite stupid looking if progres bar only values are 0 and 100 :-)</p> <p>This code returns output at once:</p> <pre><code>import subprocess p = subprocess.Popen(['mplayer', '/home/use...
1
2009-09-28T10:13:33Z
1,486,925
<p>You are in for a world of pain with buffering in my experience. The reason being is that the standard C library will detect stdout isn't connected to a terminal and use more buffering. There is nothing you can do about that except hack the source of <code>mplayer</code>.</p> <p>If you use <a href="http://pexpect....
1
2009-09-28T13:07:28Z
[ "python", "parsing", "real-time", "carriage-return" ]
Parsing commandline output progression containing carriage returns in real time with python
1,486,305
<p>I am able to transform carriage returns into new lines. The problem however is to get it running in nearly 'real time'. It will be quite stupid looking if progres bar only values are 0 and 100 :-)</p> <p>This code returns output at once:</p> <pre><code>import subprocess p = subprocess.Popen(['mplayer', '/home/use...
1
2009-09-28T10:13:33Z
1,487,556
<p><a href="http://pexpect.sourceforge.net/pexpect.html" rel="nofollow">pexpect</a> anywhere but Windows, and <a href="http://sage.math.washington.edu/home/goreckc/sage/wexpect/" rel="nofollow">wexpect</a> on Windows, are always my recommendations when you need to "defeat buffering" and read a subprocess's output "in n...
2
2009-09-28T15:04:19Z
[ "python", "parsing", "real-time", "carriage-return" ]
Parsing commandline output progression containing carriage returns in real time with python
1,486,305
<p>I am able to transform carriage returns into new lines. The problem however is to get it running in nearly 'real time'. It will be quite stupid looking if progres bar only values are 0 and 100 :-)</p> <p>This code returns output at once:</p> <pre><code>import subprocess p = subprocess.Popen(['mplayer', '/home/use...
1
2009-09-28T10:13:33Z
1,501,457
<p>Ok, Thanks! I will keep on eye for pexpect. But I found out that there is cosplatform way to do it: PyQt4 and QProcess. While it is not certainly solution for every program, it certainly fits for Qt4 frontend application :)</p>
0
2009-10-01T01:20:42Z
[ "python", "parsing", "real-time", "carriage-return" ]
Evaluating into two or more lists
1,486,558
<p>Howdy, codeboys and codegirls!</p> <p>I have came across a simple problem with seemingly easy solution. But being a Python neophyte I feel that there is a better approach somewhere.</p> <p>Say you have a list of mixed strings. There are two basic types of strings in the sack - ones with "=" in them (a=potato) and ...
5
2009-09-28T11:24:59Z
1,486,574
<p>Try</p> <pre><code>for arg in arguments: lst = equal if '=' in arg else plain lst.append(arg) </code></pre> <p>or (holy ugly)</p> <pre><code>for arg in arguments: (equal if '=' in arg else plain).append(arg) </code></pre> <p>A third option: Create a class which offers <code>append()</code> and which ...
4
2009-09-28T11:30:21Z
[ "python", "list" ]
Evaluating into two or more lists
1,486,558
<p>Howdy, codeboys and codegirls!</p> <p>I have came across a simple problem with seemingly easy solution. But being a Python neophyte I feel that there is a better approach somewhere.</p> <p>Say you have a list of mixed strings. There are two basic types of strings in the sack - ones with "=" in them (a=potato) and ...
5
2009-09-28T11:24:59Z
1,486,611
<p>You can use <a href="http://docs.python.org/library/itertools.html#itertools.groupby" rel="nofollow"><code>itertools.groupby()</code></a> for this:</p> <pre><code>import itertools f = lambda x: '=' in x groups = itertools.groupby(sorted(data, key=f), key=f) for k, g in groups: print k, list(g) </code></pre>
4
2009-09-28T11:39:45Z
[ "python", "list" ]
Evaluating into two or more lists
1,486,558
<p>Howdy, codeboys and codegirls!</p> <p>I have came across a simple problem with seemingly easy solution. But being a Python neophyte I feel that there is a better approach somewhere.</p> <p>Say you have a list of mixed strings. There are two basic types of strings in the sack - ones with "=" in them (a=potato) and ...
5
2009-09-28T11:24:59Z
1,486,663
<p>Another approach is to use the <code>filter</code> function, although it's not the most efficient solution.<br /> Example:</p> <pre><code>&gt;&gt;&gt; l = ['a=s','aa','bb','=', 'a+b'] &gt;&gt;&gt; l2 = filter(lambda s: '=' in s, l) &gt;&gt;&gt; l3 = filter(lambda s: '+' in s, l) &gt;&gt;&gt; l2 ['a=s', '='] &gt;&gt...
1
2009-09-28T11:54:58Z
[ "python", "list" ]
Evaluating into two or more lists
1,486,558
<p>Howdy, codeboys and codegirls!</p> <p>I have came across a simple problem with seemingly easy solution. But being a Python neophyte I feel that there is a better approach somewhere.</p> <p>Say you have a list of mixed strings. There are two basic types of strings in the sack - ones with "=" in them (a=potato) and ...
5
2009-09-28T11:24:59Z
1,486,676
<pre><code>def which_list(s): if "=" in s: return 1 return 0 lists = [[], []] for arg in arguments: lists[which_list(arg)].append(arg) plain, equal = lists </code></pre> <p>If you have more types of data, add an if clause to <code>which_list</code>, and initialize <code>lists</code> to more emp...
2
2009-09-28T11:57:39Z
[ "python", "list" ]
Evaluating into two or more lists
1,486,558
<p>Howdy, codeboys and codegirls!</p> <p>I have came across a simple problem with seemingly easy solution. But being a Python neophyte I feel that there is a better approach somewhere.</p> <p>Say you have a list of mixed strings. There are two basic types of strings in the sack - ones with "=" in them (a=potato) and ...
5
2009-09-28T11:24:59Z
1,486,714
<p>I would just go for two list comprehensions. While that does incur some overhead (two loops on the list), it is more Pythonic to use a list comprehension than to use a for. It's also (in my mind) much more readable than using all sorts of really cool tricks, but that less people know about.</p>
3
2009-09-28T12:12:03Z
[ "python", "list" ]
Evaluating into two or more lists
1,486,558
<p>Howdy, codeboys and codegirls!</p> <p>I have came across a simple problem with seemingly easy solution. But being a Python neophyte I feel that there is a better approach somewhere.</p> <p>Say you have a list of mixed strings. There are two basic types of strings in the sack - ones with "=" in them (a=potato) and ...
5
2009-09-28T11:24:59Z
1,486,820
<p>I put this together, and then see that Ned Batchelder was already on this same tack. I chose to package the splitting method instead of the list chooser, though, and to just use the implicit 0/1 values for False and True.</p> <pre><code>def split_on_condition(source, condition): ret = [],[] for s in source...
1
2009-09-28T12:43:58Z
[ "python", "list" ]
Evaluating into two or more lists
1,486,558
<p>Howdy, codeboys and codegirls!</p> <p>I have came across a simple problem with seemingly easy solution. But being a Python neophyte I feel that there is a better approach somewhere.</p> <p>Say you have a list of mixed strings. There are two basic types of strings in the sack - ones with "=" in them (a=potato) and ...
5
2009-09-28T11:24:59Z
1,486,870
<p>Your approach is the best one. For sorting just into two lists it can't get clearer than that. If you want it to be a one-liner, encapsulate it in a function:</p> <pre><code>def classify(arguments): equal, plain = [], [] for arg in arguments: if '=' in arg: equal.append(arg) else...
1
2009-09-28T12:54:19Z
[ "python", "list" ]
Evaluating into two or more lists
1,486,558
<p>Howdy, codeboys and codegirls!</p> <p>I have came across a simple problem with seemingly easy solution. But being a Python neophyte I feel that there is a better approach somewhere.</p> <p>Say you have a list of mixed strings. There are two basic types of strings in the sack - ones with "=" in them (a=potato) and ...
5
2009-09-28T11:24:59Z
1,486,915
<p>I would go for Edan's approach, e.g.</p> <pre><code>equal = [arg for arg in arguments if '=' in arg] plain = [arg for arg in arguments if '=' not in arg] </code></pre>
2
2009-09-28T13:05:50Z
[ "python", "list" ]
Evaluating into two or more lists
1,486,558
<p>Howdy, codeboys and codegirls!</p> <p>I have came across a simple problem with seemingly easy solution. But being a Python neophyte I feel that there is a better approach somewhere.</p> <p>Say you have a list of mixed strings. There are two basic types of strings in the sack - ones with "=" in them (a=potato) and ...
5
2009-09-28T11:24:59Z
1,489,938
<p>I read somewhere here that you might be interested in a solution that will work for <em>more</em> than two identifiers (equals sign and space). </p> <p>The following solution just requires you update the <code>uniques</code> set with anything you would like to match, the results are placed in a dictionary of lists ...
2
2009-09-29T00:06:19Z
[ "python", "list" ]
Global statements v. variables available throughout a classes
1,486,708
<p>I try to avoid "global" statements in python and <a href="http://stackoverflow.com/questions/146557/do-you-use-the-global-statement-in-python">http://stackoverflow.com/questions/146557/do-you-use-the-global-statement-in-python</a> suggests this is a common view. Values go into a function through its arguments and c...
0
2009-09-28T12:08:46Z
1,486,759
<p>self.variable is not global to the class, it's global to the instance. There's a big difference:</p> <pre><code>class MyClass: def __init__(self, a): self.a = a mc1 = MyClass(1) mc2 = MyClass(2) assert mc1.a == 1 assert mc2.a == 2 </code></pre> <p>You should definitely use self to encapsulate data in...
1
2009-09-28T12:27:43Z
[ "python", "design" ]
Global statements v. variables available throughout a classes
1,486,708
<p>I try to avoid "global" statements in python and <a href="http://stackoverflow.com/questions/146557/do-you-use-the-global-statement-in-python">http://stackoverflow.com/questions/146557/do-you-use-the-global-statement-in-python</a> suggests this is a common view. Values go into a function through its arguments and c...
0
2009-09-28T12:08:46Z
1,486,913
<blockquote> <p>Do the same reasons we should avoid globals apply within classes, so that we should only use values in methods that come in through its arguments? I'm especially thinking about long classes that can be just about an entire program.</p> </blockquote> <p>Classes exist to couple behaviour wi...
1
2009-09-28T13:05:29Z
[ "python", "design" ]
Global statements v. variables available throughout a classes
1,486,708
<p>I try to avoid "global" statements in python and <a href="http://stackoverflow.com/questions/146557/do-you-use-the-global-statement-in-python">http://stackoverflow.com/questions/146557/do-you-use-the-global-statement-in-python</a> suggests this is a common view. Values go into a function through its arguments and c...
0
2009-09-28T12:08:46Z
1,486,922
<p>Ideally, no instance-wide variables would be used and everything would be passed as a parameter and well-documented in comments. That being said, it can get very tedious to comment every little thing and method parameter lists can start to look ridiculous (unless you have a hierarchy of partially-applied methods). P...
-1
2009-09-28T13:07:07Z
[ "python", "design" ]
python multiprocessing proxy
1,486,835
<p>I have a 2 processes:</p> <p>the first process is <strong>manager.py</strong> starts in <strong>backgroung</strong>:</p> <pre><code>from multiprocessing.managers import SyncManager, BaseProxy from CompositeDict import * class CompositeDictProxy(BaseProxy): _exposed_ = ('addChild', 'setName') def addChil...
1
2009-09-28T12:47:28Z
1,487,717
<p>Besides fixing many other bugs in the above which I assume are accidental (<code>init</code> must be <code>__init__</code>, you're missing several instances of <code>self</code>, misindentation, etc, etc), the key bit is to make the registration in <code>manager.py</code> into:</p> <pre><code>Manager.register('get_...
1
2009-09-28T15:29:57Z
[ "python", "proxy", "multiprocessing", "composite" ]
Python: pass c++ object to a script, then invoke extending c++ function from script
1,487,001
<p>First of all, the problem is that program fails with double memory freeing ...</p> <p>The deal is: I have </p> <pre><code>FooCPlusPlus *obj; </code></pre> <p>and I pass it to my script. It works fine. Like this:</p> <pre><code>PyObject *pArgs, *pValue; pArgs = Py_BuildValue("((O))", obj); pValue = PyObject_CallO...
0
2009-09-28T13:22:57Z
1,488,017
<p>Well, finally I know where the problem was:</p> <p>we should return from "bar" function input args:</p> <pre><code>return args; </code></pre> <p>instead of</p> <pre><code>return PyCObject_FromVoidPtr((void *) ruleHandler, NULL); </code></pre>
0
2009-09-28T16:30:23Z
[ "python", "reference-counting" ]
python/scapy mac flooding script
1,487,389
<p>I'm trying to make a small mac flood tool in python to fill my switches cam tables but i cant make the magic happen? can you see what im doing wrong? </p> <pre><code>from scapy.all import * while 1: dest_mac = RandMAC() src_mac = RandMAC() sendp(Ether(src=src_mac, dst=dest_mac)/ARP(op=2, psrc="0.0.0.0", hwsrc...
1
2009-09-28T14:35:52Z
3,515,056
<p>You can only use some mac address: a mac address is composed by six groups of two hexadecimal digits, separated by hyphens (-) or colons (:). The first three fields must be filled with some values, different for every vendor. If this fields are not set with any vendor code the server (or the client) will drop the pa...
1
2010-08-18T17:53:52Z
[ "python", "scapy" ]
python/scapy mac flooding script
1,487,389
<p>I'm trying to make a small mac flood tool in python to fill my switches cam tables but i cant make the magic happen? can you see what im doing wrong? </p> <pre><code>from scapy.all import * while 1: dest_mac = RandMAC() src_mac = RandMAC() sendp(Ether(src=src_mac, dst=dest_mac)/ARP(op=2, psrc="0.0.0.0", hwsrc...
1
2009-09-28T14:35:52Z
10,209,040
<p>Emada,</p> <p>Mac addresses are learned by switches by using the source address only so no need to worry about destination randomizing.</p> <p>I have tested this and it seems to work well..you might also want to try the sendpfast option for flooding, however in my testing here sendp seemed to work faster?</p> <pr...
0
2012-04-18T12:06:57Z
[ "python", "scapy" ]
Time difference between system date and string, e.g. from directory name?
1,487,450
<p>I would like to write a small script that does the following (and that I can then run using my crontab):</p> <ul> <li><p>Look into a directory that contains directories whose names are in some date format, e.g. 30-10-09.</p></li> <li><p>Convert the directory name to the date it represents (of course, I could put th...
0
2009-09-28T14:45:52Z
1,487,702
<p>I would suggest using Python. You'll need the following functions:</p> <ul> <li>os.listdir gives you the directory contents, as a list of strings</li> <li><code>time.strptime(name, "%d-%m-%y")</code> will try to parse such a string, and return a time tuple. You get a ValueError exception if parsing fails.</li> <li>...
1
2009-09-28T15:28:13Z
[ "python", "date", "scripting" ]
Pytom matplotlib 3d bar function
1,487,463
<p>How to add strings to the axes in Axes3D instead of numbers?</p> <p>I just started using the matplotlib. I have used Axes3dD to plot similar to the example given on their website (http://matplotlib.sourceforge.net/examples/mplot3d/bars3d_demo.html). Note that one must use the last verson (matplotlib 0.99.1), otherw...
1
2009-09-28T14:47:27Z
1,489,446
<p>Your actually on the right path there. but instead of a string you will want to pass a list or tuple to set_xticklabels(). You may also wish to adjust the center location for the label with set_xticks().</p> <p>You may also find this function of use get_xmajorticklabels(). It will return the rendered tick labels. S...
2
2009-09-28T21:20:39Z
[ "python", "matplotlib" ]
Pytom matplotlib 3d bar function
1,487,463
<p>How to add strings to the axes in Axes3D instead of numbers?</p> <p>I just started using the matplotlib. I have used Axes3dD to plot similar to the example given on their website (http://matplotlib.sourceforge.net/examples/mplot3d/bars3d_demo.html). Note that one must use the last verson (matplotlib 0.99.1), otherw...
1
2009-09-28T14:47:27Z
1,489,727
<p>Also retrieve the axis data, work on that and set it back to the renderer, turned out to be much simpler for me ;) other than that, what NerdyNick says</p>
0
2009-09-28T22:43:30Z
[ "python", "matplotlib" ]