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 |
|---|---|---|---|---|---|---|---|---|---|
Python ConfigParser: how to work out options set in a specific section (rather than defaults) | 2,311,102 | <p>I have a config file that I read using the RawConfigParser in the standard ConfigParser library. My config file has a [DEFAULT] section followed by a [specific] section. When I loop through the options in the [specific] section, it includes the ones under [DEFAULT], which is what is meant to happen. </p>
<p>However... | 3 | 2010-02-22T13:28:26Z | 2,451,872 | <p>Given this configuration file:</p>
<pre><code>[DEFAULT]
name = a
surname = b
[Section 1]
name = section 1 name
age = 23
#we should get a surname value from defaults
[Section 2]
name = section 2 name
surname = section 2 surname
age = 24
</code></pre>
<p>Here's a program that can understand that Section 1 is usin... | 2 | 2010-03-16T03:06:23Z | [
"python",
"configparser"
] |
Python ConfigParser: how to work out options set in a specific section (rather than defaults) | 2,311,102 | <p>I have a config file that I read using the RawConfigParser in the standard ConfigParser library. My config file has a [DEFAULT] section followed by a [specific] section. When I loop through the options in the [specific] section, it includes the ones under [DEFAULT], which is what is meant to happen. </p>
<p>However... | 3 | 2010-02-22T13:28:26Z | 13,471,168 | <p>I did this recently by making the options into dictionaries, and then merging the dictionaries. The neat thing about it is that the user parameters override the defaults, and it's easy to pass them all to a function.</p>
<pre><code>import ConfigParser
config = ConfigParser.ConfigParser()
config.read('config.ini')
... | 5 | 2012-11-20T10:25:57Z | [
"python",
"configparser"
] |
How do I store a dict/list in a database? | 2,311,223 | <p>If I have a dictionary full of nested stuff, how do I store that in a database, as a string? and then, convert it back to a dictionary when I'm ready to parse?</p>
<p>Edit: I just want to convert it to a string...and then back to a dictionary.</p>
| 1 | 2010-02-22T13:49:20Z | 2,311,236 | <p>Why don't you use some serialization/deserialization from pickle module ?</p>
<p><a href="http://docs.python.org/library/pickle.html" rel="nofollow">http://docs.python.org/library/pickle.html</a></p>
| 3 | 2010-02-22T13:50:37Z | [
"python",
"database",
"string",
"list",
"dictionary"
] |
How do I store a dict/list in a database? | 2,311,223 | <p>If I have a dictionary full of nested stuff, how do I store that in a database, as a string? and then, convert it back to a dictionary when I'm ready to parse?</p>
<p>Edit: I just want to convert it to a string...and then back to a dictionary.</p>
| 1 | 2010-02-22T13:49:20Z | 2,311,245 | <p>Options:</p>
<p>1) Pickling</p>
<p>2) XML</p>
<p>3) JSON</p>
<p>others I am sure. It has a lot to do on how much portability means to you.</p>
| 4 | 2010-02-22T13:52:26Z | [
"python",
"database",
"string",
"list",
"dictionary"
] |
How do I store a dict/list in a database? | 2,311,223 | <p>If I have a dictionary full of nested stuff, how do I store that in a database, as a string? and then, convert it back to a dictionary when I'm ready to parse?</p>
<p>Edit: I just want to convert it to a string...and then back to a dictionary.</p>
| 1 | 2010-02-22T13:49:20Z | 2,312,128 | <p>Best, under your stated conditions:</p>
<pre><code>import cPickle
...
thestring = cPickle.dumps(thedict, -1)
</code></pre>
<p>the <code>-1</code> ensures the most efficient serialization and produces a <em>binary</em> string (arbitrary string of bytes). If you need an <em>ascii</em> string (because e.g. some U... | 2 | 2010-02-22T16:00:02Z | [
"python",
"database",
"string",
"list",
"dictionary"
] |
How do I store a dict/list in a database? | 2,311,223 | <p>If I have a dictionary full of nested stuff, how do I store that in a database, as a string? and then, convert it back to a dictionary when I'm ready to parse?</p>
<p>Edit: I just want to convert it to a string...and then back to a dictionary.</p>
| 1 | 2010-02-22T13:49:20Z | 2,312,726 | <p>You have two options</p>
<ul>
<li><p>use a standard serialization format (json, xml, yaml, ...)</p>
<ul>
<li>pros: you can access with a any language that can parse those formats (on the worst case you can write your own parser)</li>
<li>cons: could be slower to save and load the data (this depends of the implemen... | 1 | 2010-02-22T17:25:33Z | [
"python",
"database",
"string",
"list",
"dictionary"
] |
How do I store a dict/list in a database? | 2,311,223 | <p>If I have a dictionary full of nested stuff, how do I store that in a database, as a string? and then, convert it back to a dictionary when I'm ready to parse?</p>
<p>Edit: I just want to convert it to a string...and then back to a dictionary.</p>
| 1 | 2010-02-22T13:49:20Z | 2,312,727 | <p>There are any number of serialization methods out there, JSON is readable, reasonably compact, supported natively, and portable. I prefer it over pickle, since the latter can execute arbitrary code and potentially introduce security holes, and because of its portability. </p>
<p>Depending on your data's layout, you... | 2 | 2010-02-22T17:25:40Z | [
"python",
"database",
"string",
"list",
"dictionary"
] |
Django efficiency question | 2,311,251 | <p>I am wondering would this make any real efficieny difference (ie computation time, memory etc..)</p>
<p>This is my model:</p>
<pre><code>class FooUser(models.Model):
name = models.CharField(max_length=50)
sirname = models.CharField(max_length=50)
</code></pre>
<p>Assume I have 2 different approaches while... | 0 | 2010-02-22T13:54:24Z | 2,311,355 | <p>This:</p>
<pre><code> input_name =request.session['name']
input_sirname =request.session['sirname']
</code></pre>
<p>is not copying strings to variables. It's only assigning pointers to string objects to names in local dictionary (input_name, input_sirname). For better explanation you can take a loot at this: <a ... | 4 | 2010-02-22T14:12:25Z | [
"python",
"django",
"performance"
] |
Django efficiency question | 2,311,251 | <p>I am wondering would this make any real efficieny difference (ie computation time, memory etc..)</p>
<p>This is my model:</p>
<pre><code>class FooUser(models.Model):
name = models.CharField(max_length=50)
sirname = models.CharField(max_length=50)
</code></pre>
<p>Assume I have 2 different approaches while... | 0 | 2010-02-22T13:54:24Z | 2,312,054 | <p>I would argue that the second method (with passing request.session elements directly) is more readable. Looking at the code I know immediately what's going on - it's creating an object using raw, unmodified session data. Had it been just a variable I wouldn't know where it comes from, had it been modified in the mea... | 0 | 2010-02-22T15:50:20Z | [
"python",
"django",
"performance"
] |
Django efficiency question | 2,311,251 | <p>I am wondering would this make any real efficieny difference (ie computation time, memory etc..)</p>
<p>This is my model:</p>
<pre><code>class FooUser(models.Model):
name = models.CharField(max_length=50)
sirname = models.CharField(max_length=50)
</code></pre>
<p>Assume I have 2 different approaches while... | 0 | 2010-02-22T13:54:24Z | 2,312,076 | <p>The time required to bind a local name to a value, as in, e.g., <code>input_name = request.session['name']</code>, is absolutely negligible compared to the time executing <code>.save()</code> itself will take -- you'll never be able to measure it. So, forget such small efficiencies and focus on style, robustness, m... | 1 | 2010-02-22T15:53:26Z | [
"python",
"django",
"performance"
] |
Reliably monitor current CPU usage | 2,311,301 | <p>I'd like to monitor the current system-wide CPU usage on a Mac with Python.</p>
<p>I've written some code that starts 'ps', and adds up all the values from the '%cpu' column.</p>
<pre><code>def psColumn(colName):
"""Get a column of ps output as a list"""
ps = subprocess.Popen(["ps", "-A", "-o", colName], s... | 2 | 2010-02-22T14:01:58Z | 2,311,398 | <p>For detecting critical situations when some program is hogging the CPU perhaps looking at load average is better? Take a look at "uptime" command. </p>
<p>Load average number tells you how many processes on average are using or waiting on CPU for execution. If it is close to or over 1.0, it means the system is cons... | 3 | 2010-02-22T14:21:24Z | [
"python",
"osx",
"cpu"
] |
Reliably monitor current CPU usage | 2,311,301 | <p>I'd like to monitor the current system-wide CPU usage on a Mac with Python.</p>
<p>I've written some code that starts 'ps', and adds up all the values from the '%cpu' column.</p>
<pre><code>def psColumn(colName):
"""Get a column of ps output as a list"""
ps = subprocess.Popen(["ps", "-A", "-o", colName], s... | 2 | 2010-02-22T14:01:58Z | 2,311,471 | <p>I was working on basically the same thing just a couple of weeks ago and I too was having trouble with psutil.cpu_percent(). </p>
<p>Instead I used psutil.cpu_times() which gives cpu time used for user, system, idle and other things depending on your OS. I dont know if this is a good way or even an accurate way o... | 1 | 2010-02-22T14:31:25Z | [
"python",
"osx",
"cpu"
] |
Reliably monitor current CPU usage | 2,311,301 | <p>I'd like to monitor the current system-wide CPU usage on a Mac with Python.</p>
<p>I've written some code that starts 'ps', and adds up all the values from the '%cpu' column.</p>
<pre><code>def psColumn(colName):
"""Get a column of ps output as a list"""
ps = subprocess.Popen(["ps", "-A", "-o", colName], s... | 2 | 2010-02-22T14:01:58Z | 3,120,779 | <pre><code>>>> import psutil, time
>>> print psutil.cpu_times()
softirq=50.87; iowait=39.63; system=1130.67; idle=164171.41; user=965.15; irq=7.08; nice=0.0
>>>
>>> while 1:
... print round(psutil.cpu_percent(), 1)
... time.sleep(1)
...
5.4
3.2
7.3
7.1
2.5
</code></pre>
| 1 | 2010-06-25T19:13:58Z | [
"python",
"osx",
"cpu"
] |
speed-up python function to process files with data segments separated by a blank space | 2,311,376 | <p>I need to process files with data segments separated by a blank space, for example:</p>
<pre><code>93.18 15.21 36.69 33.85 16.41 16.81 29.17
21.69 23.71 26.38 63.70 66.69 0.89 39.91
86.55 56.34 57.80 98.38 0.24 17.19 75.46
[...]
1.30 73.02 56.79 39.28 96.39 18.77 55.03
99.95 28.88 90.90 26.70 62.37 86.58 65.05 ... | 2 | 2010-02-22T14:17:55Z | 2,311,391 | <p>not to convert floats to floats would be the first step. I would suggest, however, to first <a href="http://docs.python.org/library/profile.html" rel="nofollow">profile your code</a> and then try to optimize the bottleneck parts.</p>
<p>I understand that you've changed your code from the original, but </p>
<pre><c... | 2 | 2010-02-22T14:20:34Z | [
"python",
"numpy",
"performance"
] |
speed-up python function to process files with data segments separated by a blank space | 2,311,376 | <p>I need to process files with data segments separated by a blank space, for example:</p>
<pre><code>93.18 15.21 36.69 33.85 16.41 16.81 29.17
21.69 23.71 26.38 63.70 66.69 0.89 39.91
86.55 56.34 57.80 98.38 0.24 17.19 75.46
[...]
1.30 73.02 56.79 39.28 96.39 18.77 55.03
99.95 28.88 90.90 26.70 62.37 86.58 65.05 ... | 2 | 2010-02-22T14:17:55Z | 2,311,545 | <p>You are only reading every character exactly once, so there isn't any real performance to gain.</p>
<p>You could combine strip and split if the empty lines contain a lot of whitespace.</p>
<p>You could also save some time initializing the numpy array from start, instead of first creating a python array and then co... | 1 | 2010-02-22T14:41:28Z | [
"python",
"numpy",
"performance"
] |
speed-up python function to process files with data segments separated by a blank space | 2,311,376 | <p>I need to process files with data segments separated by a blank space, for example:</p>
<pre><code>93.18 15.21 36.69 33.85 16.41 16.81 29.17
21.69 23.71 26.38 63.70 66.69 0.89 39.91
86.55 56.34 57.80 98.38 0.24 17.19 75.46
[...]
1.30 73.02 56.79 39.28 96.39 18.77 55.03
99.95 28.88 90.90 26.70 62.37 86.58 65.05 ... | 2 | 2010-02-22T14:17:55Z | 2,311,812 | <p><a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.fromfile.html" rel="nofollow">numpy.fromfile</a> doesn't work for you?</p>
<pre><code>arr = fromfile('tmp.txt', sep=' ', dtype=int)
</code></pre>
| 0 | 2010-02-22T15:16:31Z | [
"python",
"numpy",
"performance"
] |
speed-up python function to process files with data segments separated by a blank space | 2,311,376 | <p>I need to process files with data segments separated by a blank space, for example:</p>
<pre><code>93.18 15.21 36.69 33.85 16.41 16.81 29.17
21.69 23.71 26.38 63.70 66.69 0.89 39.91
86.55 56.34 57.80 98.38 0.24 17.19 75.46
[...]
1.30 73.02 56.79 39.28 96.39 18.77 55.03
99.95 28.88 90.90 26.70 62.37 86.58 65.05 ... | 2 | 2010-02-22T14:17:55Z | 2,312,409 | <p>try increasing the read buffer, IO is probably the bottle neck of your code</p>
<pre><code>open('file.txt', 'r', 1024 * 10)
</code></pre>
<p>also if the data is fully sequential you can try to skip the line by line code and convert a bunch of lines at once</p>
| 1 | 2010-02-22T16:37:49Z | [
"python",
"numpy",
"performance"
] |
speed-up python function to process files with data segments separated by a blank space | 2,311,376 | <p>I need to process files with data segments separated by a blank space, for example:</p>
<pre><code>93.18 15.21 36.69 33.85 16.41 16.81 29.17
21.69 23.71 26.38 63.70 66.69 0.89 39.91
86.55 56.34 57.80 98.38 0.24 17.19 75.46
[...]
1.30 73.02 56.79 39.28 96.39 18.77 55.03
99.95 28.88 90.90 26.70 62.37 86.58 65.05 ... | 2 | 2010-02-22T14:17:55Z | 2,314,412 | <p>Instead of :</p>
<pre><code>if len(line) <= 1: # only '\n' in «empty» lines
break
values = line.split()
</code></pre>
<p>try this:</p>
<pre><code>values = line.split()
if not values: # line is wholly whitespace, end of segment
break
</code></pre>
| 1 | 2010-02-22T21:38:57Z | [
"python",
"numpy",
"performance"
] |
speed-up python function to process files with data segments separated by a blank space | 2,311,376 | <p>I need to process files with data segments separated by a blank space, for example:</p>
<pre><code>93.18 15.21 36.69 33.85 16.41 16.81 29.17
21.69 23.71 26.38 63.70 66.69 0.89 39.91
86.55 56.34 57.80 98.38 0.24 17.19 75.46
[...]
1.30 73.02 56.79 39.28 96.39 18.77 55.03
99.95 28.88 90.90 26.70 62.37 86.58 65.05 ... | 2 | 2010-02-22T14:17:55Z | 2,314,719 | <p>Here's a variant that <em>might</em> be faster for few indices. It builds a string of only the desired values so that <code>np.fromstring</code> does less work.</p>
<pre><code>def get_pos_nextvalues_fewindices(pos_file, indices):
result = ''
for line in pos_file:
if len(line) > 1:
s ... | 0 | 2010-02-22T22:19:55Z | [
"python",
"numpy",
"performance"
] |
How to make a user friendly start of a Python program? | 2,311,455 | <p>I have a Python program (GUI application). I can run this program from the command prompt on Windows (command line on Linux). But it can be too complicated for users. Is there an easy way to initiate a start of the program with a click (double click) on a pictogram (a small image on the desktop)?</p>
| 0 | 2010-02-22T14:28:43Z | 2,311,525 | <p>I'm not sure if I understood the question well, but if you just need a way to simulate a command line input with a simply clickable icon, just create a simple .bat file (assuming windows) on the desktop, as a new text file containing something like </p>
<blockquote>
<p>C:\[Pythonpath]\python C:\[MyPythonAppPath]\... | 1 | 2010-02-22T14:38:35Z | [
"python",
"command-line",
"desktop",
"command-prompt"
] |
How to make a user friendly start of a Python program? | 2,311,455 | <p>I have a Python program (GUI application). I can run this program from the command prompt on Windows (command line on Linux). But it can be too complicated for users. Is there an easy way to initiate a start of the program with a click (double click) on a pictogram (a small image on the desktop)?</p>
| 0 | 2010-02-22T14:28:43Z | 2,311,920 | <p><strong>Linux:</strong>
I am not sure, which linux distro and desktop you use but for gnome I create such files on desktop e.. create a myapp.desktop and put in on desktop</p>
<pre><code>[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=MyApp
Type=Application
Exec=python /home/anushri/display.anurag/xxx.py
TryExec=
I... | 1 | 2010-02-22T15:33:18Z | [
"python",
"command-line",
"desktop",
"command-prompt"
] |
How to make a user friendly start of a Python program? | 2,311,455 | <p>I have a Python program (GUI application). I can run this program from the command prompt on Windows (command line on Linux). But it can be too complicated for users. Is there an easy way to initiate a start of the program with a click (double click) on a pictogram (a small image on the desktop)?</p>
| 0 | 2010-02-22T14:28:43Z | 2,311,990 | <p>What I've done in the past is use <a href="http://www.py2exe.org/" rel="nofollow">py2exe</a> to create an executable from my python script. That embeds the interpreter and the source inside an EXE, that way it works just like a native executable and you don't have to have the users install python or anything compli... | 0 | 2010-02-22T15:41:16Z | [
"python",
"command-line",
"desktop",
"command-prompt"
] |
How to make a user friendly start of a Python program? | 2,311,455 | <p>I have a Python program (GUI application). I can run this program from the command prompt on Windows (command line on Linux). But it can be too complicated for users. Is there an easy way to initiate a start of the program with a click (double click) on a pictogram (a small image on the desktop)?</p>
| 0 | 2010-02-22T14:28:43Z | 2,332,334 | <p>Use py2exe to make an exe and just to make it more 'user friendly' use Inno set up (www.jrsoftware.org/isinfo.php ) along with IStools to build up an installer which would integrate the GUI with sound, widgets, other elements etc and users who do not have python etc installed in their systems can also play your GUI ... | 1 | 2010-02-25T07:22:07Z | [
"python",
"command-line",
"desktop",
"command-prompt"
] |
Getting a machine's external IP address | 2,311,510 | <p>Looking for a better way to get a machines current external IP #... Below works, but would rather not rely on an outside site to gather the information ... I am restricted to using standard Python 2.5.1 libraries bundled with Mac OS X 10.5.x</p>
<pre><code>import os
import urllib2
def check_in():
fqn = os.una... | 21 | 2010-02-22T14:36:40Z | 2,311,530 | <p>If the machine is being a firewall then your solution is a very sensible one: the alternative being able to query the firewall which ends-up being very dependent on the type of firewall (if at all possible).</p>
| 2 | 2010-02-22T14:39:45Z | [
"python",
"standard-library"
] |
Getting a machine's external IP address | 2,311,510 | <p>Looking for a better way to get a machines current external IP #... Below works, but would rather not rely on an outside site to gather the information ... I am restricted to using standard Python 2.5.1 libraries bundled with Mac OS X 10.5.x</p>
<pre><code>import os
import urllib2
def check_in():
fqn = os.una... | 21 | 2010-02-22T14:36:40Z | 2,311,543 | <p>If you are behind a router which obtains the external IP, I'm afraid you have no other option but to use external service like you do. If the router itself has some query interface, you can use it, but the solution will be very environment-specific and unreliable.</p>
| 15 | 2010-02-22T14:41:19Z | [
"python",
"standard-library"
] |
Getting a machine's external IP address | 2,311,510 | <p>Looking for a better way to get a machines current external IP #... Below works, but would rather not rely on an outside site to gather the information ... I am restricted to using standard Python 2.5.1 libraries bundled with Mac OS X 10.5.x</p>
<pre><code>import os
import urllib2
def check_in():
fqn = os.una... | 21 | 2010-02-22T14:36:40Z | 2,311,603 | <p>Just as an alternative. Here's a <a href="http://ipcheck.sourceforge.net/" rel="nofollow">script</a> you can try out.</p>
| 0 | 2010-02-22T14:51:00Z | [
"python",
"standard-library"
] |
Getting a machine's external IP address | 2,311,510 | <p>Looking for a better way to get a machines current external IP #... Below works, but would rather not rely on an outside site to gather the information ... I am restricted to using standard Python 2.5.1 libraries bundled with Mac OS X 10.5.x</p>
<pre><code>import os
import urllib2
def check_in():
fqn = os.una... | 21 | 2010-02-22T14:36:40Z | 2,311,622 | <p>If you think and external source is too unreliable, you could pool a few different services. For most ip lookup pages they require you to scrape html, but a few of them that have created lean pages for scripts like yours - also so they can reduce the hits on their sites:</p>
<ul>
<li><a href="http://automation.what... | 7 | 2010-02-22T14:52:17Z | [
"python",
"standard-library"
] |
Getting a machine's external IP address | 2,311,510 | <p>Looking for a better way to get a machines current external IP #... Below works, but would rather not rely on an outside site to gather the information ... I am restricted to using standard Python 2.5.1 libraries bundled with Mac OS X 10.5.x</p>
<pre><code>import os
import urllib2
def check_in():
fqn = os.una... | 21 | 2010-02-22T14:36:40Z | 8,251,444 | <p>As Sunny has suggested, its not possible in general to get external ip-address being inside a network without any help from external services.
Have a look at the following tutorial which covers exactly the same thing. I guess it works for Python 2.5.X.
<a href="http://codetempo.com/programming/python/monitoring-ip... | 0 | 2011-11-24T02:04:03Z | [
"python",
"standard-library"
] |
Getting a machine's external IP address | 2,311,510 | <p>Looking for a better way to get a machines current external IP #... Below works, but would rather not rely on an outside site to gather the information ... I am restricted to using standard Python 2.5.1 libraries bundled with Mac OS X 10.5.x</p>
<pre><code>import os
import urllib2
def check_in():
fqn = os.una... | 21 | 2010-02-22T14:36:40Z | 9,944,261 | <p>This piece of python code will do it</p>
<pre><code>import urllib
import re
f = urllib.urlopen("http://www.canyouseeme.org/")
html_doc = f.read()
f.close()
m = re.search('(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]... | 2 | 2012-03-30T13:48:11Z | [
"python",
"standard-library"
] |
Getting a machine's external IP address | 2,311,510 | <p>Looking for a better way to get a machines current external IP #... Below works, but would rather not rely on an outside site to gather the information ... I am restricted to using standard Python 2.5.1 libraries bundled with Mac OS X 10.5.x</p>
<pre><code>import os
import urllib2
def check_in():
fqn = os.una... | 21 | 2010-02-22T14:36:40Z | 14,699,673 | <pre><code>ipWebCode = urllib.request.urlopen("http://ip.nefsc.noaa.gov").read().decode("utf8")
ipWebCode=ipWebCode.split("color=red> ")
ipWebCode = ipWebCode[1]
ipWebCode = ipWebCode.split("</font>")
externalIp = ipWebCode[0]
</code></pre>
<p>this is a short snippet I had written for another program. The tri... | 0 | 2013-02-05T03:23:00Z | [
"python",
"standard-library"
] |
Getting a machine's external IP address | 2,311,510 | <p>Looking for a better way to get a machines current external IP #... Below works, but would rather not rely on an outside site to gather the information ... I am restricted to using standard Python 2.5.1 libraries bundled with Mac OS X 10.5.x</p>
<pre><code>import os
import urllib2
def check_in():
fqn = os.una... | 21 | 2010-02-22T14:36:40Z | 16,951,414 | <p>I tried most of the other answers on this question here and came to find that most of the services used were defunct except one.</p>
<p>Here is a script that should do the trick and download only a minimal amount of information:</p>
<pre><code>#!/usr/bin/env python
import urllib
import re
def get_external_ip():
... | 3 | 2013-06-05T23:18:58Z | [
"python",
"standard-library"
] |
Getting a machine's external IP address | 2,311,510 | <p>Looking for a better way to get a machines current external IP #... Below works, but would rather not rely on an outside site to gather the information ... I am restricted to using standard Python 2.5.1 libraries bundled with Mac OS X 10.5.x</p>
<pre><code>import os
import urllib2
def check_in():
fqn = os.una... | 21 | 2010-02-22T14:36:40Z | 21,217,054 | <p>Here's another alternative script.</p>
<pre><code>def track_ip():
"""
Returns Dict with the following keys:
- ip
- latlong
- country
- city
- user-agent
"""
conn = httplib.HTTPConnection("www.trackip.net")
conn.request("GET", "/ip?json")
resp = conn.getresponse()
print resp.stat... | 1 | 2014-01-19T12:59:44Z | [
"python",
"standard-library"
] |
Getting a machine's external IP address | 2,311,510 | <p>Looking for a better way to get a machines current external IP #... Below works, but would rather not rely on an outside site to gather the information ... I am restricted to using standard Python 2.5.1 libraries bundled with Mac OS X 10.5.x</p>
<pre><code>import os
import urllib2
def check_in():
fqn = os.una... | 21 | 2010-02-22T14:36:40Z | 22,157,882 | <p>I wrote a module for that: <a href="https://pypi.python.org/pypi/ipgetter">ipgetter</a>.
Is designed to fetch your external IP address from the internet. It is used mostly when behind a NAT. It picks your IP randomly from a serverlist to minimize request overhead on a single server.
Actually with 44 server and test ... | 25 | 2014-03-03T21:31:28Z | [
"python",
"standard-library"
] |
Getting a machine's external IP address | 2,311,510 | <p>Looking for a better way to get a machines current external IP #... Below works, but would rather not rely on an outside site to gather the information ... I am restricted to using standard Python 2.5.1 libraries bundled with Mac OS X 10.5.x</p>
<pre><code>import os
import urllib2
def check_in():
fqn = os.una... | 21 | 2010-02-22T14:36:40Z | 22,674,095 | <pre><code>In [1]: import stun
stun.get_ip_info()
('Restric NAT', 'xx.xx.xx.xx', 55320)
</code></pre>
| 1 | 2014-03-26T22:10:12Z | [
"python",
"standard-library"
] |
Getting a machine's external IP address | 2,311,510 | <p>Looking for a better way to get a machines current external IP #... Below works, but would rather not rely on an outside site to gather the information ... I am restricted to using standard Python 2.5.1 libraries bundled with Mac OS X 10.5.x</p>
<pre><code>import os
import urllib2
def check_in():
fqn = os.una... | 21 | 2010-02-22T14:36:40Z | 23,461,888 | <p>If you're just writing for yourself and not for a generalized application, you might be able to find the address on the setup page for your router and then scrape it from that page's html. This worked fine for me with my SMC router. One read and one simple RE search and I've found it.</p>
<p>My particular interest ... | 0 | 2014-05-04T21:39:18Z | [
"python",
"standard-library"
] |
Getting a machine's external IP address | 2,311,510 | <p>Looking for a better way to get a machines current external IP #... Below works, but would rather not rely on an outside site to gather the information ... I am restricted to using standard Python 2.5.1 libraries bundled with Mac OS X 10.5.x</p>
<pre><code>import os
import urllib2
def check_in():
fqn = os.una... | 21 | 2010-02-22T14:36:40Z | 23,562,537 | <p>The most simple (non python) working solution I can think of is</p>
<pre><code>wget -q -O- icanhazip.com
</code></pre>
<p>I'd like to add a very short Python3 solution which makes use of the JSON API of <a href="http://hostip.info" rel="nofollow">http://hostip.info</a>.</p>
<pre><code>from urllib.request import u... | 2 | 2014-05-09T10:39:25Z | [
"python",
"standard-library"
] |
Getting a machine's external IP address | 2,311,510 | <p>Looking for a better way to get a machines current external IP #... Below works, but would rather not rely on an outside site to gather the information ... I am restricted to using standard Python 2.5.1 libraries bundled with Mac OS X 10.5.x</p>
<pre><code>import os
import urllib2
def check_in():
fqn = os.una... | 21 | 2010-02-22T14:36:40Z | 31,092,297 | <p>In my opinion the simplest solution is </p>
<pre><code> f = requests.request('GET', 'http://myip.dnsomatic.com')
ip = f.text
</code></pre>
<p>Thats all.</p>
| 2 | 2015-06-27T18:48:12Z | [
"python",
"standard-library"
] |
Getting a machine's external IP address | 2,311,510 | <p>Looking for a better way to get a machines current external IP #... Below works, but would rather not rely on an outside site to gather the information ... I am restricted to using standard Python 2.5.1 libraries bundled with Mac OS X 10.5.x</p>
<pre><code>import os
import urllib2
def check_in():
fqn = os.una... | 21 | 2010-02-22T14:36:40Z | 35,707,014 | <p>Use this script :</p>
<pre><code>import urllib, json
data = json.loads(urllib.urlopen("http://ip.jsontest.com/").read())
print data["ip"]
</code></pre>
<p>Without json :</p>
<pre><code>import urllib, re
data = re.search('"([0-9.]*)"', urllib.urlopen("http://ip.jsontest.com/").read()).group(1)
print data
</code>... | 0 | 2016-02-29T18:37:05Z | [
"python",
"standard-library"
] |
Getting a machine's external IP address | 2,311,510 | <p>Looking for a better way to get a machines current external IP #... Below works, but would rather not rely on an outside site to gather the information ... I am restricted to using standard Python 2.5.1 libraries bundled with Mac OS X 10.5.x</p>
<pre><code>import os
import urllib2
def check_in():
fqn = os.una... | 21 | 2010-02-22T14:36:40Z | 36,205,547 | <p>I liked the <a href="http://ipify.org" rel="nofollow">http://ipify.org</a>. They even provide Python code for using their API.</p>
<pre><code># This example requires the requests library be installed. You can learn more
# about the Requests library here: http://docs.python-requests.org/en/latest/
from requests im... | 2 | 2016-03-24T16:44:21Z | [
"python",
"standard-library"
] |
Empty list in appengine datastore: java vs python | 2,311,533 | <p>I have the following java model class in AppEngine:</p>
<pre><code>public class Xyz ... {
@Persistent
private Set<Long> uvw;
}
</code></pre>
<p>When saving an object <em>Xyz</em> with an <strong>empty</strong> set <em>uvw</em> in Java, I get a "<strong>null</strong>" field (as listed in the appengine... | 11 | 2010-02-22T14:40:16Z | 2,311,644 | <p>The Java Set behavior is because Java's Collections are reference types, which default to being null.</p>
<p>To actually create an empty Set, declare it like this:</p>
<pre><code>@Persistent
private Set<Long> uvw = new HashSet<Long>();
</code></pre>
<p>or using some other implementation of <a href="ht... | 0 | 2010-02-22T14:55:07Z | [
"java",
"python",
"google-app-engine",
"datanucleus"
] |
Empty list in appengine datastore: java vs python | 2,311,533 | <p>I have the following java model class in AppEngine:</p>
<pre><code>public class Xyz ... {
@Persistent
private Set<Long> uvw;
}
</code></pre>
<p>When saving an object <em>Xyz</em> with an <strong>empty</strong> set <em>uvw</em> in Java, I get a "<strong>null</strong>" field (as listed in the appengine... | 11 | 2010-02-22T14:40:16Z | 3,056,482 | <p>I use the low-level java api, so perhaps what I am doing would be different. But before I save a collection-type data structure to the datastore, I convert it into something that the datastore naturally handles. This would include mainly Strings and ByteArrays.</p>
<p>It sounds like java app engine is interpretin... | 1 | 2010-06-16T19:23:14Z | [
"java",
"python",
"google-app-engine",
"datanucleus"
] |
Empty list in appengine datastore: java vs python | 2,311,533 | <p>I have the following java model class in AppEngine:</p>
<pre><code>public class Xyz ... {
@Persistent
private Set<Long> uvw;
}
</code></pre>
<p>When saving an object <em>Xyz</em> with an <strong>empty</strong> set <em>uvw</em> in Java, I get a "<strong>null</strong>" field (as listed in the appengine... | 11 | 2010-02-22T14:40:16Z | 3,079,410 | <p>It should work if you assign a default value to your Python property:</p>
<pre><code>uvw = db.ListProperty(int, default=[])
</code></pre>
| 2 | 2010-06-20T13:36:55Z | [
"java",
"python",
"google-app-engine",
"datanucleus"
] |
Slicing at runtime | 2,311,578 | <p>can someone explain me how to slice a numpy.array at runtime?
I don't know the rank (number of dimensions) at 'coding time'.</p>
<p>A minimal example:</p>
<pre><code>import numpy as np
a = np.arange(16).reshape(4,4) # 2D matrix
targetsize = [2,3] # desired shape
b_correct = dynSlicing(a, targetsize)
b_wrong = np.... | 3 | 2010-02-22T14:46:58Z | 2,311,707 | <p>You can directly 'change' it. This is due to the nature of arrays only allowing backdrop.</p>
<p>Instead you can copy a section, or even better create a view of the desired shape:
<a href="http://www.scipy.org/Tentative_NumPy_Tutorial#head-1529ae93dd5d431ffe3a1001a4ab1a394e70a5f2" rel="nofollow">http://www.scipy.or... | 1 | 2010-02-22T15:03:02Z | [
"python",
"numpy"
] |
Slicing at runtime | 2,311,578 | <p>can someone explain me how to slice a numpy.array at runtime?
I don't know the rank (number of dimensions) at 'coding time'.</p>
<p>A minimal example:</p>
<pre><code>import numpy as np
a = np.arange(16).reshape(4,4) # 2D matrix
targetsize = [2,3] # desired shape
b_correct = dynSlicing(a, targetsize)
b_wrong = np.... | 3 | 2010-02-22T14:46:58Z | 2,311,792 | <p>Passing a tuple of slice objects does the job:</p>
<pre><code>def dynSlicing(data, targetsize):
return data[tuple(slice(x) for x in targetsize)]
</code></pre>
| 6 | 2010-02-22T15:13:09Z | [
"python",
"numpy"
] |
Slicing at runtime | 2,311,578 | <p>can someone explain me how to slice a numpy.array at runtime?
I don't know the rank (number of dimensions) at 'coding time'.</p>
<p>A minimal example:</p>
<pre><code>import numpy as np
a = np.arange(16).reshape(4,4) # 2D matrix
targetsize = [2,3] # desired shape
b_correct = dynSlicing(a, targetsize)
b_wrong = np.... | 3 | 2010-02-22T14:46:58Z | 2,311,995 | <p>Simple solution:</p>
<pre><code>b = a[tuple(map(slice,targetsize))]
</code></pre>
| 2 | 2010-02-22T15:41:48Z | [
"python",
"numpy"
] |
Using Javascript to change all textareas in an html page | 2,311,718 | <p>I am creating a project in Django, and I am using the Django Admin pages along with TinyMCE. But I would like to be able to toggle TinyMCE on and off like in this example:</p>
<p><a href="http://tinymce.moxiecode.com/examples/example_01.php" rel="nofollow">http://tinymce.moxiecode.com/examples/example_01.php</a></p... | 1 | 2010-02-22T15:05:07Z | 2,311,751 | <p>You can use</p>
<pre><code>document.getElementsByTagName("textarea")
</code></pre>
<p>to return an array of all the <textarea/> elements. Then iterate over it and do with it as you will.</p>
| 4 | 2010-02-22T15:08:58Z | [
"javascript",
"python",
"django",
"django-admin"
] |
QListWidget on freemantle | 2,311,739 | <p>I have a problem with QListWidget on freemantle (maemo, n900).</p>
<p>I want to use two QListWidget on same window and allow the user to pick on number in each window.</p>
<p>When the user use the second QListWidget, the "blue" color on it disparear.
How to change the color of a item selected in QListWidget which ... | 3 | 2010-02-22T15:07:45Z | 2,312,532 | <p>Kind of a hack, but you can change the <code>QPallete</code> of both <code>QListWidgets</code> so that the inactive color is the same as the active color.</p>
<p><a href="http://qt.nokia.com/doc/4.6/qpalette.html#ColorGroup-enum" rel="nofollow">http://qt.nokia.com/doc/4.6/qpalette.html#ColorGroup-enum</a></p>
<p>T... | 2 | 2010-02-22T16:54:26Z | [
"python",
"qt",
"maemo",
"n900"
] |
How to pass data from Google App Engine(Python) to Flex 4 application | 2,311,796 | <p>I am using python and webapp framework in app engine for backend and flex 4 for front end.
I would like to pass a string form backend to front end, so i write the following code in the main.py:</p>
<pre><code>class MainPage(webapp.RequestHandler):
def get(self):
userVO = "test"
template_values = {
'url':... | 0 | 2010-02-22T15:13:49Z | 2,312,018 | <p>The best way to talk from Flex to GAE is using AMF. Here is how:</p>
<p>app.yaml</p>
<pre><code>application: flexandthecloud
version: 3
runtime: python
api_version: 1
handlers:
- url: /services/.*
script: main.py
</code></pre>
<p>main.py</p>
<pre><code>#!/usr/bin/env python
import wsgiref.handlers
from pyam... | 2 | 2010-02-22T15:45:59Z | [
"python",
"flex",
"google-app-engine",
"swfobject"
] |
How to pass data from Google App Engine(Python) to Flex 4 application | 2,311,796 | <p>I am using python and webapp framework in app engine for backend and flex 4 for front end.
I would like to pass a string form backend to front end, so i write the following code in the main.py:</p>
<pre><code>class MainPage(webapp.RequestHandler):
def get(self):
userVO = "test"
template_values = {
'url':... | 0 | 2010-02-22T15:13:49Z | 2,330,667 | <p>What's in your index.html?
You can pass the values to index.html, set a javascript function like:</p>
<pre><code>function passvalue {
PassParameter("userVO", "{{userVO}}");
}
</code></pre>
<p>Then set a function in Flex:</p>
<pre><code>public function gethtmlparam(name:String, val:String):void {
s... | 1 | 2010-02-25T00:09:10Z | [
"python",
"flex",
"google-app-engine",
"swfobject"
] |
How to pass data from Google App Engine(Python) to Flex 4 application | 2,311,796 | <p>I am using python and webapp framework in app engine for backend and flex 4 for front end.
I would like to pass a string form backend to front end, so i write the following code in the main.py:</p>
<pre><code>class MainPage(webapp.RequestHandler):
def get(self):
userVO = "test"
template_values = {
'url':... | 0 | 2010-02-22T15:13:49Z | 2,343,029 | <p>Based on your comment to James Ward's response, I wonder if you can accomplish what you need with a FlashVars param element?</p>
<p><a href="http://livedocs.adobe.com/flex/3/html/help.html?content=passingarguments_3.html" rel="nofollow">http://livedocs.adobe.com/flex/3/html/help.html?content=passingarguments_3.html... | 1 | 2010-02-26T16:20:31Z | [
"python",
"flex",
"google-app-engine",
"swfobject"
] |
python twisted stdio multiple connections to a server with a command prompt for interaction | 2,311,844 | <p>I have written a simple twisted application that connects to a server that listens on 1 or more ports. The twisted app connects to this server and usually connects to a few of the open ports at a time. This server is a serial logger that connects to serial devices and provides the serial line information through a ... | 2 | 2010-02-22T15:19:56Z | 2,311,997 | <p>To add an interactive console to your Twisted app, see <a href="http://www.oluyede.org/blog/2008/08/31/twisted-interactive-console/" rel="nofollow">this article</a> -- it explains how to use <a href="http://twistedmatrix.com/documents/current/api/twisted.internet.stdio.html" rel="nofollow">twisted.internet.stdio</a>... | 2 | 2010-02-22T15:42:20Z | [
"python",
"user-interface",
"twisted",
"stdio"
] |
python string interpolation | 2,311,906 | <p>What could generate the following behavior ?</p>
<pre><code>>>> print str(msg)
my message
>>> print unicode(msg)
my message
</code></pre>
<p>But:</p>
<pre><code>>>> print '%s' % msg
another message
</code></pre>
<p>More info: </p>
<ul>
<li>my <code>msg</code> object is inherited from ... | 13 | 2010-02-22T15:29:26Z | 2,312,243 | <p><em>Update 2:</em> Please find the original answer, including a simple example of a class exhibiting the behaviour described by the OP, below the horizontal bar. As for what I was able to surmise in the course of my inquiry into Python's sources (v. 2.6.4):</p>
<p>The file <code>Include/unicodeobject.h</code> conta... | 8 | 2010-02-22T16:17:07Z | [
"python",
"string",
"string-interpolation"
] |
python string interpolation | 2,311,906 | <p>What could generate the following behavior ?</p>
<pre><code>>>> print str(msg)
my message
>>> print unicode(msg)
my message
</code></pre>
<p>But:</p>
<pre><code>>>> print '%s' % msg
another message
</code></pre>
<p>More info: </p>
<ul>
<li>my <code>msg</code> object is inherited from ... | 13 | 2010-02-22T15:29:26Z | 2,312,291 | <p>So problem is class like to something below behaves weirdly</p>
<pre><code>class Msg(unicode):
def __init__(self, s):
unicode.__init__(self, s)
__unicode__ = __repr__ = __str__ = lambda self: "my message"
msg = Msg("another message")
print str(msg)
print unicode(msg)
print "%s"%msg
</code></pre>
... | 6 | 2010-02-22T16:21:22Z | [
"python",
"string",
"string-interpolation"
] |
python string interpolation | 2,311,906 | <p>What could generate the following behavior ?</p>
<pre><code>>>> print str(msg)
my message
>>> print unicode(msg)
my message
</code></pre>
<p>But:</p>
<pre><code>>>> print '%s' % msg
another message
</code></pre>
<p>More info: </p>
<ul>
<li>my <code>msg</code> object is inherited from ... | 13 | 2010-02-22T15:29:26Z | 2,312,469 | <p>I think your problem is that you are trying to extend a built-in. Magic <code>__</code> methods don't get called for builtins. I think you will have to do some kind of wrap-and-delegate, like this (untested) (maybe Anurag beat me to the punch):</p>
<pre><code>class Message(object):
def __init__(self, strval... | 3 | 2010-02-22T16:45:24Z | [
"python",
"string",
"string-interpolation"
] |
Segmentation fault when importing pylab in a python script | 2,311,941 | <p>I have installed Ubuntu 8.10. I am using python 2.6.4. I have installed the following packages</p>
<p>networkx 1.0rc1
matplotlib 0.99.1.2
scipy 0.7.1
numpy 1.3</p>
<p>when I write the following statement in my code </p>
<pre><code>import pylab
</code></pre>
<p>Also this statement gives a segmentation fault</p>
... | 3 | 2010-02-22T15:27:42Z | 2,313,418 | <p>try running python through gdb. The top frame of the stacktrace is the (assumed) origin of the segmentation fault. This should give you a rough idea what to write in a bug report. If all of the above packages are from the ubuntu repositories, there should be a good chance that someone in the ubuntu community has an ... | 1 | 2010-02-22T19:11:58Z | [
"python"
] |
Python ( or general programming ). Why use <> instead of != and are there risks? | 2,312,169 | <p>I think if I understand correctly, <code>a <> b</code> is the exact same thing functionally as <code>a != b</code>, and in Python <code>not a == b</code>, but is there reason to use <code><></code> over the other versions? I know a common mistake for Python newcomers is to think that <code>not a is b</co... | 5 | 2010-02-22T16:06:40Z | 2,312,202 | <p><code><></code> in Python 2 is an exact synonym for <code>!=</code> -- no reason to use it, no disadvantages either except the gratuitous heterogeneity (a style issue). It's been long discouraged, and has now been removed in Python 3.</p>
| 15 | 2010-02-22T16:10:47Z | [
"python",
"operators"
] |
Python ( or general programming ). Why use <> instead of != and are there risks? | 2,312,169 | <p>I think if I understand correctly, <code>a <> b</code> is the exact same thing functionally as <code>a != b</code>, and in Python <code>not a == b</code>, but is there reason to use <code><></code> over the other versions? I know a common mistake for Python newcomers is to think that <code>not a is b</co... | 5 | 2010-02-22T16:06:40Z | 2,312,204 | <p>you shouldn't use <code><></code> in python.</p>
| 0 | 2010-02-22T16:11:00Z | [
"python",
"operators"
] |
Python ( or general programming ). Why use <> instead of != and are there risks? | 2,312,169 | <p>I think if I understand correctly, <code>a <> b</code> is the exact same thing functionally as <code>a != b</code>, and in Python <code>not a == b</code>, but is there reason to use <code><></code> over the other versions? I know a common mistake for Python newcomers is to think that <code>not a is b</co... | 5 | 2010-02-22T16:06:40Z | 2,312,600 | <p>Just a pedantic note: the <code><></code> operator is in some sense misnamed (misdenoted?). <code>a <> b</code> might naturally be interpreted as meaning <code>a < b or a > b</code> (evaluating <code>a</code> and <code>b</code> only once, of course), but since not all orderings are total ordering... | 8 | 2010-02-22T17:06:42Z | [
"python",
"operators"
] |
Window Icon of Exe in PyQt4 | 2,312,210 | <p>I have a small program in PyQt4 and I want to compile the program into an Exe. I am using py2exe to do that. I can successfully set icon in the windows title bar using the following code, but when i compile it into exe the icon is lost and i see the default windows application. here is my program:</p>
<pre><code>im... | 9 | 2010-02-22T16:11:53Z | 2,312,580 | <p>I believe you need to reference the <code>.ico</code> file directly from the EXE or DLL that you are creating with <code>py2exe</code>. You seem to have the setup.py script correct, so take a look at: <a href="http://www.py2exe.org/index.cgi/CustomIcons" rel="nofollow">http://www.py2exe.org/index.cgi/CustomIcons</a... | 4 | 2010-02-22T17:03:07Z | [
"python",
"windows",
"qt",
"qt4",
"py2exe"
] |
Window Icon of Exe in PyQt4 | 2,312,210 | <p>I have a small program in PyQt4 and I want to compile the program into an Exe. I am using py2exe to do that. I can successfully set icon in the windows title bar using the following code, but when i compile it into exe the icon is lost and i see the default windows application. here is my program:</p>
<pre><code>im... | 9 | 2010-02-22T16:11:53Z | 2,318,178 | <p>I would suggest you to create a file called YourApp.rc, add up the following line :</p>
<pre><code>IDI_ICON1 ICON DISCARDABLE "res/icons/app_icon.ico"
</code></pre>
<p>Then in your .PRO file, add up the following lines :</p>
<pre><code>win32{
RC_FILE = YourApp.rc
}
</code></pre>
<p>It should fix your proble... | 0 | 2010-02-23T12:49:19Z | [
"python",
"windows",
"qt",
"qt4",
"py2exe"
] |
Window Icon of Exe in PyQt4 | 2,312,210 | <p>I have a small program in PyQt4 and I want to compile the program into an Exe. I am using py2exe to do that. I can successfully set icon in the windows title bar using the following code, but when i compile it into exe the icon is lost and i see the default windows application. here is my program:</p>
<pre><code>im... | 9 | 2010-02-22T16:11:53Z | 5,424,782 | <p>The problem is that py2exe doesn't include the qt icon reader plugin. You need to tell it to include it with the data_files parameter. Something along these lines:</p>
<pre><code>setup(windows=[{"script":script_path,
"icon_resources":[(1, icon_path)]}],
data_files = [
('imagefor... | 14 | 2011-03-24T19:57:43Z | [
"python",
"windows",
"qt",
"qt4",
"py2exe"
] |
Python Virtualbox API | 2,312,254 | <p><a href="http://enomalism.com/api/pyvb/" rel="nofollow">http://enomalism.com/api/pyvb/</a></p>
<p>here we have <code>def _init_(self,**kw):</code></p>
<p>what parameter(s) should be passed when we create an instance for pyvb.vm.vbVM ???</p>
| 0 | 2010-02-22T16:18:40Z | 2,312,290 | <p>Looks like you want to pass in an array of configuration items. See the <a href="http://enomalism.com/api/pyvb/pyvb.vm-pysrc.html#vbVM.__init__" rel="nofollow">source code</a>.</p>
| 0 | 2010-02-22T16:21:16Z | [
"python",
"virtualbox"
] |
Python Virtualbox API | 2,312,254 | <p><a href="http://enomalism.com/api/pyvb/" rel="nofollow">http://enomalism.com/api/pyvb/</a></p>
<p>here we have <code>def _init_(self,**kw):</code></p>
<p>what parameter(s) should be passed when we create an instance for pyvb.vm.vbVM ???</p>
| 0 | 2010-02-22T16:18:40Z | 2,317,221 | <p>What you are seeing is "keyword arguments". You can call the constructor with a dictionary or named arguments. Here is an example of using keyword arguments:</p>
<pre>
class MyClass(object):
def __init__(self,**kwargs):
if 'val' in kwargs:
self.__value = kwargs['val'];
elif 'value' in kw... | 1 | 2010-02-23T10:11:26Z | [
"python",
"virtualbox"
] |
Scheduling Python Programs | 2,312,314 | <p>How would you go about a having a function check something every ten minutes?
I would like to check a directory for new files every ten minutes. I know python has a time library but can it be used for this?</p>
| 0 | 2010-02-22T16:25:01Z | 2,312,327 | <p><a href="http://docs.python.org/library/time.html#time.sleep" rel="nofollow"><code>time.sleep</code></a>:</p>
<pre><code>time.sleep(10*60)
</code></pre>
<p>you might want to look into <code>cron</code> or Scheduled Tasks services of the OS.</p>
| 0 | 2010-02-22T16:25:53Z | [
"python",
"time",
"python-3.x"
] |
Scheduling Python Programs | 2,312,314 | <p>How would you go about a having a function check something every ten minutes?
I would like to check a directory for new files every ten minutes. I know python has a time library but can it be used for this?</p>
| 0 | 2010-02-22T16:25:01Z | 2,312,348 | <p>The <a href="http://docs.python.org/3.1/library/sched.html#module-sched" rel="nofollow">sched</a> module is worth a look.</p>
| 1 | 2010-02-22T16:29:43Z | [
"python",
"time",
"python-3.x"
] |
Scheduling Python Programs | 2,312,314 | <p>How would you go about a having a function check something every ten minutes?
I would like to check a directory for new files every ten minutes. I know python has a time library but can it be used for this?</p>
| 0 | 2010-02-22T16:25:01Z | 2,312,424 | <p>for checking of files, you may want to try <a href="http://pyinotify.sourceforge.net/" rel="nofollow">pyinotify</a></p>
| 0 | 2010-02-22T16:40:00Z | [
"python",
"time",
"python-3.x"
] |
Different 404 pages depending on the application in Django | 2,312,407 | <p>We are developing a project with several applications using Django. It shares the database, but it has several applications targeting different very different users. Roughly, administrators and final users. The UI of each application is very different.
I need to create a 404 error page, but seems that I can only cr... | 4 | 2010-02-22T16:37:29Z | 2,312,566 | <p>It's not at all true that you can only create a single 404 page for the entire app. <a href="https://docs.djangoproject.com/en/1.8/ref/views/#the-404-page-not-found-view" rel="nofollow">The documentation</a> explains how you can create a specific 404 handler view, which of course can look at the value of <code>reque... | 3 | 2010-02-22T17:00:47Z | [
"python",
"django"
] |
Different 404 pages depending on the application in Django | 2,312,407 | <p>We are developing a project with several applications using Django. It shares the database, but it has several applications targeting different very different users. Roughly, administrators and final users. The UI of each application is very different.
I need to create a 404 error page, but seems that I can only cr... | 4 | 2010-02-22T16:37:29Z | 2,312,573 | <p><a href="http://docs.djangoproject.com/en/dev/intro/tutorial03/#write-a-404-page-not-found-view" rel="nofollow">Write a 404 view</a> by setting <code>handler404</code>, and not just a template. In that view, try to figure from the url which 404 you should show, and render that.</p>
| 3 | 2010-02-22T17:01:48Z | [
"python",
"django"
] |
Does PIL create artifacting on the bottom edge of the image when you thumbnail() then crop()? If so, what is your workaround? | 2,312,438 | <p>When I call PIL to thumbnail() an image, and then crop(), I get artifacting on the last row of pixels -- they're either mostly black with specks of intense color, or what seems to be a not-resized area of the image ( ie, that line of pixels is at the original resolution and did not scale down with the rest )</p>
<p... | 3 | 2010-02-22T16:42:01Z | 2,314,563 | <p>Yes, this happens to me also. This was a learning exercise for me because I have never cropped or created thumbnails using the PIL...</p>
<h2>thumbnail(size,filter=None)</h2>
<p>Replaces the original image, in place, with a new image of the given size (p. 2). The optional
filter argument works in the same way as ... | 2 | 2010-02-22T21:58:46Z | [
"python",
"python-imaging-library",
"imaging"
] |
web2py, OAuth and LinkedIn | 2,312,464 | <p>I am new to Python and Web2py and I am developing an app that will use the LinkedIn API.</p>
<p>I use this library <a href="http://code.google.com/p/python-linkedin/" rel="nofollow">http://code.google.com/p/python-linkedin/</a> (it includes OAuth). My problem is very strange and that's why I am writing to the list.... | 2 | 2010-02-22T16:44:41Z | 2,316,173 | <p>You mentioned that in both cases it is quite simple... it leaves me to wonder.</p>
<p>Is it the exact same code in both cases?</p>
| 0 | 2010-02-23T04:49:41Z | [
"python",
"oauth",
"linkedin",
"web2py"
] |
web2py, OAuth and LinkedIn | 2,312,464 | <p>I am new to Python and Web2py and I am developing an app that will use the LinkedIn API.</p>
<p>I use this library <a href="http://code.google.com/p/python-linkedin/" rel="nofollow">http://code.google.com/p/python-linkedin/</a> (it includes OAuth). My problem is very strange and that's why I am writing to the list.... | 2 | 2010-02-22T16:44:41Z | 2,340,758 | <p>I just tried and it works but:
1) make sure you run this on the same hostname that you registered with linkedin
2) pass a full RETURN_URL, not a relative URL as returned by URL</p>
<pre><code>def index():
import linkedin
from linkedin import linkedin
RETURN_URL = "http://web2py.com/linkedin/default/hello"
a... | 1 | 2010-02-26T10:03:31Z | [
"python",
"oauth",
"linkedin",
"web2py"
] |
How to improve performance when interpolating on 3d data with SciPy | 2,312,665 | <p>I have 3d-data representing the atmosphere. Now I want to interpolate this data to a common Z coordinate (what I mean by that should be clear from the function's doctring). The following code works fine, but I was wondering if there were a way to improve the performance ...</p>
<pre><code>def interpLevel(grid,value... | 3 | 2010-02-22T17:16:49Z | 2,313,975 | <p>Well, this might give a small speed-up just because it uses less memory.</p>
<pre><code>ret = np.zeros_like(data[0,:,:])
for latIdx in xrange(grid.shape[1]):
for lonIdx in xrange(grid.shape[2]):
# check if we need to flip the column
if grid[0,latIdx,lonIdx] > grid[-1,latIdx,lonIdx]:
... | 2 | 2010-02-22T20:37:05Z | [
"python",
"numpy",
"scipy",
"interpolation"
] |
Can the Django dev server correctly serve SVG? | 2,312,714 | <p>I am trying to serve a svg map using:</p>
<pre><code><object data="map.svg" type="image/svg+xml" width="400" height="300">
<embed src="map.svg" type="image/svg+xml" width="400" height="300" />
</object>
</code></pre>
<p>In Firefox this leads to a plugin prompt. If I rename map.<strong>svg</st... | 15 | 2010-02-22T17:24:16Z | 2,312,866 | <p>If you're serving the SVG dynamically from a regular django view, you can specify the mimetype in the <a href="http://docs.djangoproject.com/en/1.1/ref/request-response/#httpresponse-objects">HTTPResponse</a> object you return from that view. In this case, you'll want the mimetype in place for both dev and productio... | 6 | 2010-02-22T17:47:07Z | [
"python",
"django",
"svg"
] |
Can the Django dev server correctly serve SVG? | 2,312,714 | <p>I am trying to serve a svg map using:</p>
<pre><code><object data="map.svg" type="image/svg+xml" width="400" height="300">
<embed src="map.svg" type="image/svg+xml" width="400" height="300" />
</object>
</code></pre>
<p>In Firefox this leads to a plugin prompt. If I rename map.<strong>svg</st... | 15 | 2010-02-22T17:24:16Z | 2,313,050 | <p>I don't have Django available to test this at the moment but it looks like the static server uses the <a href="http://docs.python.org/dev/library/mimetypes.html">mimetypes library</a> to determine the content type (specifically guess_type()).</p>
<p>With a little bit a Googling, I came across <a href="http://moinmo... | 37 | 2010-02-22T18:17:00Z | [
"python",
"django",
"svg"
] |
Controlling VirtualBox from commandline with python | 2,313,010 | <p>We are using python virtualbox API for controlling the virtualbox. For that we are using the "pyvb" package(as given in python API documentation).</p>
<pre><code>al=pyvb.vb.VB()
m=pyvb.vm.vbVM()
al.startVM(m)
</code></pre>
<p>we have executed using the python interpreter. No error is shown but the virtualbox doesn... | 0 | 2010-02-22T18:10:15Z | 2,313,087 | <p>The code quoted doesn't seem to specify what VM to run. Shouldn't you be doing a <a href="http://enomalism.com/api/pyvb/pyvb.vb.VB-class.html#getVM" rel="nofollow"><code>getVM</code></a> call and then using that resulting VM instance in your <code>startVM</code> call? E.g.:</p>
<pre><code>al=pyvb.vb.VB()
m=al.getVM... | 0 | 2010-02-22T18:22:07Z | [
"python",
"virtualbox"
] |
Controlling VirtualBox from commandline with python | 2,313,010 | <p>We are using python virtualbox API for controlling the virtualbox. For that we are using the "pyvb" package(as given in python API documentation).</p>
<pre><code>al=pyvb.vb.VB()
m=pyvb.vm.vbVM()
al.startVM(m)
</code></pre>
<p>we have executed using the python interpreter. No error is shown but the virtualbox doesn... | 0 | 2010-02-22T18:10:15Z | 2,313,384 | <p>I found that I can use the following functions to find if a VM is running, restore a VM to a specific snapshot, and start a VM by name.</p>
<pre><code>from subprocess import Popen, PIPE
def running_vms():
"""
Return list of running vms
"""
f = Popen(r'vboxmanage --nologo list ru... | 3 | 2010-02-22T19:05:25Z | [
"python",
"virtualbox"
] |
Programming language decision for C++ legacy project workflow | 2,313,017 | <p>I have quite a lot of C++ legacy code modules from my colleagues, each doing different jobs. Unfortunately they are poorly written and yes, all GNU C++ code running under Linux. </p>
<p>I want to write a controller program to make singular C++ module a workflow for a very urgent demo. Also I need to write a front-e... | 2 | 2010-02-22T18:11:57Z | 2,313,159 | <p>Noting the "very urgent demo" part, assuming that that would take about a month, depending on the complexity, I'd stick to the familiar.
True, maintaining python would be easier in the end, and learning python should be a breeze, if you deem it viable.</p>
<p>I'd say, have the team learn python and do the basic stu... | 3 | 2010-02-22T18:30:24Z | [
"java",
"python",
"programming-languages",
"binding",
"jni"
] |
Programming language decision for C++ legacy project workflow | 2,313,017 | <p>I have quite a lot of C++ legacy code modules from my colleagues, each doing different jobs. Unfortunately they are poorly written and yes, all GNU C++ code running under Linux. </p>
<p>I want to write a controller program to make singular C++ module a workflow for a very urgent demo. Also I need to write a front-e... | 2 | 2010-02-22T18:11:57Z | 2,313,266 | <p>I would use Python. You could write very basic wrappers using the Python C API and then call said functions from Python with relative ease.</p>
| 0 | 2010-02-22T18:46:59Z | [
"java",
"python",
"programming-languages",
"binding",
"jni"
] |
Programming language decision for C++ legacy project workflow | 2,313,017 | <p>I have quite a lot of C++ legacy code modules from my colleagues, each doing different jobs. Unfortunately they are poorly written and yes, all GNU C++ code running under Linux. </p>
<p>I want to write a controller program to make singular C++ module a workflow for a very urgent demo. Also I need to write a front-e... | 2 | 2010-02-22T18:11:57Z | 2,313,312 | <p>Given the urgency, I'd have to stick with C++.</p>
<p>Without that, I'd say keep what you got, but feel free to switch to a preferred language when refactoring. That would be the time to do it. </p>
<p>What you should <strong>not</strong> do, ever, is "port" anything to another language without rewriting or changi... | 1 | 2010-02-22T18:54:58Z | [
"java",
"python",
"programming-languages",
"binding",
"jni"
] |
regex for state abbreviations (python) | 2,313,032 | <p>I am trying to create a regex that matches a US state abbreviations in a string using python. </p>
<p>The abbreviation can be in the format:</p>
<pre><code>CA
Ca
</code></pre>
<p>The string could be:</p>
<pre><code>Boulder, CO 80303
Boulder, Co
Boulder CO
...
</code></pre>
<p>Here is what I have, which obviousl... | 3 | 2010-02-22T18:13:28Z | 2,313,043 | <pre><code>re.search(r'\b[a-z]{2}\b', subject, re.I)
</code></pre>
<p>it will find double-letter names of towns, though</p>
| 1 | 2010-02-22T18:15:31Z | [
"python",
"regex"
] |
regex for state abbreviations (python) | 2,313,032 | <p>I am trying to create a regex that matches a US state abbreviations in a string using python. </p>
<p>The abbreviation can be in the format:</p>
<pre><code>CA
Ca
</code></pre>
<p>The string could be:</p>
<pre><code>Boulder, CO 80303
Boulder, Co
Boulder CO
...
</code></pre>
<p>Here is what I have, which obviousl... | 3 | 2010-02-22T18:13:28Z | 2,313,098 | <p>A simple and reliable way is to have all the states listed:</p>
<pre><code>states = ['IA', 'KS', 'UT', 'VA', 'NC', 'NE', 'SD', 'AL', 'ID', 'FM', 'DE', 'AK', 'CT', 'PR', 'NM', 'MS', 'PW', 'CO', 'NJ', 'FL', 'MN', 'VI', 'NV', 'AZ', 'WI', 'ND', 'PA', 'OK', 'KY', 'RI', 'NH', 'MO', 'ME', 'VT', 'GA', 'GU', 'AS', 'NY', 'CA... | 7 | 2010-02-22T18:23:16Z | [
"python",
"regex"
] |
Python: How to Access Linux Paths | 2,313,053 | <p>Using Python, how does one parse/access files with Linux-specific features, like <code>"~/.mozilla/firefox/*.default"</code>? I've tried this, but it doesn't work.</p>
<p>Thanks</p>
| 2 | 2010-02-22T18:17:39Z | 2,313,101 | <p><code>~</code> is expanded by the shell and not a real path. As such you have to navigate there manually.</p>
<pre><code>import os
homeDir = os.environ['HOME']
f = open( homeDir + '/.mozilla/firefox/*.default' )
# ...
</code></pre>
| 2 | 2010-02-22T18:23:24Z | [
"python",
"linux",
"path"
] |
Python: How to Access Linux Paths | 2,313,053 | <p>Using Python, how does one parse/access files with Linux-specific features, like <code>"~/.mozilla/firefox/*.default"</code>? I've tried this, but it doesn't work.</p>
<p>Thanks</p>
| 2 | 2010-02-22T18:17:39Z | 2,313,118 | <p><a href="http://docs.python.org/library/os.html" rel="nofollow">http://docs.python.org/library/os.html</a>
Gives a complete reference if you would like to change directory or give paths.</p>
<p>You can for example give relative paths and access specific files.</p>
<p>If you would like to execute commands then <a h... | 1 | 2010-02-22T18:24:47Z | [
"python",
"linux",
"path"
] |
Python: How to Access Linux Paths | 2,313,053 | <p>Using Python, how does one parse/access files with Linux-specific features, like <code>"~/.mozilla/firefox/*.default"</code>? I've tried this, but it doesn't work.</p>
<p>Thanks</p>
| 2 | 2010-02-22T18:17:39Z | 2,313,119 | <p>This</p>
<pre><code>import glob, os
glob.glob(os.path.expanduser('~/.mozilla/firefox/*.default'))
</code></pre>
<p>will give you a list of all files ending in ".default" in the current user's <code>~/.mozilla/firefox</code> directory using <a href="http://docs.python.org/library/os.path.html#os.path.expanduser">os... | 7 | 2010-02-22T18:24:55Z | [
"python",
"linux",
"path"
] |
Python: How to Access Linux Paths | 2,313,053 | <p>Using Python, how does one parse/access files with Linux-specific features, like <code>"~/.mozilla/firefox/*.default"</code>? I've tried this, but it doesn't work.</p>
<p>Thanks</p>
| 2 | 2010-02-22T18:17:39Z | 2,313,168 | <p>It's important to remember:</p>
<ul>
<li>use of the tilde <code>~</code> expands the home directory as per Poke's answer</li>
<li>use of the forward slash <code>/</code> is the separator for linux / *nix directories</li>
<li>by default, *nix systems such as linux for example has a wild card globbing in the shell, f... | 1 | 2010-02-22T18:32:24Z | [
"python",
"linux",
"path"
] |
Default value in a function in Python | 2,313,075 | <p>I am noticing the following:</p>
<pre><code>class c:
def __init__(self, data=[]):
self._data=data
a=c()
b=c()
a._data.append(1)
print b._data
[1]
</code></pre>
<p>Is this the correct behavior?</p>
| 7 | 2010-02-22T18:20:03Z | 2,313,105 | <p>Yes, it's correct behavior.</p>
<p>However, from your question, it appears that it's not what you expected.</p>
<p>If you want it to match your expectations, be aware of the following:</p>
<p>Rule 1. Do not use mutable objects as default values.</p>
<pre><code>def anyFunction( arg=[] ):
</code></pre>
<p>Will n... | 10 | 2010-02-22T18:23:36Z | [
"python",
"default-value"
] |
Default value in a function in Python | 2,313,075 | <p>I am noticing the following:</p>
<pre><code>class c:
def __init__(self, data=[]):
self._data=data
a=c()
b=c()
a._data.append(1)
print b._data
[1]
</code></pre>
<p>Is this the correct behavior?</p>
| 7 | 2010-02-22T18:20:03Z | 2,313,113 | <p>This is a classic pitfall. See <a href="http://zephyrfalcon.org/labs/python_pitfalls.html" rel="nofollow">http://zephyrfalcon.org/labs/python_pitfalls.html</a>, section 5: "Mutable default arguments"</p>
| 4 | 2010-02-22T18:24:05Z | [
"python",
"default-value"
] |
Default value in a function in Python | 2,313,075 | <p>I am noticing the following:</p>
<pre><code>class c:
def __init__(self, data=[]):
self._data=data
a=c()
b=c()
a._data.append(1)
print b._data
[1]
</code></pre>
<p>Is this the correct behavior?</p>
| 7 | 2010-02-22T18:20:03Z | 2,313,178 | <p>Always make functions like this then:</p>
<pre><code>def __init__ ( self, data = None ):
if data is None:
data = []
self._data = data
</code></pre>
<p>Alternatively you could also use <code>data = data or []</code>, but that prevents the user from passing <em>empty</em> parameters (<code>''</code>,... | 1 | 2010-02-22T18:34:47Z | [
"python",
"default-value"
] |
Conversion from imperative to functional programming [Python to Standard ML] | 2,313,141 | <p>I have a function specification that states it that should evaluate a polynomial function of one variable. The coefficient of the function is given as a list. It also accepts the value of the variable as a real. </p>
<p>For example: eval(2, [4, 3, 2, 1]) = 26 (1*x^3 + 2*x^2 + 3*x^1 + 4*x^0, where x = 2)</p>
<p>H... | 3 | 2010-02-22T18:27:50Z | 2,313,309 | <p>The usual way to express sums in functional languages is a fold. You can get rid of the need for an index (and a function to raise an int to the power of another int) by multiplying the sum with r in each iteration:</p>
<pre><code>fun eval radix lst = let
fun f (element, sum) = sum * radix + element
in
foldr f ... | 4 | 2010-02-22T18:54:28Z | [
"python",
"recursion",
"parameters",
"functional-programming",
"sml"
] |
Conversion from imperative to functional programming [Python to Standard ML] | 2,313,141 | <p>I have a function specification that states it that should evaluate a polynomial function of one variable. The coefficient of the function is given as a list. It also accepts the value of the variable as a real. </p>
<p>For example: eval(2, [4, 3, 2, 1]) = 26 (1*x^3 + 2*x^2 + 3*x^1 + 4*x^0, where x = 2)</p>
<p>H... | 3 | 2010-02-22T18:27:50Z | 2,313,490 | <p>You can use explicit recursion to walk through the list of coefficients, exponentiate the radix, and sum up the total.</p>
<pre><code>fun eval r =
let fun step (power, sum) (coeff :: rest) =
step (power * r, sum + coeff * power) rest
| step (_, sum) nil = sum
in step (1, 0)
end... | 1 | 2010-02-22T19:22:30Z | [
"python",
"recursion",
"parameters",
"functional-programming",
"sml"
] |
Python: Access a MySQL db without MySQLdb module | 2,313,307 | <p>Is there another way to connect to a MySQL database with what came included in the version of Python (2.5.1) that is bundled with Mac OS 10.5.x? I unfortunately cannot add the the MySQLdb module to the client machines I am working with...I need to work with the stock version of Python that shipped with Leopard. </p... | 2 | 2010-02-22T18:54:20Z | 2,313,495 | <p>Why not install a user (non-system) copy of MySQLdb?
These are <a href="http://sourceforge.net/projects/mysql-python/files/">the files</a> you'd need to install:</p>
<pre><code>/usr/lib/pyshared/python2.6
/usr/lib/pyshared/python2.6/_mysql.so
/usr/share/pyshared
/usr/share/pyshared/MySQLdb
/usr/share/pyshared/MySQL... | 8 | 2010-02-22T19:23:02Z | [
"python",
"mysql",
"osx"
] |
Python: Access a MySQL db without MySQLdb module | 2,313,307 | <p>Is there another way to connect to a MySQL database with what came included in the version of Python (2.5.1) that is bundled with Mac OS 10.5.x? I unfortunately cannot add the the MySQLdb module to the client machines I am working with...I need to work with the stock version of Python that shipped with Leopard. </p... | 2 | 2010-02-22T18:54:20Z | 2,314,215 | <p>You can simplify parsing the data returned by a command line batch call on mysql by using os.popen() rather than subprocess.call(), and modifying the query in the command.</p>
<ul>
<li>Dropping the command into os.popen(cmd).readlines() get the output as a list of returned lines, with records separated by a tab cha... | 0 | 2010-02-22T21:10:21Z | [
"python",
"mysql",
"osx"
] |
Python: Access a MySQL db without MySQLdb module | 2,313,307 | <p>Is there another way to connect to a MySQL database with what came included in the version of Python (2.5.1) that is bundled with Mac OS 10.5.x? I unfortunately cannot add the the MySQLdb module to the client machines I am working with...I need to work with the stock version of Python that shipped with Leopard. </p... | 2 | 2010-02-22T18:54:20Z | 2,335,177 | <p>Or you could check out <a href="http://launchpad.net/myconnpy" rel="nofollow">MySQL Connector/Python</a>. It's still in development, but should work with Python 2.5. No MySQL libraries or other software needed.</p>
| 2 | 2010-02-25T15:28:18Z | [
"python",
"mysql",
"osx"
] |
Python: Access a MySQL db without MySQLdb module | 2,313,307 | <p>Is there another way to connect to a MySQL database with what came included in the version of Python (2.5.1) that is bundled with Mac OS 10.5.x? I unfortunately cannot add the the MySQLdb module to the client machines I am working with...I need to work with the stock version of Python that shipped with Leopard. </p... | 2 | 2010-02-22T18:54:20Z | 9,170,459 | <p>If the problem is the inability, as so many people have mentioned, that the msqldb module is a problem a simpler way is
1. install the mysql db
2. install the pyodbc module
3. Load and configure the odbc mysql driver
4. perform sql manipulations with pyodbc, which is very mature and full functional.</p>
<p>hope thi... | 1 | 2012-02-07T03:03:25Z | [
"python",
"mysql",
"osx"
] |
Google apps login in django | 2,313,573 | <p>I'm developing a django app that integrates with google apps. I'd like to let the users login with their google apps accounts (accounts in google hosted domains, <i>not google accounts</i>) so they can access their docs, calendar, and whatnot.</p>
<p>In order to do it, I downloaded and started using django_openid_a... | 10 | 2010-02-22T19:37:51Z | 2,575,075 | <p>According to <a href="http://groups.google.com/group/google-federated-login-api/web/openid-discovery-for-hosted-domains">http://groups.google.com/group/google-federated-login-api/web/openid-discovery-for-hosted-domains</a>, Google changed the way of IdP Discovery and user XRDS check a little bit to give Google Apps ... | 8 | 2010-04-04T16:33:40Z | [
"python",
"django",
"google-apps",
"django-openid-auth"
] |
Google apps login in django | 2,313,573 | <p>I'm developing a django app that integrates with google apps. I'd like to let the users login with their google apps accounts (accounts in google hosted domains, <i>not google accounts</i>) so they can access their docs, calendar, and whatnot.</p>
<p>In order to do it, I downloaded and started using django_openid_a... | 10 | 2010-02-22T19:37:51Z | 8,438,800 | <p>I think you can give a try <a href="http://github.com/hudora/django-googleappsauth" rel="nofollow">http://github.com/hudora/django-googleappsauth</a>
but I found some bugs <a href="https://github.com/simul14/django-googleappsauth" rel="nofollow">trying to fix them and translating comments</a></p>
| 1 | 2011-12-08T22:47:28Z | [
"python",
"django",
"google-apps",
"django-openid-auth"
] |
Genshi TemplateSyntaxError on python block where it should work | 2,313,590 | <pre><code><?python class += 1 ?>
</code></pre>
<p>One really simple line of code which definitely should work, but still it gives me this error:</p>
<pre><code>TemplateSyntaxError: invalid syntax (file.html, line 22)
</code></pre>
<p>I shorted the filepath for readability, but that's the exact error. I'm defi... | 0 | 2010-02-22T19:40:50Z | 2,313,653 | <p><code>class</code> is a Python keyword. You can't name a variable that.</p>
| 1 | 2010-02-22T19:48:50Z | [
"python",
"syntax-error",
"codeblocks",
"genshi"
] |
How does this decorator make a call to the 'register' method? | 2,313,666 | <p>I'm trying to understand what is going on in the decorator @not_authenticated.
The next step in the TraceRoute is to the method '<strong>register</strong>' which is also located in django_authopenid/views.py which I just don't understand because I don't see anywhere that register is even mentioned in signin()</p>
... | 2 | 2010-02-22T19:50:31Z | 2,314,691 | <p>Without attempting to understand all of that why don't you insert:</p>
<pre><code>import pdb; pdb.set_trace()
</code></pre>
<p>wherever this "register" method is?</p>
<p>Than hit "bt"</p>
| 0 | 2010-02-22T22:16:04Z | [
"python",
"django",
"decorator"
] |
How does this decorator make a call to the 'register' method? | 2,313,666 | <p>I'm trying to understand what is going on in the decorator @not_authenticated.
The next step in the TraceRoute is to the method '<strong>register</strong>' which is also located in django_authopenid/views.py which I just don't understand because I don't see anywhere that register is even mentioned in signin()</p>
... | 2 | 2010-02-22T19:50:31Z | 2,357,095 | <p>Are you sure the call gets into signin()?</p>
<p>Because if the user is already authenticated (request.user.is_authenticated()) , the openid code is called directly, and signin() redirects anyway..</p>
<p>You have this inside httpreferrer:</p>
<p><code>
'HTTP_REFERER': 'http://workproject.com/account/signin/compl... | 0 | 2010-03-01T16:02:32Z | [
"python",
"django",
"decorator"
] |
How does this decorator make a call to the 'register' method? | 2,313,666 | <p>I'm trying to understand what is going on in the decorator @not_authenticated.
The next step in the TraceRoute is to the method '<strong>register</strong>' which is also located in django_authopenid/views.py which I just don't understand because I don't see anywhere that register is even mentioned in signin()</p>
... | 2 | 2010-02-22T19:50:31Z | 2,428,000 | <p>After looking through django_authopenid/views.py , the part that appears to be calling <strong>register</strong> is this part of signin:</p>
<pre><code>return ask_openid(request,
form_signin.cleaned_data['openid_url'],
redirect_to,
on_failure=signin_fai... | 0 | 2010-03-11T19:27:33Z | [
"python",
"django",
"decorator"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.