title
stringlengths
10
172
question_id
int64
469
40.1M
question_body
stringlengths
22
48.2k
question_score
int64
-44
5.52k
question_date
stringlengths
20
20
answer_id
int64
497
40.1M
answer_body
stringlengths
18
33.9k
answer_score
int64
-38
8.38k
answer_date
stringlengths
20
20
tags
list
Bash while loop calling a Python script
2,359,896
<p>I would like to call a Python script from within a Bash while loop. However, I do not understand very well how to use appropriately the while loop (and maybe variable) syntax of the Bash. The behaviour I am looking for is that, while a file still contains lines (DNA sequences), I am calling a Python script to extrac...
1
2010-03-01T23:30:31Z
2,359,930
<p>No idea why you want to do this.</p> <pre><code>c=1 while [[ -s file.txt ]] ; # Stop when file.txt has no more lines do echo "Python script called $c times" python script.py # Uses file.txt and removes lines from it c=$(($c + 1)) done </code></pre>
3
2010-03-01T23:37:52Z
[ "python", "bash", "while-loop" ]
Bash while loop calling a Python script
2,359,896
<p>I would like to call a Python script from within a Bash while loop. However, I do not understand very well how to use appropriately the while loop (and maybe variable) syntax of the Bash. The behaviour I am looking for is that, while a file still contains lines (DNA sequences), I am calling a Python script to extrac...
1
2010-03-01T23:30:31Z
2,359,977
<p>The following should do what you say you want:</p> <pre><code>#!/bin/bash c=1 while read line; do echo "Python script called $c times" # $line contains a line of text from file.txt python script.py c=$((c + 1)) done &lt; file.txt </code></pre> <p>However, there is no need to use bash, to iterate...
0
2010-03-01T23:46:38Z
[ "python", "bash", "while-loop" ]
Bash while loop calling a Python script
2,359,896
<p>I would like to call a Python script from within a Bash while loop. However, I do not understand very well how to use appropriately the while loop (and maybe variable) syntax of the Bash. The behaviour I am looking for is that, while a file still contains lines (DNA sequences), I am calling a Python script to extrac...
1
2010-03-01T23:30:31Z
2,360,011
<p>@OP if you want to loop through a file , just use while read loop. Also, you are not using the variables $c as well as the line. Are you passing each line to your Python script? Or you just calling your Python script whenever a line is encountered? (your script going to be slow if you do that)</p> <pre><code>while ...
0
2010-03-01T23:53:25Z
[ "python", "bash", "while-loop" ]
Pure Python in Xcode?
2,359,994
<p>Could anyone tell me how to use pure Python without Cocoa support in Xcode? I can only find the Cocoa-Python template on the Internet.</p> <p>Thanks in advance.</p>
3
2010-03-01T23:49:13Z
2,360,374
<p>If you are just trying to write pure Python command line tools, using Xcode is like using a big sledge hammer to hit a tiny nail, in other words, probably not the best tool for the job. There are some old posts out there about how to set up a pure Python Xcode project, like <a href="http://www.mactech.com/articles/...
7
2010-03-02T01:41:35Z
[ "python", "xcode" ]
Pure Python in Xcode?
2,359,994
<p>Could anyone tell me how to use pure Python without Cocoa support in Xcode? I can only find the Cocoa-Python template on the Internet.</p> <p>Thanks in advance.</p>
3
2010-03-01T23:49:13Z
2,360,692
<p>Just about the best IDE for editing and running Python code is actually still emacs. The python-mode for emacs does a wonderful job of maintaining whitespace and, with a bit of configuration, emacs is truly a powerful editor.</p> <p>Pretty radically different than your typical GUI editor, certainly, and some find ...
0
2010-03-02T03:18:55Z
[ "python", "xcode" ]
Pure Python in Xcode?
2,359,994
<p>Could anyone tell me how to use pure Python without Cocoa support in Xcode? I can only find the Cocoa-Python template on the Internet.</p> <p>Thanks in advance.</p>
3
2010-03-01T23:49:13Z
2,360,880
<p>A lot of people like eclipse with PyDev for python, although I don't know how wel it works on OS X with apple's mishandling of java.</p>
0
2010-03-02T04:19:57Z
[ "python", "xcode" ]
Pure Python in Xcode?
2,359,994
<p>Could anyone tell me how to use pure Python without Cocoa support in Xcode? I can only find the Cocoa-Python template on the Internet.</p> <p>Thanks in advance.</p>
3
2010-03-01T23:49:13Z
2,361,909
<p>Even though I am using BBEdit, I found Wingware Python editor did a good job in exploiting the introspected data of Python modules. Purely designed for Python. Give it a try.</p> <p><a href="http://www.wingide.com/" rel="nofollow">http://www.wingide.com/</a></p>
0
2010-03-02T09:03:40Z
[ "python", "xcode" ]
how to read an excel file on google app engine
2,360,010
<p>Generally I work with CSV files but for this project I need to support XLS too. Does anyone have experience reading XLS files on GAE with Python?</p> <p>2 possible alternatives I am considering:</p> <ul> <li><a href="http://pypi.python.org/pypi/xlrd" rel="nofollow">xlrd</a></li> <li><a href="http://code.google.com...
1
2010-03-01T23:53:07Z
2,360,242
<p><a href="http://pypi.python.org/pypi/xlrd" rel="nofollow">xlrd</a> saves you the network round-trip implied by the use of Google Docs; if you don't need to keep the document stored (which would be a substantial plus for Google Docs), this might incline you towards xlrd. I believe they're both high-quality.</p> <p>...
3
2010-03-02T00:58:26Z
[ "python", "excel", "google-app-engine", "csv" ]
Python directory list returned to Django template
2,360,205
<p>Total Python newb here. I have a images directory and I need to return the names and urls of those files to a django template that I can loop through for links. I know it will be the server path, but I can modify it via JS. I've tried os.walk, but I keep getting empty results. </p>
0
2010-03-02T00:50:50Z
2,360,257
<p>If it's a single directory, <code>os.listdir('thedirectory')</code> will give you a list of filename strings that seem to be suitable for your purposes (though it won't make "the urls" -- not sure how you want to make them?). If you need a whole <em>tree</em> of directories (recursively including subdirectories) th...
1
2010-03-02T01:04:41Z
[ "python", "list", "directory-structure" ]
Python directory list returned to Django template
2,360,205
<p>Total Python newb here. I have a images directory and I need to return the names and urls of those files to a django template that I can loop through for links. I know it will be the server path, but I can modify it via JS. I've tried os.walk, but I keep getting empty results. </p>
0
2010-03-02T00:50:50Z
2,360,344
<p>If your images are in one directory</p> <pre><code>import os root="/my" Path=os.path.join(root,"path","images") os.chdir(Path) for files in os.listdir("."): if files[-3:].lower() in ["gif","png","jpg","bmp"] : print "image file: ",files </code></pre>
2
2010-03-02T01:34:09Z
[ "python", "list", "directory-structure" ]
Concurrent downloads - Python
2,360,291
<p>the plan is this:</p> <p>I download a webpage, collect a list of images parsed in the DOM and then download these. After this I would iterate through the images in order to evaluate which image is best suited to represent the webpage.</p> <p>Problem is that images are downloaded 1 by 1 and this can take quite some...
9
2010-03-02T01:14:57Z
2,360,388
<p><a href="http://www.ibm.com/developerworks/aix/library/au-threadingpython/">Here</a> is an article on threading which uses url fetching as an example.</p>
4
2010-03-02T01:46:40Z
[ "python", "html", "concurrency", "web-crawler" ]
Concurrent downloads - Python
2,360,291
<p>the plan is this:</p> <p>I download a webpage, collect a list of images parsed in the DOM and then download these. After this I would iterate through the images in order to evaluate which image is best suited to represent the webpage.</p> <p>Problem is that images are downloaded 1 by 1 and this can take quite some...
9
2010-03-02T01:14:57Z
2,360,431
<p>While threading is certainly a possibility, I would instead suggest <a href="http://docs.python.org/library/asyncore.html?highlight=asyncore#module-asyncore" rel="nofollow"><code>asyncore</code></a> -- there's an excellent example <a href="http://broadcast.oreilly.com/2009/03/pymotw-asyncore.html" rel="nofollow">her...
6
2010-03-02T01:58:18Z
[ "python", "html", "concurrency", "web-crawler" ]
Concurrent downloads - Python
2,360,291
<p>the plan is this:</p> <p>I download a webpage, collect a list of images parsed in the DOM and then download these. After this I would iterate through the images in order to evaluate which image is best suited to represent the webpage.</p> <p>Problem is that images are downloaded 1 by 1 and this can take quite some...
9
2010-03-02T01:14:57Z
2,361,129
<p>Speeding up crawling is basically <a href="http://eventlet.net/">Eventlet</a>'s main use case. It's deeply fast -- we have an application that has to hit 2,000,000 urls in a few minutes. It makes use of the fastest event interface on your system (epoll, generally), and uses greenthreads (which are built on top of ...
12
2010-03-02T05:41:45Z
[ "python", "html", "concurrency", "web-crawler" ]
Concurrent downloads - Python
2,360,291
<p>the plan is this:</p> <p>I download a webpage, collect a list of images parsed in the DOM and then download these. After this I would iterate through the images in order to evaluate which image is best suited to represent the webpage.</p> <p>Problem is that images are downloaded 1 by 1 and this can take quite some...
9
2010-03-02T01:14:57Z
9,017,007
<p>Nowadays there are excellent Python libs you might want to use - <a href="http://urllib3.readthedocs.org/" rel="nofollow">urllib3</a> and <a href="http://docs.python-requests.org/" rel="nofollow">requests</a></p>
0
2012-01-26T10:48:37Z
[ "python", "html", "concurrency", "web-crawler" ]
Python: Misunderstanding about how imports work
2,360,399
<p>Here is my loader class, <strong>ItemLoader.py</strong>:</p> <pre><code>from google.appengine.ext import db from google.appengine.tools import bulkloader import models class ItemLoader(bulkloader.Loader): def __init__(self): bulkloader.Loader.__init__(self, 'Item', [('CSIN', int), # not too DRY... ...
2
2010-03-02T01:49:25Z
2,360,505
<p>You must add models directory to the PYTHONPATH. From docs:</p> <pre><code>(which is in your PYTHONPATH, such as the directory where you'll run the tool) </code></pre> <p>If you don't do that, python can't find your module.</p>
1
2010-03-02T02:16:43Z
[ "python", "google-app-engine", "import" ]
Python and Memory Consumption
2,360,483
<p>I am searching for a way to be able to handle overloading the RAM and CPU using a high memory program... I would like to process a LARGE amount of data contained in files. I then read the files and process the data therein. The problem is there are many nested for loops and a root XML file is being created from all ...
0
2010-03-02T02:11:40Z
2,360,509
<p>Do you really need to keep the whole data from the XML file on memory at once?</p> <p>Most (all?) XML libraries out there allow you to <a href="http://www.ibm.com/developerworks/xml/library/x-hiperfparse/" rel="nofollow">do iterative parsing</a>, meaning that you <a href="http://lethain.com/entry/2009/jan/22/handli...
3
2010-03-02T02:17:44Z
[ "python", "memory-management" ]
Google App Engine: Give arguments to a script from URL handler?
2,360,638
<p>Here is a portion of my <code>app.yaml</code> file:</p> <pre><code>handlers: - url: /remote_api script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py login: admin - url: /detail/(\d)+ script: Detail.py - url: /.* script: Index.py </code></pre> <p>I want that capture group (the one signified by <co...
2
2010-03-02T03:00:08Z
2,360,718
<p>I see two questions, how to pass elements of the url path as variables in the handler, and how to get the catch-all to render properly.</p> <p>Both of these have more to do with the main() method in the handler than the app.yaml</p> <p>1) to pass the id in the <code>/detail/(\d)</code> url, you want something like...
11
2010-03-02T03:28:30Z
[ "python", "google-app-engine" ]
Supporting PubSubHubbub with PyRSS2Gen?
2,360,641
<p>I'm using PyRSS2Gen to generate a RSS feed and I'm trying to support PubSubHubbub, but I need to add link elements that break RSS. Here's what should work without requiring a rewrite as Atom:</p> <pre><code>&lt;atom:link rel="hub" href="http://example.hub.com" xmlns:atom="http://www.w3.org/2005/Atom"&gt; &lt;atom:...
2
2010-03-02T03:00:41Z
5,463,590
<p>I looked at the PyRSS2Gen source code, and it looks like all you have to do is override the RSS class' <code>publish_extensions()</code> method. Something like this perhaps:</p> <pre><code>import PyRSS2Gen class MyRSS2(PyRSS2Gen.RSS2): def publish_extensions(self, handler): PyRSS2Gen._element(handler, ...
0
2011-03-28T18:46:15Z
[ "python", "rss", "pubsubhubbub" ]
datetime rendering in the admin forms
2,360,699
<p>I have the following Model and ModelAdmin classes. However when I view the posts in the admin list page, the <code>created</code> fields are rendered as <code>2010-03-01 22:15:18.494594</code>. I've tried setting the <code>DATETIME_FORMAT</code> variable in settings.py, but that didn't help. Any ideas how to cont...
0
2010-03-02T03:21:25Z
2,360,750
<p>I am not aware of a way to simply specify a date format for use in the admin interface. You do have other options though. Take a look <a href="http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display" rel="nofollow">here</a>. According to the documentation the list of c...
0
2010-03-02T03:39:49Z
[ "python", "django" ]
datetime rendering in the admin forms
2,360,699
<p>I have the following Model and ModelAdmin classes. However when I view the posts in the admin list page, the <code>created</code> fields are rendered as <code>2010-03-01 22:15:18.494594</code>. I've tried setting the <code>DATETIME_FORMAT</code> variable in settings.py, but that didn't help. Any ideas how to cont...
0
2010-03-02T03:21:25Z
2,361,274
<p>Odd, on my admin lists the dates are displayed like this by default:</p> <blockquote> <p>Feb. 28, 2010, 12:25 p.m.</p> </blockquote> <p>Have you set your locale information in settings.py?</p> <pre><code>TIME_ZONE = 'America/Los_Angeles' LANGUAGE_CODE = 'en-us' USE_I18N = True </code></pre>
0
2010-03-02T06:25:17Z
[ "python", "django" ]
What exactly does "import *" import?
2,360,724
<p>In Python, what exactly does <code>import *</code> import? Does it import <code>__init__.py</code> found in the containing folder?</p> <p>For example, is it necessary to declare <code>from project.model import __init__</code>, or is <code>from project.model import *</code> sufficient?</p>
15
2010-03-02T03:31:45Z
2,360,736
<p>Yes, it does. It imports <em>everything</em> (that is not a private variable, i.e.: variables whose names start with <code>_</code> or <code>__</code>), and you should try not to use it according to "<a href="http://stackoverflow.com/questions/896112/properly-importing-modules-in-python">Properly importing modules i...
3
2010-03-02T03:35:32Z
[ "python", "namespaces", "python-import" ]
What exactly does "import *" import?
2,360,724
<p>In Python, what exactly does <code>import *</code> import? Does it import <code>__init__.py</code> found in the containing folder?</p> <p>For example, is it necessary to declare <code>from project.model import __init__</code>, or is <code>from project.model import *</code> sufficient?</p>
15
2010-03-02T03:31:45Z
2,360,749
<p>If <code>project.model</code> is a package, the module referred to by <code>import project.model</code> is from <code>.../project/model/__init__.py</code>. <code>from project.model import *</code> dumps everything from <code>__init__.py</code>'s namespace into yours. It does not automatically do anything with the ot...
2
2010-03-02T03:39:43Z
[ "python", "namespaces", "python-import" ]
What exactly does "import *" import?
2,360,724
<p>In Python, what exactly does <code>import *</code> import? Does it import <code>__init__.py</code> found in the containing folder?</p> <p>For example, is it necessary to declare <code>from project.model import __init__</code>, or is <code>from project.model import *</code> sufficient?</p>
15
2010-03-02T03:31:45Z
2,360,769
<p>If the module in question (<code>project.model</code> in your case) has defined a list of stings named <code>__all__</code>, then every named variable in that list is imported. If there is no such variable, it imports everything.</p>
1
2010-03-02T03:43:20Z
[ "python", "namespaces", "python-import" ]
What exactly does "import *" import?
2,360,724
<p>In Python, what exactly does <code>import *</code> import? Does it import <code>__init__.py</code> found in the containing folder?</p> <p>For example, is it necessary to declare <code>from project.model import __init__</code>, or is <code>from project.model import *</code> sufficient?</p>
15
2010-03-02T03:31:45Z
2,360,782
<p>It import (into the current namespace) whatever names the module (or package) lists in its <code>__all__</code> attribute -- missing such an attribute, all names that don't start with <code>_</code>.</p> <p>It's mostly intended as a handy shortcut for use only in interactive interpreter sessions: as other answers s...
8
2010-03-02T03:47:36Z
[ "python", "namespaces", "python-import" ]
What exactly does "import *" import?
2,360,724
<p>In Python, what exactly does <code>import *</code> import? Does it import <code>__init__.py</code> found in the containing folder?</p> <p>For example, is it necessary to declare <code>from project.model import __init__</code>, or is <code>from project.model import *</code> sufficient?</p>
15
2010-03-02T03:31:45Z
2,360,808
<p>The "advantage" of <code>from xyz import *</code> as opposed to other forms of import is that it imports <em>everything</em> (well, almost... [see (a) below] everything) from the designated module under the current module. This allows using the various objects (variables, classes, methods...) from the imported modu...
23
2010-03-02T03:56:25Z
[ "python", "namespaces", "python-import" ]
Global function in __init__.py not accessible using Pylons + Python
2,360,846
<p>I'm having trouble creating a global function accessible from within all classes. I receive an error from within user.py that says:</p> <pre><code>NameError: global name 'connectCentral' is not defined </code></pre> <p>Here is my current code.</p> <p>project/model/__ init __.py:</p> <pre><code> """The applic...
0
2010-03-02T04:09:31Z
2,360,858
<p>You need to qualify the name with the module (or package) it's in, so:</p> <pre><code> try: project.model.connectCentral() </code></pre> <p>etc.</p>
2
2010-03-02T04:12:10Z
[ "python", "pylons" ]
How do I correctly install dulwich to get hg-git working on Windows?
2,360,944
<p>I'm trying to use the hg-git Mercurial extension on Windows (Windows 7 64-bit, to be specific). I have Mercurial and Git installed. I have Python 2.5 (32-bit) installed.</p> <p>I followed the instructions on <a href="http://hg-git.github.com/">http://hg-git.github.com/</a> to install the extension. The initial easy...
47
2010-03-02T04:40:47Z
2,432,436
<p>Until you get <code>import dulwich</code> to work, <code>hggit</code> won't work. Check that the <code>dulwich</code> egg file is in your <code>easy-install.pth</code> file under <code>site-packages</code>. </p> <p>For further debugging you can try ask <code>pkg_resources</code> about it:</p> <pre><code>import pkg...
0
2010-03-12T11:48:40Z
[ "python", "windows", "mercurial", "hg-git", "dulwich" ]
How do I correctly install dulwich to get hg-git working on Windows?
2,360,944
<p>I'm trying to use the hg-git Mercurial extension on Windows (Windows 7 64-bit, to be specific). I have Mercurial and Git installed. I have Python 2.5 (32-bit) installed.</p> <p>I followed the instructions on <a href="http://hg-git.github.com/">http://hg-git.github.com/</a> to install the extension. The initial easy...
47
2010-03-02T04:40:47Z
2,504,117
<p>Try following configuration (change to your path), which works for me:</p> <pre><code>[extensions] ; hg-git extention hgext.bookmarks = hggit = C:\Python26\Lib\site-packages\hg_git-0.2.1-py2.6.egg\hggit </code></pre> <p>In my case when I have empty value for <code>hggit =</code>, I get the same error as you do in ...
4
2010-03-23T22:37:50Z
[ "python", "windows", "mercurial", "hg-git", "dulwich" ]
How do I correctly install dulwich to get hg-git working on Windows?
2,360,944
<p>I'm trying to use the hg-git Mercurial extension on Windows (Windows 7 64-bit, to be specific). I have Mercurial and Git installed. I have Python 2.5 (32-bit) installed.</p> <p>I followed the instructions on <a href="http://hg-git.github.com/">http://hg-git.github.com/</a> to install the extension. The initial easy...
47
2010-03-02T04:40:47Z
2,564,931
<p>If you can install TortoiseHg, it includes dulwich and other requirements.</p>
8
2010-04-02T03:57:15Z
[ "python", "windows", "mercurial", "hg-git", "dulwich" ]
How do I correctly install dulwich to get hg-git working on Windows?
2,360,944
<p>I'm trying to use the hg-git Mercurial extension on Windows (Windows 7 64-bit, to be specific). I have Mercurial and Git installed. I have Python 2.5 (32-bit) installed.</p> <p>I followed the instructions on <a href="http://hg-git.github.com/">http://hg-git.github.com/</a> to install the extension. The initial easy...
47
2010-03-02T04:40:47Z
2,733,516
<blockquote> <p>That makes me think dulwich is not installed correctly, or not in the path.</p> </blockquote> <p>You're absolutely right. Mercurial binary distributions for Windows are 'frozen' - they use the Python code and interpreter bundled with them and therefore independent of packages installed in system ...
16
2010-04-28T22:25:07Z
[ "python", "windows", "mercurial", "hg-git", "dulwich" ]
How do I correctly install dulwich to get hg-git working on Windows?
2,360,944
<p>I'm trying to use the hg-git Mercurial extension on Windows (Windows 7 64-bit, to be specific). I have Mercurial and Git installed. I have Python 2.5 (32-bit) installed.</p> <p>I followed the instructions on <a href="http://hg-git.github.com/">http://hg-git.github.com/</a> to install the extension. The initial easy...
47
2010-03-02T04:40:47Z
4,242,477
<p>I ran into this problem too with dulwich.errors. Instead of installing everything from scratch. I just copied dulwich from my default site-packages to the mercurial site-packages. worked with no problems.</p>
0
2010-11-22T05:12:16Z
[ "python", "windows", "mercurial", "hg-git", "dulwich" ]
How do I correctly install dulwich to get hg-git working on Windows?
2,360,944
<p>I'm trying to use the hg-git Mercurial extension on Windows (Windows 7 64-bit, to be specific). I have Mercurial and Git installed. I have Python 2.5 (32-bit) installed.</p> <p>I followed the instructions on <a href="http://hg-git.github.com/">http://hg-git.github.com/</a> to install the extension. The initial easy...
47
2010-03-02T04:40:47Z
6,998,710
<p>I found a simpler solution at <a href="http://candidcode.com/2010/01/12/a-guide-to-converting-from-mercurial-hg-to-git-on-a-windows-client/">http://candidcode.com/2010/01/12/a-guide-to-converting-from-mercurial-hg-to-git-on-a-windows-client/</a></p> <p>And then I found a yet simpler solution myself:</p> <p>To use ...
10
2011-08-09T15:28:17Z
[ "python", "windows", "mercurial", "hg-git", "dulwich" ]
How do I correctly install dulwich to get hg-git working on Windows?
2,360,944
<p>I'm trying to use the hg-git Mercurial extension on Windows (Windows 7 64-bit, to be specific). I have Mercurial and Git installed. I have Python 2.5 (32-bit) installed.</p> <p>I followed the instructions on <a href="http://hg-git.github.com/">http://hg-git.github.com/</a> to install the extension. The initial easy...
47
2010-03-02T04:40:47Z
18,240,195
<blockquote> <p>sudo apt-get install python-dev # Dam you dependency!</p> <p>sudo easy_install dulwich </p> </blockquote> <p>Success!</p>
-2
2013-08-14T19:06:34Z
[ "python", "windows", "mercurial", "hg-git", "dulwich" ]
How do I correctly install dulwich to get hg-git working on Windows?
2,360,944
<p>I'm trying to use the hg-git Mercurial extension on Windows (Windows 7 64-bit, to be specific). I have Mercurial and Git installed. I have Python 2.5 (32-bit) installed.</p> <p>I followed the instructions on <a href="http://hg-git.github.com/">http://hg-git.github.com/</a> to install the extension. The initial easy...
47
2010-03-02T04:40:47Z
21,272,625
<p>Based on techtonik's <a href="http://stackoverflow.com/a/2733516/1236781">explanation</a> of the reason for the failing import of <code>dulwich.errors</code>, I found a solution which appears simpler to me than the already proposed ones:</p> <p>On the <a href="http://mercurial.selenic.com/downloads/" rel="nofollow"...
0
2014-01-22T01:43:24Z
[ "python", "windows", "mercurial", "hg-git", "dulwich" ]
How do I correctly install dulwich to get hg-git working on Windows?
2,360,944
<p>I'm trying to use the hg-git Mercurial extension on Windows (Windows 7 64-bit, to be specific). I have Mercurial and Git installed. I have Python 2.5 (32-bit) installed.</p> <p>I followed the instructions on <a href="http://hg-git.github.com/">http://hg-git.github.com/</a> to install the extension. The initial easy...
47
2010-03-02T04:40:47Z
35,139,578
<p>I got this error as well even after downloading the latest Tortoisehg and making sure the hggit plugin was installed as well as my .ini &amp; hgrc files had the right entry to enable hggit.</p> <p>Turns out my problem was that I had both mercurial and tortoisehg in my path. So when I ran any hg commands, it was usi...
0
2016-02-01T20:21:20Z
[ "python", "windows", "mercurial", "hg-git", "dulwich" ]
Delete() views and template code
2,361,074
<p>Template:</p> <pre><code>&lt;form method="POST" action="/customer/delete/"&gt; &lt;div style="float: right; margin: 0px; padding: 05px; "&gt; Name:&lt;select name="customer"&gt; {% for customer in customer %} &lt;option value="{{ customer.name|escape }}" &gt;&lt;/option&gt;&lt;br /&gt; {% endfor %} &...
1
2010-03-02T05:21:17Z
2,361,373
<pre><code>Customer.objects.get(name = request.POST['name']).delete() </code></pre> <p>By the way, are you sure that the <code>action</code> variable in the template is indeed <code>'delete'</code>? If it isn't, the url called (and hence the method) will be different.</p> <pre><code>&lt;form method="POST" action="/cu...
0
2010-03-02T06:53:15Z
[ "python", "django" ]
Delete() views and template code
2,361,074
<p>Template:</p> <pre><code>&lt;form method="POST" action="/customer/delete/"&gt; &lt;div style="float: right; margin: 0px; padding: 05px; "&gt; Name:&lt;select name="customer"&gt; {% for customer in customer %} &lt;option value="{{ customer.name|escape }}" &gt;&lt;/option&gt;&lt;br /&gt; {% endfor %} &...
1
2010-03-02T05:21:17Z
2,363,027
<p>Your URLConf isn't catching any data to pass on to the variable <code>name</code>. You need to either catch it as a part of the URL, or leave it to catch in a POSTed argument.</p> <p>As part of the URL:</p> <pre><code>(r'^customer/(?P&lt;name&gt;[a-z]*)/delete/', 'quote.excel.views.delete') def delete(request, n...
1
2010-03-02T12:26:40Z
[ "python", "django" ]
using __init__.py
2,361,124
<p>I am having difficulty understanding the usage scenarios or design goals of python's <code>__init__.py</code> files in my projects.</p> <p>Assume that I have 'model' directory (refers as a package) which contains the following files</p> <ol> <li><code>__init__.py</code></li> <li><code>meta.py</code></li> <li><code...
59
2010-03-02T05:36:24Z
2,361,131
<p>The contents of <code>__init__.py</code> are imported when you import a module within the package.</p> <p>You're overlooking a third scenario, which is to put the common parts in a separate module and then have the other modules import that, leaving <code>__init__.py</code> for things that will be used outside the ...
22
2010-03-02T05:42:02Z
[ "python", "module", "initialization", "packages" ]
using __init__.py
2,361,124
<p>I am having difficulty understanding the usage scenarios or design goals of python's <code>__init__.py</code> files in my projects.</p> <p>Assume that I have 'model' directory (refers as a package) which contains the following files</p> <ol> <li><code>__init__.py</code></li> <li><code>meta.py</code></li> <li><code...
59
2010-03-02T05:36:24Z
2,361,278
<p>The vast majority of the <code>__init__.py</code> files I write are empty, because many packages don't have anything to initialize.</p> <p>One example in which I may want initialization is when at package-load time I want to read in a bunch of data once and for all (from files, a DB, or the web, say) -- in which ca...
46
2010-03-02T06:26:05Z
[ "python", "module", "initialization", "packages" ]
Pickled Object Versioning
2,361,140
<p>I am working on a project where we have a large number of objects being serialized and stored to disk using <code>pickle</code>/<code>cPickle</code>.</p> <p>As the life of the project progresses (after release to customers in the field) it is likely that future features/fixes will require us to change the signature...
1
2010-03-02T05:45:33Z
2,361,252
<p>The <code>pickle</code> format has no such proviso. Why don't you just make the "serial version number" part of the object's attributes, to be pickled right along with the rest? Then the "notification" can be trivially had by comparing actual and desired version -- don't see why it should be a PITA.</p>
2
2010-03-02T06:20:23Z
[ "python", "serialization", "pickle", "serialversionuid" ]
Solving Sparse Linear Problem With Some Known Boundary Values
2,361,176
<p>I'm trying to solve a Poisson equation on a rectangular domain which ends up being a linear problem like Ax=b but since I know the boundary conditions, there are nodes where I have the solution values. I guess my question is... How can I solve the sparse system Ax=b if I know what some of the coordinates of x ...
1
2010-03-02T05:57:35Z
2,361,204
<p>If I understand correctly, some elements of x are known, and some are not, and you want to solve Ax = b for the unknown values of x, correct?</p> <p>Let Ax = [A1 A2][x1; x2] = b, where the vector x = [x1; x2], the vector x1 has the unknown values of x, and vector x2 have the known values of x. Then, A1x1 = b - A2x2...
1
2010-03-02T06:07:05Z
[ "python", "numpy", "linear", "sparse-matrix", "poisson" ]
What is the best way to get the first item from an iterable matching a condition?
2,361,426
<p>In Python, I would like to get the first item from a list matching a condition. For example, the following function is adequate:</p> <pre><code>def first(the_iterable, condition = lambda x: True): for i in the_iterable: if condition(i): return i </code></pre> <p>This function could be used ...
95
2010-03-02T07:11:29Z
2,361,448
<p>The <a href="http://docs.python.org/library/itertools.html"><code>itertools</code></a> module contains a filter function for iterators. The first element of the filtered iterator can be obtained by calling <code>next()</code> on it:</p> <pre><code>from itertools import ifilter print ifilter((lambda i: i &gt; 3), r...
5
2010-03-02T07:16:46Z
[ "python", "coding-style", "iterator" ]
What is the best way to get the first item from an iterable matching a condition?
2,361,426
<p>In Python, I would like to get the first item from a list matching a condition. For example, the following function is adequate:</p> <pre><code>def first(the_iterable, condition = lambda x: True): for i in the_iterable: if condition(i): return i </code></pre> <p>This function could be used ...
95
2010-03-02T07:11:29Z
2,361,495
<p>Similar to using <code>ifilter</code>, you could use a generator expression:</p> <pre><code>&gt;&gt;&gt; (x for x in xrange(10) if x &gt; 5).next() 6 </code></pre> <p>In either case, you probably want to catch <code>StopIteration</code> though, in case no elements satisfy your condition.</p> <p>Technically speaki...
9
2010-03-02T07:27:51Z
[ "python", "coding-style", "iterator" ]
What is the best way to get the first item from an iterable matching a condition?
2,361,426
<p>In Python, I would like to get the first item from a list matching a condition. For example, the following function is adequate:</p> <pre><code>def first(the_iterable, condition = lambda x: True): for i in the_iterable: if condition(i): return i </code></pre> <p>This function could be used ...
95
2010-03-02T07:11:29Z
2,361,694
<p>I would write this </p> <pre><code>next(x for x in xrange(10) if x &gt; 3) </code></pre>
3
2010-03-02T08:22:08Z
[ "python", "coding-style", "iterator" ]
What is the best way to get the first item from an iterable matching a condition?
2,361,426
<p>In Python, I would like to get the first item from a list matching a condition. For example, the following function is adequate:</p> <pre><code>def first(the_iterable, condition = lambda x: True): for i in the_iterable: if condition(i): return i </code></pre> <p>This function could be used ...
95
2010-03-02T07:11:29Z
2,361,739
<p>Oneliner:</p> <pre><code>thefirst = [i for i in range(10) if i &gt; 3][0] </code></pre> <p>If youre not sure that any element will be valid according to the criteria, you should enclose this with <code>try/except</code> since that <code>[0]</code> can raise an <code>IndexError</code>.</p>
-1
2010-03-02T08:34:17Z
[ "python", "coding-style", "iterator" ]
What is the best way to get the first item from an iterable matching a condition?
2,361,426
<p>In Python, I would like to get the first item from a list matching a condition. For example, the following function is adequate:</p> <pre><code>def first(the_iterable, condition = lambda x: True): for i in the_iterable: if condition(i): return i </code></pre> <p>This function could be used ...
95
2010-03-02T07:11:29Z
2,361,899
<p>For older versions of Python where the next built-in doesn't exist:</p> <pre><code>(x for x in range(10) if x &gt; 3).next() </code></pre>
6
2010-03-02T09:02:13Z
[ "python", "coding-style", "iterator" ]
What is the best way to get the first item from an iterable matching a condition?
2,361,426
<p>In Python, I would like to get the first item from a list matching a condition. For example, the following function is adequate:</p> <pre><code>def first(the_iterable, condition = lambda x: True): for i in the_iterable: if condition(i): return i </code></pre> <p>This function could be used ...
95
2010-03-02T07:11:29Z
2,364,277
<p>In Python 2.6 or better:</p> <ul> <li><p><code>next(x for x in the_iterable if x &gt; 3)</code></p> <p>if you want <code>StopIteration</code> to be raised if no matching element is found,</p></li> <li><p><code>next( (x for x in the_iterable if x&gt;3), default_value)</code></p> <p>if you want <code>default_value<...
149
2010-03-02T15:29:26Z
[ "python", "coding-style", "iterator" ]
What is the best way to get the first item from an iterable matching a condition?
2,361,426
<p>In Python, I would like to get the first item from a list matching a condition. For example, the following function is adequate:</p> <pre><code>def first(the_iterable, condition = lambda x: True): for i in the_iterable: if condition(i): return i </code></pre> <p>This function could be used ...
95
2010-03-02T07:11:29Z
10,240,381
<p>Since you've requested a built-in one-liner, this will avoid the issue of a <code>StopIteration</code> exception, though it requires that your iterable is small so you can cast it to a list, since that is the only construct I know of which will swallow a StopIteration and let you peek at the values:</p> <pre><code>...
1
2012-04-20T04:43:10Z
[ "python", "coding-style", "iterator" ]
What is the best way to get the first item from an iterable matching a condition?
2,361,426
<p>In Python, I would like to get the first item from a list matching a condition. For example, the following function is adequate:</p> <pre><code>def first(the_iterable, condition = lambda x: True): for i in the_iterable: if condition(i): return i </code></pre> <p>This function could be used ...
95
2010-03-02T07:11:29Z
34,894,322
<h1>Damn Exceptions!</h1> <p>I love <a href="http://stackoverflow.com/a/2364277/3191896">this answer</a>. However, since <code>next()</code> raise a <code>StopIteration</code> exception when there are no items, i would use the following snippet to avoid an exception:</p> <pre><code>a = [] item = next(x for x in a) if...
1
2016-01-20T07:49:18Z
[ "python", "coding-style", "iterator" ]
What is the best way to get the first item from an iterable matching a condition?
2,361,426
<p>In Python, I would like to get the first item from a list matching a condition. For example, the following function is adequate:</p> <pre><code>def first(the_iterable, condition = lambda x: True): for i in the_iterable: if condition(i): return i </code></pre> <p>This function could be used ...
95
2010-03-02T07:11:29Z
35,513,376
<h3>As a reusable, documented and tested function</h3> <pre><code>def first(iterable, condition = lambda x: True): """ Returns the first item in the `iterable` that satisfies the `condition`. If the condition is not given, returns the first item of the iterable. Raises `StopIteration` if no i...
2
2016-02-19T19:25:41Z
[ "python", "coding-style", "iterator" ]
What is the best way to get the first item from an iterable matching a condition?
2,361,426
<p>In Python, I would like to get the first item from a list matching a condition. For example, the following function is adequate:</p> <pre><code>def first(the_iterable, condition = lambda x: True): for i in the_iterable: if condition(i): return i </code></pre> <p>This function could be used ...
95
2010-03-02T07:11:29Z
36,941,923
<p>In Python 3:</p> <pre><code>a = (None, False, 0, 1) assert next(filter(None, a)) == 1 </code></pre> <p>In Python 2.6:</p> <pre><code>a = (None, False, 0, 1) assert next(iter(filter(None, a))) == 1 </code></pre>
0
2016-04-29T15:14:08Z
[ "python", "coding-style", "iterator" ]
django error :1146, "Table 'basic_project.topics_topic' doesn't exist"
2,361,451
<p>TemplateSyntaxError at /tribes/</p> <p>Caught an exception while rendering: (1146, "Table 'basic_project.topics_topic' doesn't exist")</p> <p><img src="http://omploader.org/vM3BrZA" alt="alt text"></p> <p>why ??</p> <p>thanks</p>
1
2010-03-02T07:17:12Z
2,361,471
<p><a href="http://docs.djangoproject.com/en/dev/ref/django-admin/#syncdb" rel="nofollow">Because.</a></p> <p>You have to run <code>syncdb</code> everytime you add a new app or model.</p>
2
2010-03-02T07:21:48Z
[ "python", "django", "pinax" ]
Python: Access Posix' locale database without setlocale()
2,361,764
<p>The setup is a Django based website on an Ubuntu server system with lots of useful information in <code>/usr/share/i18n/locales</code>.</p> <p>The question: Can I access this pool of wisdom <em>without</em> using Python's <code>locale.setlocale()</code> afore?</p> <p>The reason: <a href="http://docs.python.org/lib...
2
2010-03-02T08:37:34Z
2,362,682
<p>The magic library to achieve this is called <a href="http://babel.edgewall.org/" rel="nofollow">Babel</a>. Does what I want:</p> <h3>Before</h3> <pre><code>import locale setlocale(LC_ALL, 'de') x = locale.format('%.2f', 123) setlocale(LC_ALL, '') </code></pre> <h3>After</h3> <pre><code>from babel.numbers import ...
2
2010-03-02T11:18:02Z
[ "python", "django", "posix", "internationalization", "locale" ]
How to switch axes in matplotlib?
2,361,872
<p>I like to switch x axis with y axis after plotting a graph with matplotlib? Any easy way for it? Thanks in advance.</p>
5
2010-03-02T08:58:45Z
2,364,605
<p>You can simply switch x and y parameters in the plot function:</p> <pre><code>I[3]: x = np.linspace(0,2*np.pi, 100) I[4]: y = np.sin(x) I[5]: plt.plot(x,y) I[6]: plt.figure(); plt.plot(y,x) </code></pre>
-3
2010-03-02T16:09:40Z
[ "python", "matplotlib" ]
Detecting consecutive integers in a list
2,361,945
<p>I have a list containing data as such:</p> <pre><code>[1, 2, 3, 4, 7, 8, 10, 11, 12, 13, 14] </code></pre> <p>I'd like to print out the ranges of consecutive integers:</p> <pre><code>1-4, 7-8, 10-14 </code></pre> <p>Is there a built-in/fast/efficient way of doing this?</p>
25
2010-03-02T09:10:14Z
2,361,991
<p>From <a href="https://docs.python.org/2.6/library/itertools.html#examples" rel="nofollow">the docs</a>:</p> <pre><code>&gt;&gt;&gt; from itertools import groupby &gt;&gt;&gt; from operator import itemgetter &gt;&gt;&gt; data = [ 1, 4,5,6, 10, 15,16,17,18, 22, 25,26,27,28] &gt;&gt;&gt; for k, g in groupby(enumerate(...
48
2010-03-02T09:17:00Z
[ "python", "algorithm", "list" ]
Detecting consecutive integers in a list
2,361,945
<p>I have a list containing data as such:</p> <pre><code>[1, 2, 3, 4, 7, 8, 10, 11, 12, 13, 14] </code></pre> <p>I'd like to print out the ranges of consecutive integers:</p> <pre><code>1-4, 7-8, 10-14 </code></pre> <p>Is there a built-in/fast/efficient way of doing this?</p>
25
2010-03-02T09:10:14Z
2,361,998
<p>Built-In: No, as far as I'm aware.</p> <p>You have to run through the array. Start off with putting the first value in a variable and print it, then as long as you keep hitting the next number do nothing but remember the last number in another variable. If the next number is not in line, check the last number remem...
4
2010-03-02T09:17:57Z
[ "python", "algorithm", "list" ]
Detecting consecutive integers in a list
2,361,945
<p>I have a list containing data as such:</p> <pre><code>[1, 2, 3, 4, 7, 8, 10, 11, 12, 13, 14] </code></pre> <p>I'd like to print out the ranges of consecutive integers:</p> <pre><code>1-4, 7-8, 10-14 </code></pre> <p>Is there a built-in/fast/efficient way of doing this?</p>
25
2010-03-02T09:10:14Z
20,725,061
<p>This will print exactly as you specified:</p> <pre><code>&gt;&gt;&gt; nums = [1, 2, 3, 4, 7, 8, 10, 11, 12, 13, 14] &gt;&gt;&gt; ranges = sum((list(t) for t in zip(nums, nums[1:]) if t[0]+1 != t[1]), []) &gt;&gt;&gt; iranges = iter(nums[0:1] + ranges + nums[-1:]) &gt;&gt;&gt; print ', '.join([str(n) + '-' + str(nex...
0
2013-12-22T00:47:28Z
[ "python", "algorithm", "list" ]
Detecting consecutive integers in a list
2,361,945
<p>I have a list containing data as such:</p> <pre><code>[1, 2, 3, 4, 7, 8, 10, 11, 12, 13, 14] </code></pre> <p>I'd like to print out the ranges of consecutive integers:</p> <pre><code>1-4, 7-8, 10-14 </code></pre> <p>Is there a built-in/fast/efficient way of doing this?</p>
25
2010-03-02T09:10:14Z
20,726,567
<p>Here is another basic solution without using any module, which is good for interview, generally in the interview they asked without using any modules:</p> <pre><code>#!/usr/bin/python def split_list(n): """will return the list index""" return [(x+1) for x,y in zip(n, n[1:]) if y-x != 1] def get_sub_list(m...
0
2013-12-22T05:32:12Z
[ "python", "algorithm", "list" ]
Detecting consecutive integers in a list
2,361,945
<p>I have a list containing data as such:</p> <pre><code>[1, 2, 3, 4, 7, 8, 10, 11, 12, 13, 14] </code></pre> <p>I'd like to print out the ranges of consecutive integers:</p> <pre><code>1-4, 7-8, 10-14 </code></pre> <p>Is there a built-in/fast/efficient way of doing this?</p>
25
2010-03-02T09:10:14Z
24,847,233
<p>I had a similar problem and am using the following for a sorted list. It outputs a dictionary with ranges of values listed in a dictionary. The keys separate each run of consecutive numbers and are also the running total of non-sequential items between numbers in sequence. </p> <p>Your list gives me an output of <c...
0
2014-07-20T04:01:23Z
[ "python", "algorithm", "list" ]
RSS screen scraper
2,362,066
<p>Can anyone point me towards a ready made RSS screen scraper, preferably in Python in order to get full text RSS feeds?</p>
3
2010-03-02T09:28:48Z
2,362,102
<p>There's a good list of them <a href="http://wiki.python.org/moin/RssLibraries" rel="nofollow">here</a>, which mentions <a href="http://diveintomark.org/projects/feed_parser/" rel="nofollow">Feed Parser</a>, which you use like this:</p> <pre><code>import feedparser python_wiki_rss_url = "http://www.python.org/cgi-b...
3
2010-03-02T09:34:43Z
[ "python", "rss" ]
RSS screen scraper
2,362,066
<p>Can anyone point me towards a ready made RSS screen scraper, preferably in Python in order to get full text RSS feeds?</p>
3
2010-03-02T09:28:48Z
2,362,112
<p><a href="http://feedparser.org" rel="nofollow">feedparser.org</a> is great</p>
1
2010-03-02T09:35:29Z
[ "python", "rss" ]
RSS screen scraper
2,362,066
<p>Can anyone point me towards a ready made RSS screen scraper, preferably in Python in order to get full text RSS feeds?</p>
3
2010-03-02T09:28:48Z
2,362,155
<p>Sorry but it doesn't exist in python, though they do in php. You are more then welcome to use and improve the one I made named scraped. Though it does not do all sites, it is a recipe based system that currently only handles the NYT, WSJ and the Economist. I am working on an all inclusive algorithm, but its a maj...
0
2010-03-02T09:43:45Z
[ "python", "rss" ]
Match start and end of file in python with regex
2,362,471
<p>I'm having a hard time finding the regex for the start and end of a file in python. How would I accomplish this ?</p>
4
2010-03-02T10:37:57Z
2,362,547
<p>Maybe you should pose your question more clearly, like what you trying to do. That said, you can slurp the file into one whole string, and match your pattern using re.</p> <pre><code>import re data=open("file").read() pat=re.compile("^.*pattern.*$",re.M|re.DOTALL) print pat.findall(data) </code></pre> <p>There are...
2
2010-03-02T10:51:38Z
[ "python", "regex" ]
Match start and end of file in python with regex
2,362,471
<p>I'm having a hard time finding the regex for the start and end of a file in python. How would I accomplish this ?</p>
4
2010-03-02T10:37:57Z
2,363,274
<p>regex <code>$</code> is <strong>NOT</strong> your friend; see <a href="http://stackoverflow.com/questions/2317134/regular-expression/2318190#2318190">this SO answer</a> </p>
0
2010-03-02T13:13:29Z
[ "python", "regex" ]
Match start and end of file in python with regex
2,362,471
<p>I'm having a hard time finding the regex for the start and end of a file in python. How would I accomplish this ?</p>
4
2010-03-02T10:37:57Z
2,363,282
<p>Read the whole file into a string, then \A matches only the beginning of a string, and \Z matches only the end of a string. With re.MULTILINE, '^' matches the beginning of the string <strong>and</strong> the just after a newline, and '$' matches the end of the string <strong>and</strong> just before a newline. Se...
7
2010-03-02T13:14:35Z
[ "python", "regex" ]
How can i capture the UDP packet and find the TTL Values from the packet using python
2,362,541
<p>HI </p> <p>I want to capture the UDP packets by joining to the Multicast group. after the receving the packet i want to check for the TTL value from that UDP packet. How can i achieve this by using python ?</p> <p>The Sammple code as mentioned below: here <strong>rec_port</strong> is any port which i had used to ...
3
2010-03-02T10:50:31Z
2,362,554
<p>You probably want to use <a href="http://pycap.sourceforge.net/" rel="nofollow">this</a> python wrapper. If it doesn't satisfy you can wrap <a href="http://www.tcpdump.org/" rel="nofollow">libpcap</a> yourself.</p> <p><strong>In response to unwind:</strong> You don't have to act "promiscious" with libpcap, you can ...
2
2010-03-02T10:53:07Z
[ "python" ]
How can i capture the UDP packet and find the TTL Values from the packet using python
2,362,541
<p>HI </p> <p>I want to capture the UDP packets by joining to the Multicast group. after the receving the packet i want to check for the TTL value from that UDP packet. How can i achieve this by using python ?</p> <p>The Sammple code as mentioned below: here <strong>rec_port</strong> is any port which i had used to ...
3
2010-03-02T10:50:31Z
2,362,836
<p>in a comment, you told us that you are able to join the multicast group.</p> <p>now you can use <code>getsockopt()</code>, specify <code>IPPROTO_IP</code> for the level parameter and <code>IP_MULTICAST_TTL</code> for the option, to get the TTL value which is written to outgoing packets.</p>
0
2010-03-02T11:48:38Z
[ "python" ]
print value of a column in django
2,362,729
<p>How to print the test field in the following query in django</p> <pre><code>res=Resources.objects.filter(test=request.profile) logging.debug(test) # won't work </code></pre> <p>I wanted to check what this value is compared with..</p>
0
2010-03-02T11:27:48Z
2,362,745
<p>You have to iterate through <code>res</code> and print each model's value of <code>test</code> in turn.</p>
1
2010-03-02T11:29:27Z
[ "python", "django" ]
print value of a column in django
2,362,729
<p>How to print the test field in the following query in django</p> <pre><code>res=Resources.objects.filter(test=request.profile) logging.debug(test) # won't work </code></pre> <p>I wanted to check what this value is compared with..</p>
0
2010-03-02T11:27:48Z
2,364,623
<p>You may also try the <code>values_list</code> method, eg:</p> <pre><code>Resource.objects.filter(test=request.profile).values_list("test") </code></pre> <p>It returns a list of tuples with the value of "test" for each matched record.</p>
0
2010-03-02T16:11:48Z
[ "python", "django" ]
Simple and effective web framework
2,362,840
<p>I'm looking for a suitable cross-platform web framework (if that's the proper term). I need something that doesn't rely on knowing the server's address or the absolute path to the files. Ideally it would come with a (development) server and be widely supported.</p> <p>I've already tried PHP, Django and web2py. Djan...
4
2010-03-02T11:49:08Z
2,362,857
<p>I'd say Ruby on Rails is what you're looking for. Works anywhere, and no configuration needed. You only have it installed, install the gems you need, and off you go.</p> <p>I also use ColdFusion, which is totally multi-platform, but relies on the Administrator settings for DSN configuration and stuff.</p>
0
2010-03-02T11:51:41Z
[ "python", "web-frameworks" ]
Simple and effective web framework
2,362,840
<p>I'm looking for a suitable cross-platform web framework (if that's the proper term). I need something that doesn't rely on knowing the server's address or the absolute path to the files. Ideally it would come with a (development) server and be widely supported.</p> <p>I've already tried PHP, Django and web2py. Djan...
4
2010-03-02T11:49:08Z
2,362,858
<p><a href="http://turbogears.org/" rel="nofollow">TurboGears</a>: Everything optional.</p>
0
2010-03-02T11:51:53Z
[ "python", "web-frameworks" ]
Simple and effective web framework
2,362,840
<p>I'm looking for a suitable cross-platform web framework (if that's the proper term). I need something that doesn't rely on knowing the server's address or the absolute path to the files. Ideally it would come with a (development) server and be widely supported.</p> <p>I've already tried PHP, Django and web2py. Djan...
4
2010-03-02T11:49:08Z
2,362,864
<p>I think you need to focus on Restful web applications. Zend is a PHP based MVC framework.</p>
-1
2010-03-02T11:53:24Z
[ "python", "web-frameworks" ]
Simple and effective web framework
2,362,840
<p>I'm looking for a suitable cross-platform web framework (if that's the proper term). I need something that doesn't rely on knowing the server's address or the absolute path to the files. Ideally it would come with a (development) server and be widely supported.</p> <p>I've already tried PHP, Django and web2py. Djan...
4
2010-03-02T11:49:08Z
2,362,869
<p>I think you need to be more specific about what you want to achieve, and what kind of product(s) you want to develop. A "no setup required" product may come with tons of auto-configuration bloat, while a framework requiring a small setup file could be set up in minutes, too, with much more simplicity in the long run...
2
2010-03-02T11:53:59Z
[ "python", "web-frameworks" ]
Simple and effective web framework
2,362,840
<p>I'm looking for a suitable cross-platform web framework (if that's the proper term). I need something that doesn't rely on knowing the server's address or the absolute path to the files. Ideally it would come with a (development) server and be widely supported.</p> <p>I've already tried PHP, Django and web2py. Djan...
4
2010-03-02T11:49:08Z
2,362,875
<p>Give <a href="http://bottle.paws.de/" rel="nofollow">bottle</a> a try. I use it for my simple no-frills webapps. It is very intuitive and easy to work with in my experience. </p> <p>Here is some sample code, and it requires just <code>bottle.py</code>, no other dependencies.</p> <pre><code>from bottle import route...
0
2010-03-02T11:55:25Z
[ "python", "web-frameworks" ]
Simple and effective web framework
2,362,840
<p>I'm looking for a suitable cross-platform web framework (if that's the proper term). I need something that doesn't rely on knowing the server's address or the absolute path to the files. Ideally it would come with a (development) server and be widely supported.</p> <p>I've already tried PHP, Django and web2py. Djan...
4
2010-03-02T11:49:08Z
2,362,878
<p><a href="http://werkzeug.pocoo.org/" rel="nofollow">Werkzeug</a>:</p> <pre><code>import werkzeug @werkzeug.Request.application def app(request): return werkzeug.Response("Hello, World!") werkzeug.run_simple("0.0.0.0", 4000, app) </code></pre> <p>You can optionally use werkzeug URL routing (or your own, or anyt...
1
2010-03-02T11:55:47Z
[ "python", "web-frameworks" ]
Simple and effective web framework
2,362,840
<p>I'm looking for a suitable cross-platform web framework (if that's the proper term). I need something that doesn't rely on knowing the server's address or the absolute path to the files. Ideally it would come with a (development) server and be widely supported.</p> <p>I've already tried PHP, Django and web2py. Djan...
4
2010-03-02T11:49:08Z
2,362,938
<p>This question is based on a complete failure to understand any of the tools you have apparently "investigated", or indeed web serving generally.</p> <p>Django has an admin panel? Well, don't use it if you don't want to. There's no configuration that needs to be done there, it's for managing your data if you want.</...
5
2010-03-02T12:08:03Z
[ "python", "web-frameworks" ]
Simple and effective web framework
2,362,840
<p>I'm looking for a suitable cross-platform web framework (if that's the proper term). I need something that doesn't rely on knowing the server's address or the absolute path to the files. Ideally it would come with a (development) server and be widely supported.</p> <p>I've already tried PHP, Django and web2py. Djan...
4
2010-03-02T11:49:08Z
2,363,110
<p>Just stumbled upon <a href="http://www.quixote.ca/" rel="nofollow">Quixote</a> recently. Never used it though.</p>
0
2010-03-02T12:42:10Z
[ "python", "web-frameworks" ]
Simple and effective web framework
2,362,840
<p>I'm looking for a suitable cross-platform web framework (if that's the proper term). I need something that doesn't rely on knowing the server's address or the absolute path to the files. Ideally it would come with a (development) server and be widely supported.</p> <p>I've already tried PHP, Django and web2py. Djan...
4
2010-03-02T11:49:08Z
2,363,285
<p>In web2py you do not need to use the admin interface. It is optional. Here is how you create a simple app from zero:</p> <pre><code> wget http://web2py.com/examples/static/web2py_src.zip unzip web2py_src.zip cd web2py/applications mkdir myapp cp -r ../welcome/* ./ </code></pre> <p>Optional Edit your app</p> <...
4
2010-03-02T13:14:54Z
[ "python", "web-frameworks" ]
Simple and effective web framework
2,362,840
<p>I'm looking for a suitable cross-platform web framework (if that's the proper term). I need something that doesn't rely on knowing the server's address or the absolute path to the files. Ideally it would come with a (development) server and be widely supported.</p> <p>I've already tried PHP, Django and web2py. Djan...
4
2010-03-02T11:49:08Z
2,363,373
<p>Use plain old ASP. IIS does not care where files are stored. All paths can be set relative from the virtual directory. That means you can include "/myproject/myfile.asp", whereas in PHP it's often done using relative paths. Global.asa then contains global configuration for the application. You hardly ever have to wo...
0
2010-03-02T13:30:26Z
[ "python", "web-frameworks" ]
Simple and effective web framework
2,362,840
<p>I'm looking for a suitable cross-platform web framework (if that's the proper term). I need something that doesn't rely on knowing the server's address or the absolute path to the files. Ideally it would come with a (development) server and be widely supported.</p> <p>I've already tried PHP, Django and web2py. Djan...
4
2010-03-02T11:49:08Z
2,363,485
<blockquote> <p>What I need is a simple and effective cross-platform web development language that works pretty much anywhere.</p> </blockquote> <p>Have you tried HTML?</p> <p>But seriously, I think Pekka is right when he says you need to specify and clarify what you want. Most of the features you don't want are s...
1
2010-03-02T13:47:33Z
[ "python", "web-frameworks" ]
Simple and effective web framework
2,362,840
<p>I'm looking for a suitable cross-platform web framework (if that's the proper term). I need something that doesn't rely on knowing the server's address or the absolute path to the files. Ideally it would come with a (development) server and be widely supported.</p> <p>I've already tried PHP, Django and web2py. Djan...
4
2010-03-02T11:49:08Z
6,516,933
<p>I am python newbie but experienced PHP developer for 12 years but I have to admit that I migrated to python because of the <a href="http://bottlepy.org/docs/dev/" rel="nofollow">bottle framework</a>. I am African so you don't have to be extra smart to use it... Give it a try, you'll love it. Hey and it also runs on...
1
2011-06-29T07:07:54Z
[ "python", "web-frameworks" ]
How to do mutual certificate authentication with httplib2
2,363,105
<p>I'm using httplib2 to make a request from my server to another web service. We want to use mutual certificate authentication. I see how to use a certificate for the outgoing connection (<code>h.set_certificate</code>), but how do I check the certificate used by the answering server?</p> <p><a href="http://code.go...
7
2010-03-02T12:41:09Z
2,382,365
<p>Here's the code my co-worker Dave St. Germain wrote to solve the problem:</p> <pre><code>import ssl import socket from httplib2 import has_timeout import httplib2 import socks class CertificateValidationError(httplib2.HttpLib2Error): pass def validating_sever_factory(ca_cert_file): # we need to define a...
4
2010-03-04T20:07:54Z
[ "python", "ssl", "httplib2" ]
How to do mutual certificate authentication with httplib2
2,363,105
<p>I'm using httplib2 to make a request from my server to another web service. We want to use mutual certificate authentication. I see how to use a certificate for the outgoing connection (<code>h.set_certificate</code>), but how do I check the certificate used by the answering server?</p> <p><a href="http://code.go...
7
2010-03-02T12:41:09Z
9,148,622
<p>perhaps things have changed since your question, I am able to do mutual authentication with <a href="http://code.google.com/p/httplib2/" rel="nofollow">httplib2</a> v0.7, as below:</p> <pre><code>import httplib2 h=httplib2.Http(ca_certs='ca.crt') h.add_certificate(key='client_private_key.pem', cert='cert_client.pe...
2
2012-02-05T10:50:19Z
[ "python", "ssl", "httplib2" ]
Nested functions scope in Python
2,363,266
<p>I have the following function that walks a nested tree and prints the result</p> <pre><code>def walk_tree(tree): def read_node(node): print node for n in node['subnodes']: read_node(n) read_node(tree) </code></pre> <p>If I want to return a txt with the data collected from wal...
2
2010-03-02T13:11:49Z
2,363,299
<p>You could try:</p> <pre><code>def walk_tree(tree): txt = '' # (1) def read_node(node, txt=txt): txt += node # (2) for n in node['subnodes']: read_node(n, txt) read_node(tree) </code></pre> <p>This binds <code>walk_tree</code>s value of txt to the default value in <code>read...
0
2010-03-02T13:16:53Z
[ "python", "tree" ]
Nested functions scope in Python
2,363,266
<p>I have the following function that walks a nested tree and prints the result</p> <pre><code>def walk_tree(tree): def read_node(node): print node for n in node['subnodes']: read_node(n) read_node(tree) </code></pre> <p>If I want to return a txt with the data collected from wal...
2
2010-03-02T13:11:49Z
2,363,303
<p><code>txt</code> is accessible in <code>read_node</code>, I think it's just some problem with <code>+=</code> and that <code>txt</code> is not in local scope in <code>read_node</code>.</p> <pre><code>&gt;&gt;&gt; def a(): ... x = "" ... def b(): ... x += "X" ... b() ... print x ... &gt;&gt;&gt; a() Traceback...
6
2010-03-02T13:17:43Z
[ "python", "tree" ]
Nested functions scope in Python
2,363,266
<p>I have the following function that walks a nested tree and prints the result</p> <pre><code>def walk_tree(tree): def read_node(node): print node for n in node['subnodes']: read_node(n) read_node(tree) </code></pre> <p>If I want to return a txt with the data collected from wal...
2
2010-03-02T13:11:49Z
2,363,334
<p>In Python you cannot rebind variables of an outer scope (of <code>walk_tree</code> in your example).</p> <p>So this will fail:</p> <pre><code>def a(): def b(): txt += "b" # !!! print txt txt = "mytext" b() a() </code></pre> <p>but this will work:</p> <pre><code>def a(): def b()...
5
2010-03-02T13:22:27Z
[ "python", "tree" ]
regular expression to extract @name symbols from tweet
2,363,289
<p>I would like to use regular expression to extract only <code>@patrick @michelle</code> from the following sentence:</p> <pre><code>@patrick @michelle we having diner @home tonight do you want to join? </code></pre> <p>Note: <code>@home</code> should not be include in the result because, it is not at beginning of...
0
2010-03-02T13:15:02Z
2,363,313
<p>Try this regular expression:</p> <pre><code>/^\s*@(\w+)\s+@(\w+)/ </code></pre> <p><code>\s</code> denotes whitespace characters and <code>\w</code> word characters.</p>
0
2010-03-02T13:19:28Z
[ "c#", "php", "python", "regex", "perl" ]
regular expression to extract @name symbols from tweet
2,363,289
<p>I would like to use regular expression to extract only <code>@patrick @michelle</code> from the following sentence:</p> <pre><code>@patrick @michelle we having diner @home tonight do you want to join? </code></pre> <p>Note: <code>@home</code> should not be include in the result because, it is not at beginning of...
0
2010-03-02T13:15:02Z
2,363,320
<p>As long as it starts with an @ and continues with those this will do it I tested it in poweshell so some regex engines are a bit different. This should also catch n names at the beginning of the line</p> <p>"^((@\w+)\s)+"</p>
0
2010-03-02T13:20:59Z
[ "c#", "php", "python", "regex", "perl" ]
regular expression to extract @name symbols from tweet
2,363,289
<p>I would like to use regular expression to extract only <code>@patrick @michelle</code> from the following sentence:</p> <pre><code>@patrick @michelle we having diner @home tonight do you want to join? </code></pre> <p>Note: <code>@home</code> should not be include in the result because, it is not at beginning of...
0
2010-03-02T13:15:02Z
2,363,325
<p>Perhaps something like this, though you'll have to split on whitespace anything in the matching group to extract multiple ids.</p> <pre><code>/^\s*(@\w+\s+)*\s+.*$/ </code></pre>
0
2010-03-02T13:21:43Z
[ "c#", "php", "python", "regex", "perl" ]
regular expression to extract @name symbols from tweet
2,363,289
<p>I would like to use regular expression to extract only <code>@patrick @michelle</code> from the following sentence:</p> <pre><code>@patrick @michelle we having diner @home tonight do you want to join? </code></pre> <p>Note: <code>@home</code> should not be include in the result because, it is not at beginning of...
0
2010-03-02T13:15:02Z
2,363,330
<pre><code>/(?:(?:@\S+\s+)+|^)@\S+/g </code></pre> <p>It first matches either an "@" followed by many non-space characters, or the start of line, and then matches another "@" followed by many non-space characters.</p> <p>Note that it's common in Twitter that <code>@name</code> is preceded by <code>RT</code>, appears ...
4
2010-03-02T13:22:06Z
[ "c#", "php", "python", "regex", "perl" ]
regular expression to extract @name symbols from tweet
2,363,289
<p>I would like to use regular expression to extract only <code>@patrick @michelle</code> from the following sentence:</p> <pre><code>@patrick @michelle we having diner @home tonight do you want to join? </code></pre> <p>Note: <code>@home</code> should not be include in the result because, it is not at beginning of...
0
2010-03-02T13:15:02Z
2,363,381
<p>You have tagged your post c#, so I assume you can use the .NET Regex imnplementation. Using .NET, the following Regex will do:</p> <pre><code>(?&lt;![^@]\w+\s+)(@\w+) </code></pre> <p>This will match any words starting with @, that do not have a word without @ before them. Note that "dinner @home @8pm" will still ...
0
2010-03-02T13:31:51Z
[ "c#", "php", "python", "regex", "perl" ]
regular expression to extract @name symbols from tweet
2,363,289
<p>I would like to use regular expression to extract only <code>@patrick @michelle</code> from the following sentence:</p> <pre><code>@patrick @michelle we having diner @home tonight do you want to join? </code></pre> <p>Note: <code>@home</code> should not be include in the result because, it is not at beginning of...
0
2010-03-02T13:15:02Z
2,363,382
<p>Well, at first I thought this failed because I looked at the groups that are returned:</p> <pre><code>&gt;&gt;&gt; tw = re.compile(r"^((@\w*)\s+)*") &gt;&gt;&gt; tw.findall(tweet) [('@michelle ', '@michelle')] &gt;&gt;&gt; tw.match(tweet).groups() ('@michelle ', '@michelle') </code></pre> <p>Note that the groups o...
1
2010-03-02T13:31:55Z
[ "c#", "php", "python", "regex", "perl" ]
regular expression to extract @name symbols from tweet
2,363,289
<p>I would like to use regular expression to extract only <code>@patrick @michelle</code> from the following sentence:</p> <pre><code>@patrick @michelle we having diner @home tonight do you want to join? </code></pre> <p>Note: <code>@home</code> should not be include in the result because, it is not at beginning of...
0
2010-03-02T13:15:02Z
2,363,480
<p>for PHP </p> <pre><code>/^\s*@(\w+)\s+@(\w+)/ </code></pre> <p>Thanks KennyM</p> <p>in python</p> <pre><code>msg = '@patrick @michelle we having diner @home tonight do you want to join?' import re re.findall('(?:(?:@\S+\s+)+|^)@\S+', msg) </code></pre> <p>This works with 1 or n @name at the beginning of the se...
0
2010-03-02T13:46:32Z
[ "c#", "php", "python", "regex", "perl" ]
regular expression to extract @name symbols from tweet
2,363,289
<p>I would like to use regular expression to extract only <code>@patrick @michelle</code> from the following sentence:</p> <pre><code>@patrick @michelle we having diner @home tonight do you want to join? </code></pre> <p>Note: <code>@home</code> should not be include in the result because, it is not at beginning of...
0
2010-03-02T13:15:02Z
2,381,469
<p>In Perl, you can exploit the <code>/g</code> match-more-than-once modifier combined with the <code>\G</code> zero-width where-we-left-off assertion and list context, thus:</p> <pre><code>my $str = '@patrick @michelle we having diner @home tonight do you want to join?'; my @matches = ($str =~ m/\G(\@\w+)\s*/g); pr...
0
2010-03-04T17:43:36Z
[ "c#", "php", "python", "regex", "perl" ]
regular expression to extract @name symbols from tweet
2,363,289
<p>I would like to use regular expression to extract only <code>@patrick @michelle</code> from the following sentence:</p> <pre><code>@patrick @michelle we having diner @home tonight do you want to join? </code></pre> <p>Note: <code>@home</code> should not be include in the result because, it is not at beginning of...
0
2010-03-02T13:15:02Z
2,528,786
<p>For Python check out: <a href="http://github.com/BonsaiDen/AtarashiiFormat" rel="nofollow">http://github.com/BonsaiDen/AtarashiiFormat</a><br> It will also give you the links and the tags.</p> <p>And beware of using a simple regex, you will end up with a big mess, as I did before I converted the Twitter Text Java L...
0
2010-03-27T09:47:14Z
[ "c#", "php", "python", "regex", "perl" ]
regular expression to extract @name symbols from tweet
2,363,289
<p>I would like to use regular expression to extract only <code>@patrick @michelle</code> from the following sentence:</p> <pre><code>@patrick @michelle we having diner @home tonight do you want to join? </code></pre> <p>Note: <code>@home</code> should not be include in the result because, it is not at beginning of...
0
2010-03-02T13:15:02Z
9,638,871
<p>For C# I would do as follows: </p> <p>@([A-Za-z0-9-_&amp;;]+)</p>
0
2012-03-09T18:08:43Z
[ "c#", "php", "python", "regex", "perl" ]
Splitting list in python
2,363,417
<p>I have a list which I have obtained from a python script. the content of the list goes something like: The content below is in a file but I loaded it into a list for comparing it to something else. But now I have to split this list such that each new list created contains the complex name with the corresponding numb...
0
2010-03-02T13:37:09Z
2,363,443
<p>without more detailed info and assuming your "list" is in a file.</p> <pre><code>f=0 for line in open("file"): if "d.complex.2" in line: break # or exit if "d.complex.1" in line: f=1 if f: print line.rstrip() </code></pre> <p>output</p> <pre><code>$ ./python.py d.complex.1 24 25 67 123...
0
2010-03-02T13:41:06Z
[ "python", "list", "split" ]
Splitting list in python
2,363,417
<p>I have a list which I have obtained from a python script. the content of the list goes something like: The content below is in a file but I loaded it into a list for comparing it to something else. But now I have to split this list such that each new list created contains the complex name with the corresponding numb...
0
2010-03-02T13:37:09Z
2,363,559
<pre><code>&gt;&gt;&gt; mylist='d.complex.1\n24\n25\n67\n123\n764\nd.complex.200\n23\n54\n35\n64\nd.complex.302'.split("\n") &gt;&gt;&gt; res=[] &gt;&gt;&gt; for line in mylist: ... if line.startswith("d.complex"): ... res.append([]) ... res[-1].append(line) ... &gt;&gt;&gt; res [['d.complex.1', '24', '25', '67', ...
0
2010-03-02T13:58:50Z
[ "python", "list", "split" ]
Python: slicing a very large binary file
2,363,483
<p>Say I have a binary file of 12GB and I want to slice 8GB out of the middle of it. I know the position indices I want to cut between.</p> <p>How do I do this? Obviously 12GB won't fit into memory, that's fine, but 8GB won't either... Which I thought was fine, but it appears binary doesn't seem to like it if you do i...
6
2010-03-02T13:47:17Z
2,364,633
<p>Here's a quick example. Adapt as needed:</p> <pre><code>def copypart(src,dest,start,length,bufsize=1024*1024): with open(src,'rb') as f1: f1.seek(start) with open(dest,'wb') as f2: while length: chunk = min(bufsize,length) data = f1.read(chunk) ...
5
2010-03-02T16:12:31Z
[ "python", "binary", "large-files" ]
python os.utime doesn't update the access time
2,363,497
<p>I'm trying to modify the access timestamp and modify timestamp of a remote file I'm using the following line:</p> <pre><code>os.utime(filePath, (1267533581,1267090862)) </code></pre> <p>the modify timestamp get updated but the access timestamp doesn't</p> <p>I have tried to use this on a local file on a local fi...
0
2010-03-02T13:49:21Z
2,363,556
<p>Perhaps the last access time is disabled on your system. This could have been done for performance purposes. It's controlled by a registry setting. See:</p> <p><a href="http://www.pctools.com/guides/registry/detail/50" rel="nofollow">http://www.pctools.com/guides/registry/detail/50</a></p>
1
2010-03-02T13:58:25Z
[ "python" ]