content stringlengths 85 101k | title stringlengths 0 150 | question stringlengths 15 48k | answers list | answers_scores list | non_answers list | non_answers_scores list | tags list | name stringlengths 35 137 |
|---|---|---|---|---|---|---|---|---|
Q:
Can I override a query in DJango?
I know you can override delete and save methods in DJango models, but can you override a select query somehow to intercept and change a parameter slightly. I have a hashed value I want to check for, and would like to keep the hashing internal to the model.
A:
You don't make it ... | Can I override a query in DJango? | I know you can override delete and save methods in DJango models, but can you override a select query somehow to intercept and change a parameter slightly. I have a hashed value I want to check for, and would like to keep the hashing internal to the model.
| [
"You don't make it absolutely clear what you want to do, but I think there are two possibilities here.\nThe general way to override the database query is to define a custom Manager, and override get_query_set method. You can add extra filtering criteria here.\nHowever, if I understand your question properly, you ar... | [
3,
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0002439631_django_python.txt |
Q:
How to make socket.listen(1) work for some time and then continue rest of code?
I'm making server that make a tcp socket and work over port range, with each port it will listen on that port for some time, then continue the rest of the code.
like this::
import socket
sck = socket.socket(socket.AF_INET, socket.SOCK... | How to make socket.listen(1) work for some time and then continue rest of code? | I'm making server that make a tcp socket and work over port range, with each port it will listen on that port for some time, then continue the rest of the code.
like this::
import socket
sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sck.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
msg =''
ports = [... | [
"You can settimeout on the socket to the maximum amount of time you want to wait on it each time (call it again before every listen to the time you want to wait this time around) -- you'll get an exception, socket.timeout, if the timer expires, so be sure to have a try/except socket.timeout: around it to catch that... | [
13
] | [] | [] | [
"ports",
"python",
"sockets"
] | stackoverflow_0002444178_ports_python_sockets.txt |
Q:
how to use cherrpy built in data storage
Ok I have been reading the cherrypy documents for sometime and have not found a simple example yet. Let say I have a simple hello world site, how do I store data? Lets say I want to store a = 1, and b =2 to a dictionary using cherrypy. The config files are confusing as h... | how to use cherrpy built in data storage | Ok I have been reading the cherrypy documents for sometime and have not found a simple example yet. Let say I have a simple hello world site, how do I store data? Lets say I want to store a = 1, and b =2 to a dictionary using cherrypy. The config files are confusing as hell. Anyone have very simple example of stori... | [
"Edit your config file:\n[/]\ntools.sessions.on = True\ntools.sessions.storage_type = \"file\" # leave blank for in-memory\ntools.sessions.storage_path = \"/home/site/sessions\"\ntools.sessions.timeout = 60\n\nSetting data on a session:\ncherrypy.session['fieldname'] = 'fieldvalue'\n\nGetting data:\ncherrypy.sessio... | [
2,
1
] | [] | [] | [
"cherrypy",
"python"
] | stackoverflow_0002444270_cherrypy_python.txt |
Q:
Problem with for-loop in python
This code is supposed to be able to sort the items in self.array based upon the order of the characters in self.order. The method sort runs properly until the third iteration, unil for some reason the for loop seems to repeat indefinitely. What is going on here?
Edit: I'm making my ... | Problem with for-loop in python | This code is supposed to be able to sort the items in self.array based upon the order of the characters in self.order. The method sort runs properly until the third iteration, unil for some reason the for loop seems to repeat indefinitely. What is going on here?
Edit: I'm making my own sort function because it is a bon... | [
"During the third pass of your loop you are appending new elements to the list you are iterating over therefore you can never leave the loop:\nself.arrayt = self.leave - this assignment leads to the fact that self.leave.append(arrayi) will append elements to the list self.arrayt refers to. \nIn general you may thi... | [
1,
1,
1
] | [] | [] | [
"class",
"for_loop",
"python"
] | stackoverflow_0002444337_class_for_loop_python.txt |
Q:
Problem running python/matplotlib in background after ending ssh session
I have to VPN and then ssh from home to my work server and want to run a python script in the background, then log out of the ssh session. My script makes several histogram plots using matplotlib, and as long as I keep the connection open eve... | Problem running python/matplotlib in background after ending ssh session | I have to VPN and then ssh from home to my work server and want to run a python script in the background, then log out of the ssh session. My script makes several histogram plots using matplotlib, and as long as I keep the connection open everything is fine, but if I log out I keep getting an error message in the log f... | [
"I believe your matplotlib backend requires X11. Look in your matplotlibrc file to determine what your default is (from the error, I'm betting TkAgg). To run without X11, use the Agg backend. Either set it globally in the matplotlibrc file or on a script by script by adding this to the python program:\nimport ma... | [
25,
12,
2,
0
] | [] | [] | [
"background",
"matplotlib",
"python",
"ssh",
"tkinter"
] | stackoverflow_0002443702_background_matplotlib_python_ssh_tkinter.txt |
Q:
Dynamically expanding Django forms
I would like to create a form where a user can enter an arbitrary # of items in separate textboxes. The user could add (and potentially remove) fields as needed. Something like this:
(source: eggdrop.ch)
I found the following different solutions:
http://www.eggdrop.ch/blog/2007... | Dynamically expanding Django forms | I would like to create a form where a user can enter an arbitrary # of items in separate textboxes. The user could add (and potentially remove) fields as needed. Something like this:
(source: eggdrop.ch)
I found the following different solutions:
http://www.eggdrop.ch/blog/2007/02/15/django-dynamicforms/
http://dewfu... | [
"I know this is a new feature in the admin in Django 1.2. \nMaybe you can take a look at the way they implemented it there.\n"
] | [
2
] | [] | [] | [
"django",
"python"
] | stackoverflow_0002444656_django_python.txt |
Q:
Python 2 dict_items.sort() in Python 3
I'm porting some code from Python 2 to 3. This is valid code in Python 2 syntax:
def print_sorted_dictionary(dictionary):
items=dictionary.items()
items.sort()
In Python 3, the dict_items have no method 'sort' - how can I make a workaround for this in Python 3?
... | Python 2 dict_items.sort() in Python 3 | I'm porting some code from Python 2 to 3. This is valid code in Python 2 syntax:
def print_sorted_dictionary(dictionary):
items=dictionary.items()
items.sort()
In Python 3, the dict_items have no method 'sort' - how can I make a workaround for this in Python 3?
| [
"Use items = sorted(dictionary.items()), it works great in both Python 2 and Python 3.\n",
"dict.items returns a view instead of a list in Python 3 (somewhat similarly to the iteritems method in Python 2.x). To get a sorted list of the items use\nsorted_items = sorted(d.items())\n\nThe sorted builtin takes an ite... | [
10,
3
] | [] | [] | [
"python",
"python_3.x"
] | stackoverflow_0002444697_python_python_3.x.txt |
Q:
Dynamic mass hosting using mod_wsgi
I am trying to configure an apache server using mod_wsgi for dynamic mass hosting. Each user will have it's own instance of a python application located in /mnt/data/www/domains/[user_name] and there will be a vhost.map telling me which domain maps to each user's directory (the ... | Dynamic mass hosting using mod_wsgi | I am trying to configure an apache server using mod_wsgi for dynamic mass hosting. Each user will have it's own instance of a python application located in /mnt/data/www/domains/[user_name] and there will be a vhost.map telling me which domain maps to each user's directory (the directory will have the same name as the ... | [
"Discussion thread about this at:\nhttp://groups.google.com/group/modwsgi/browse_frm/thread/2a9905f24c10a967\n"
] | [
1
] | [] | [] | [
"apache2",
"django",
"mod_wsgi",
"python"
] | stackoverflow_0002426637_apache2_django_mod_wsgi_python.txt |
Q:
Generating two thumbnails from the same image in Django
this seems like quite an easy problem but I can't figure out what is going on here.
Basically, what I'd like to do is create two different thumbnails from one image on a Django model. What ends up happening is that it seems to be looping and recreating the sa... | Generating two thumbnails from the same image in Django | this seems like quite an easy problem but I can't figure out what is going on here.
Basically, what I'd like to do is create two different thumbnails from one image on a Django model. What ends up happening is that it seems to be looping and recreating the same image (while appending an underscore to it each time) unti... | [
"Generally I like to give thumbnailing capabilities to the template author as much as possible. That way they can adjust the size of the things in the template. Whereas building it into the business logic layer is more fixed. You might have a reason though.\nThis template filter should generate the file on first lo... | [
3
] | [] | [] | [
"django",
"python",
"python_imaging_library",
"thumbnails"
] | stackoverflow_0002444691_django_python_python_imaging_library_thumbnails.txt |
Q:
Unpacking tuples/arrays/lists as indices for Numpy Arrays
I would love to be able to do
>>> A = numpy.array(((1,2),(3,4)))
>>> idx = (0,0)
>>> A[*idx]
and get
1
however this is not valid syntax. Is there a way of doing this without explicitly writing out
>>> A[idx[0], idx[1]]
?
EDIT: Thanks for the replies. In ... | Unpacking tuples/arrays/lists as indices for Numpy Arrays | I would love to be able to do
>>> A = numpy.array(((1,2),(3,4)))
>>> idx = (0,0)
>>> A[*idx]
and get
1
however this is not valid syntax. Is there a way of doing this without explicitly writing out
>>> A[idx[0], idx[1]]
?
EDIT: Thanks for the replies. In my program I was indexing with a Numpy array rather than a tupl... | [
"It's easier than you think:\n>>> import numpy\n>>> A = numpy.array(((1,2),(3,4)))\n>>> idx = (0,0)\n>>> A[idx]\n1\n\n",
"Try\nA[tuple(idx)]\n\nUnless you have a more complex use case that's not as simple as this example, the above should work for all arrays.\n",
"No unpacking is necessary—when you have a comma... | [
24,
21,
5,
4
] | [] | [] | [
"numpy",
"python"
] | stackoverflow_0002444923_numpy_python.txt |
Q:
Can a CLSID be different for the same program installed on two different machines?
I am using comtypes to generate wrappers for a certain com library. I am having certain issues with a few things, that are not being generated properly. I can get around this by doing the missing work, manually. However can i depend... | Can a CLSID be different for the same program installed on two different machines? | I am using comtypes to generate wrappers for a certain com library. I am having certain issues with a few things, that are not being generated properly. I can get around this by doing the missing work, manually. However can i depend on the fact that CLSID's will not change?
Lets say:
I install a program with the com li... | [
"The CLSID is at least supposed not to change. Naturally a program can do a lot many stupid things breaking regulations. But: AS the CLSID is how the class is loaded, a changed CLSID would mean the USING program of a class would also have to use the changed CLSID.\nSu, yous assumption is right - if the same program... | [
1,
1
] | [] | [] | [
"com",
"python"
] | stackoverflow_0002444897_com_python.txt |
Q:
How does Python differentiate between the different data types?
Sorry if this is quite noobish to you, but I'm just starting out to learn Python after learning C++ & Java, and I am wondering how in the world I could just declare variables like id = 0 and name = 'John' without any int's or string's in front! I figu... | How does Python differentiate between the different data types? | Sorry if this is quite noobish to you, but I'm just starting out to learn Python after learning C++ & Java, and I am wondering how in the world I could just declare variables like id = 0 and name = 'John' without any int's or string's in front! I figured out that perhaps it's because there are no ''s in a number, but h... | [
"The literal objects you mention carry (pointers to;-) their own types with them of course, so when a name's bound to that object the problem of type doesn't arise -- the object always has a type, the name doesn't -- just delegates that to the object it's bound to.\nThere's no \"figuring out\" in def increase(first... | [
13,
7,
6,
4,
0
] | [] | [] | [
"python"
] | stackoverflow_0002445193_python.txt |
Q:
Convert PPT to PNG via python
I want to convert PPT to png, or other image formats using Python.
This question has been asked on SO, but essentially recommends running OpenOffice in headless X server, which was an absolute pain last time I used it. (Mostly due to hard to replicate bugs due to OO crashing.)
Is ther... | Convert PPT to PNG via python | I want to convert PPT to png, or other image formats using Python.
This question has been asked on SO, but essentially recommends running OpenOffice in headless X server, which was an absolute pain last time I used it. (Mostly due to hard to replicate bugs due to OO crashing.)
Is there any other way, (Hopefully using L... | [
"A basic workflow : \n\nconvert your ppt to pdf by using a pdf printer from PowerPoint or OpenOffice's built in PDF converter\nuse ghostscript to convert the pdf to png or other image format (something along the line of gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r100 -sOutputFile=out.png in.pdf) \n\nYou can use ... | [
2
] | [] | [] | [
"file_conversion",
"powerpoint",
"python"
] | stackoverflow_0002443464_file_conversion_powerpoint_python.txt |
Q:
What are the semantics of the 'is' operator in Python?
How does the is operator determine if two objects are the same? How does it work? I can't find it documented.
A:
From the documentation:
Every object has an identity, a type
and a value. An object’s identity
never changes once it has been
created; you... | What are the semantics of the 'is' operator in Python? | How does the is operator determine if two objects are the same? How does it work? I can't find it documented.
| [
"From the documentation:\n\nEvery object has an identity, a type\n and a value. An object’s identity\n never changes once it has been\n created; you may think of it as the\n object’s address in memory. The ‘is‘\n operator compares the identity of two\n objects; the id() function returns an\n integer represen... | [
14,
14,
7
] | [] | [] | [
"python"
] | stackoverflow_0002438667_python.txt |
Q:
How to control a subthread process in python?
Code first:
'''this is main structure of my program'''
from twisted.web import http
from twisted.protocols import basic
import threading
threadstop = False #thread trigger,to be done
class MyThread(threading.Thread):
def __init__(self):
threading.Threa... | How to control a subthread process in python? | Code first:
'''this is main structure of my program'''
from twisted.web import http
from twisted.protocols import basic
import threading
threadstop = False #thread trigger,to be done
class MyThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.start()
def run(... | [
"Use the atexit module to register (in the main thread) a function that set the global threadstop to True, or, more simply, set the daemon attribute of the thread object to True so it won't keep the process alive if the main thread exits.\n",
"This is not a direct answer to your question and Alex has already addr... | [
2,
2
] | [] | [] | [
"multithreading",
"python",
"twisted"
] | stackoverflow_0002444616_multithreading_python_twisted.txt |
Q:
Test directory permissions in Python?
In Python on Windows, is there a way to determine if a user has permission to access a directory? I've taken a look at os.access but it gives false results.
>>> os.access('C:\haveaccess', os.R_OK)
False
>>> os.access(r'C:\haveaccess', os.R_OK)
True
>>> os.access('C:\donthavea... | Test directory permissions in Python? | In Python on Windows, is there a way to determine if a user has permission to access a directory? I've taken a look at os.access but it gives false results.
>>> os.access('C:\haveaccess', os.R_OK)
False
>>> os.access(r'C:\haveaccess', os.R_OK)
True
>>> os.access('C:\donthaveaccess', os.R_OK)
False
>>> os.access(r'C:\d... | [
"It can be complicated to check for permissions in Windows (beware of issues in Vista with UAC, for example! -- see this related question).\nAre you talking about simple read access, i.e. reading the directory's contents?\nThe surest way of testing permissions would be to try to access the directory (e.g. do an os.... | [
7,
5,
0
] | [] | [] | [
"directory",
"permissions",
"python",
"windows"
] | stackoverflow_0000539133_directory_permissions_python_windows.txt |
Q:
In Django, what is a one-to-one relationship?
I've always been using ForeignKeys.
A:
A one-to-one relationship is a unique relation between two entities in both directions. I.e. for an entity A there exists only one entity B and vice versa.
The documentation says:
Conceptually, this is similar to a ForeignKey ... | In Django, what is a one-to-one relationship? | I've always been using ForeignKeys.
| [
"A one-to-one relationship is a unique relation between two entities in both directions. I.e. for an entity A there exists only one entity B and vice versa.\nThe documentation says:\n\nConceptually, this is similar to a ForeignKey with unique=True, but the \"reverse\" side of the relation will directly return a si... | [
3
] | [] | [] | [
"database",
"django",
"mysql",
"python"
] | stackoverflow_0002445823_database_django_mysql_python.txt |
Q:
how to add markup to text using JavaScript regex
I need to add markup to some text using JavaScript regular expressions. In Python I could do this with:
>>> import re
>>> re.sub('(banana|apple)', r'<b>\1</b>', 'I have 1 banana and 2 apples!')
'I have 1 <b>banana</b> and 2 <b>apple</b>s!'
What is the equivalent in... | how to add markup to text using JavaScript regex | I need to add markup to some text using JavaScript regular expressions. In Python I could do this with:
>>> import re
>>> re.sub('(banana|apple)', r'<b>\1</b>', 'I have 1 banana and 2 apples!')
'I have 1 <b>banana</b> and 2 <b>apple</b>s!'
What is the equivalent in JavaScript?
string.replace(regex, newstring) seems to... | [
"In the new string, you can reference capture groups via the tokens $1, $2, etc. A lot of the high-level reference sites (like w3schools) fail to document that. It's in the spec, of course, or more accessibly discussed on MDC.\nSo taking your example:\n\"I have 1 banana and 2 apples!\".replace(/(banana|apple)/gi, \... | [
2,
2
] | [] | [] | [
"javascript",
"python",
"regex"
] | stackoverflow_0002446056_javascript_python_regex.txt |
Q:
Is there an API for Aardvark?
Is there an API for Aardvark (http://vark.com)? How can I programmatically ask questions and get answers?
A:
Since their website do not seems to provide an API, you'll have to rely upon the old, brutal and nevertheless efficient (as long as the site do not change) html scanning of p... | Is there an API for Aardvark? | Is there an API for Aardvark (http://vark.com)? How can I programmatically ask questions and get answers?
| [
"Since their website do not seems to provide an API, you'll have to rely upon the old, brutal and nevertheless efficient (as long as the site do not change) html scanning of pages.\nUsing java platform, i would suggest you to use Groovy goodness, like XmlSlurper, which allow one to parse an XML document with ease.\... | [
1
] | [] | [] | [
"java",
"php",
"python"
] | stackoverflow_0002441803_java_php_python.txt |
Q:
read a text field in Python using regular expressions
I have text file, like
FILED AS OF DATE: 20090209
DATE AS OF CHANGE: 20090209
I need to find the position using FILED AS OF DATE: and read the date. I know how to do it using python strings. But using a regular expression seems cooler:)
Btw, how to ... | read a text field in Python using regular expressions | I have text file, like
FILED AS OF DATE: 20090209
DATE AS OF CHANGE: 20090209
I need to find the position using FILED AS OF DATE: and read the date. I know how to do it using python strings. But using a regular expression seems cooler:)
Btw, how to parse the date?
Thanks!
| [
"#!/usr/bin/env python\nimport datetime, fileinput, re\n\nfor line in fileinput.input():\n if 'FILED AS OF DATE' in line:\n line = line.rstrip()\n dt = datetime.datetime.strptime(line, 'FILED AS OF DATE: %Y%m%d')\n\n # or with regex\n date_str, = re.findall(r'\\d+', line)\n dt... | [
3,
1,
1
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0002446447_python_regex.txt |
Q:
django deployment apache
I would like to create a python script, which will:
Create a django project in the current directory. Fix settings.py, urls.py.
Do syncdb
Install new apache instance listening on specific port (command line argument), with WSGI configured to serve my project.
I can't figure out how to do... | django deployment apache | I would like to create a python script, which will:
Create a django project in the current directory. Fix settings.py, urls.py.
Do syncdb
Install new apache instance listening on specific port (command line argument), with WSGI configured to serve my project.
I can't figure out how to do point 3.
EDIT:
Peter Rowell: ... | [
"Jacob Kaplan Moss' Django Deployment Workshop assets have some nice examples. You'll probably still need to do some legwork on your end to automate things to your taste but there may be some stuff in there you can use as a starting point.\nhttp://github.com/jacobian/django-deployment-workshop\n",
"One way is to ... | [
1,
1
] | [] | [] | [
"apache",
"deployment",
"django",
"python"
] | stackoverflow_0002419279_apache_deployment_django_python.txt |
Q:
monkey patching time.time() in python
I've an application where, for testing, I need to replace the time.time() call with a specific timestamp, I've done that in the past using ruby
(code available here: http://github.com/zemariamm/Back-to-Future/blob/master/back_to_future.rb )
However I do not know how to do thi... | monkey patching time.time() in python | I've an application where, for testing, I need to replace the time.time() call with a specific timestamp, I've done that in the past using ruby
(code available here: http://github.com/zemariamm/Back-to-Future/blob/master/back_to_future.rb )
However I do not know how to do this using Python.
Any hints ?
Cheers,
Ze Mari... | [
"You can simply set time.time to point to your new time function, like this:\nimport time\n\ndef my_time():\n return 0.0\n\nold_time = time.time\ntime.time = my_time\n\n"
] | [
14
] | [] | [] | [
"datetime",
"monkeypatching",
"python",
"ruby",
"time"
] | stackoverflow_0002446987_datetime_monkeypatching_python_ruby_time.txt |
Q:
How would I write this query in GeoDjango? (It's a library for geographic calculations in Django)
Right now I'm using raw SQL to find people within 500 meters of the current user.
cursor.execute("SELECT user_id FROM myapp_location WHERE\
GLength(LineStringFromWKB(LineString(asbinary(utm), asbinary(PointFrom... | How would I write this query in GeoDjango? (It's a library for geographic calculations in Django) | Right now I'm using raw SQL to find people within 500 meters of the current user.
cursor.execute("SELECT user_id FROM myapp_location WHERE\
GLength(LineStringFromWKB(LineString(asbinary(utm), asbinary(PointFromWKB(point(%s, %s)))))) < %s"\
,(user_utm_easting, user_utm_northing, 500));
How would I do this... | [
"Well assuming you have the appropriate model, \nfrom django.contrib.gis.db import models\n\nclass User(models.Model):\n location = models.PointField()\n objects = models.GeoManager()\n\nit would look like:\nUser.objects.filter(location__dwithin=(current_user.location, D(m=500)))\n\nBut note that such distanc... | [
1
] | [] | [] | [
"database",
"django",
"location",
"mysql",
"python"
] | stackoverflow_0002447257_database_django_location_mysql_python.txt |
Q:
How to define initialized C-array in the Pyrex?
I want to define initialized C-array in Pyrex, e.g. equivalent of:
unsigned char a[8] = {0,1,2,3,4,5,6,7};
What will be equivalent in Pyrex?
Just array is
cdef unsigned char a[8]
But how can I made it initialized with my values?
A:
In Cython, Pyrex's successor, t... | How to define initialized C-array in the Pyrex? | I want to define initialized C-array in Pyrex, e.g. equivalent of:
unsigned char a[8] = {0,1,2,3,4,5,6,7};
What will be equivalent in Pyrex?
Just array is
cdef unsigned char a[8]
But how can I made it initialized with my values?
| [
"In Cython, Pyrex's successor, this feature was added over a year a go to fix this feature request, so for example the following works in Cython now:\ncdef double a[] = [0.5, 0.3, 0.1, 0.1]\n\nHowever, Pyrex's development is proceeding much more slowly (which is why Cython was forked years ago by developers rarin' ... | [
4
] | [] | [] | [
"c",
"pyrex",
"python",
"python_c_extension"
] | stackoverflow_0002446873_c_pyrex_python_python_c_extension.txt |
Q:
Date versus time interval plotting in Matplotlib
The pyplot plot_date function expects pairs of dates and values to be plotted with a certain line style. Is there a recommended approach to plot multiple values or interval data against date/time values?
A:
To plot interval data, you may use the error bar provided... | Date versus time interval plotting in Matplotlib | The pyplot plot_date function expects pairs of dates and values to be plotted with a certain line style. Is there a recommended approach to plot multiple values or interval data against date/time values?
| [
"To plot interval data, you may use the error bar provided by the errorbar() function and the use axis.xaxis_date() to make matplotlib format the axis like plot_date() function does.\nHere is an example:\n#!/usr/bin/python\n\nimport datetime\nimport numpy as np\nimport matplotlib.dates as mdates\nimport matplotlib.... | [
5
] | [] | [] | [
"matplotlib",
"python"
] | stackoverflow_0002207670_matplotlib_python.txt |
Q:
How to customize pickle for django model objects
My app uses a "per-user session" to allow multiple sessions from the same user to share state. It operates very similarly to the django session by pickling objects.
I need to pickle a complex object that refers to django model objects. The standard pickling proces... | How to customize pickle for django model objects | My app uses a "per-user session" to allow multiple sessions from the same user to share state. It operates very similarly to the django session by pickling objects.
I need to pickle a complex object that refers to django model objects. The standard pickling process stores a denormalized object in the pickle. So if t... | [
"It's unclear what your goal is.\n\"But if I just store the id and class in a tuple then I'm necessarily going back to the database every time I use any of the django objects. I'd like to be able to keep the ones I'm using in memory over the course of a page request.\"\nThis doesn't make sense, since a view functio... | [
1,
0
] | [] | [] | [
"django",
"pickle",
"python"
] | stackoverflow_0002448035_django_pickle_python.txt |
Q:
How can I use functools.partial on multiple methods on an object, and freeze parameters out of order?
I find functools.partial to be extremely useful, but I would like to be able to freeze arguments out of order (the argument you want to freeze is not always the first one) and I'd like to be able to apply it to se... | How can I use functools.partial on multiple methods on an object, and freeze parameters out of order? | I find functools.partial to be extremely useful, but I would like to be able to freeze arguments out of order (the argument you want to freeze is not always the first one) and I'd like to be able to apply it to several methods on a class at once, to make a proxy object that has the same methods as the underlying object... | [
"You're \"binding too deep\": change def __getattribute__(self, name): to def __getattr__(self, name): in class PureProxy. __getattribute__ intercepts every attribute access and so bypasses everything that you've set with setattr(self, name, ... making those setattr bereft of any effect, which obviously's not what... | [
3
] | [] | [] | [
"functional_programming",
"metaprogramming",
"python",
"standard_library"
] | stackoverflow_0002448187_functional_programming_metaprogramming_python_standard_library.txt |
Q:
Python - platform-independent 5.1 Sound Library
Is there any dolby/5.1/7.1 audio processing Python library? It would be best if it is platform independent.
Would be nice if it looks like:
import lib
f = lib.open("8channels_audiofile")
lib.play(from=f.channel3, to="left rear");
A:
http://pysonic.sourceforge.net/... | Python - platform-independent 5.1 Sound Library | Is there any dolby/5.1/7.1 audio processing Python library? It would be best if it is platform independent.
Would be nice if it looks like:
import lib
f = lib.open("8channels_audiofile")
lib.play(from=f.channel3, to="left rear");
| [
"http://pysonic.sourceforge.net/ - this depends on FMOD, which is free for non-commercial use, and supported on many platforms.\nSee the FMOD website for details: http://www.fmod.org/\n"
] | [
1
] | [] | [] | [
"audio",
"multimedia",
"python",
"signal_processing"
] | stackoverflow_0002448652_audio_multimedia_python_signal_processing.txt |
Q:
Check result of AX_PYTHON_MODULE in configure.ac
In using the m4_ax_python_module.m4 macro in configure.ac (AX_PYTHON_MODULE), one can know at configure time if a given module is installed. It takes two arguments, the module name, and second argument which if not empty, will lead to an exit, useful when the module... | Check result of AX_PYTHON_MODULE in configure.ac | In using the m4_ax_python_module.m4 macro in configure.ac (AX_PYTHON_MODULE), one can know at configure time if a given module is installed. It takes two arguments, the module name, and second argument which if not empty, will lead to an exit, useful when the module is a must-have.
In the case where you don't want a f... | [
"Ok the best solution I've found so far was:\nEDIT: using AS_IF instead of just if test\nAS_IF([test \"x${HAVE_PYMOD_JSON}\" = \"xno\"], \n AS_IF([test \"x${HAVE_PYMOD_SIMPLEJSON}\" = \"xno\"],\n [AC_MSG_ERROR([Requires one of json or simplejson])]))\n\nWhat through me off was in the macro, the AS_TR_CPP ... | [
1
] | [] | [] | [
"autotools",
"configure",
"python"
] | stackoverflow_0002448756_autotools_configure_python.txt |
Q:
Getting a Jabber status via Python
I'm developing a website using the Django framework, and I need to retrieve Jabber (okay, Google Talk) statuses for a user. Most of the Jabber python libraries seem like an incredible amount of overkill (and overhead) for a simple task. Is there any simple way to do this?
I know... | Getting a Jabber status via Python | I'm developing a website using the Django framework, and I need to retrieve Jabber (okay, Google Talk) statuses for a user. Most of the Jabber python libraries seem like an incredible amount of overkill (and overhead) for a simple task. Is there any simple way to do this?
I know very little about XMPP/Jabber, though o... | [
"I recommend checking out Google AppEngine's XMPP API (Django runs on AppEngine, too). AFAIK you have to be authorized to check a user's status.\n",
"\nDo you need to be an authenticated and\n \"friended\" user to retrieve another\n user's status?\n\nYes.\nTo get the status of a given user, you should write a j... | [
0,
0
] | [] | [] | [
"django",
"google_talk",
"python",
"xmpp"
] | stackoverflow_0002375705_django_google_talk_python_xmpp.txt |
Q:
SQLAlchemy custom query column
I have a declarative table defined like this:
class Transaction(Base):
__tablename__ = "transactions"
id = Column(Integer, primary_key=True)
account_id = Column(Integer)
transfer_account_id = Column(Integer)
amount = Column(Numeric(12, 2))
...
The query shoul... | SQLAlchemy custom query column | I have a declarative table defined like this:
class Transaction(Base):
__tablename__ = "transactions"
id = Column(Integer, primary_key=True)
account_id = Column(Integer)
transfer_account_id = Column(Integer)
amount = Column(Numeric(12, 2))
...
The query should be:
SELECT id, (CASE WHEN transfe... | [
"The construct you are looking for is called column_property. You could use a secondary mapper to actually replace the amount column. Are you sure you are not making things too difficult for yourself by not just storing the negative values in the database directly or giving the \"corrected\" column a different name... | [
1,
1
] | [] | [] | [
"declarative",
"python",
"sqlalchemy"
] | stackoverflow_0002444679_declarative_python_sqlalchemy.txt |
Q:
What's the best way to record the type of every variable assignment in a Python program?
Python is so dynamic that it's not always clear what's going on in a large program, and looking at a tiny bit of source code does not always help. To make matters worse, editors tend to have poor support for navigating to the... | What's the best way to record the type of every variable assignment in a Python program? | Python is so dynamic that it's not always clear what's going on in a large program, and looking at a tiny bit of source code does not always help. To make matters worse, editors tend to have poor support for navigating to the definitions of tokens or import statements in a Python file.
One way to compensate might be t... | [
"I don't think you can help making it slow, but it should be possible to detect the address of each variable when you encounter a STORE_FAST STORE_NAME STORE_* opcode.\nWhether or not this has been done before, I do not know.\nIf you need debugging, look at PDB, this will allow you to step through your code and acc... | [
3,
1,
1,
1
] | [] | [] | [
"profiling",
"python"
] | stackoverflow_0000823103_profiling_python.txt |
Q:
Python Image Library, Close method
I have been using pil for the first time today. And I wanted to resize an image assuming it was larger than 800x600 and also create a thumbnail. I could do either of these tasks separately but not together in one method (I am doing a custom save method in django admin). This retu... | Python Image Library, Close method | I have been using pil for the first time today. And I wanted to resize an image assuming it was larger than 800x600 and also create a thumbnail. I could do either of these tasks separately but not together in one method (I am doing a custom save method in django admin). This returns a "cannot identify image file" error... | [
"Ah, if i only open the orginal image once and create the thumbnail after resizing then the problem is solved\n"
] | [
0
] | [] | [] | [
"django",
"python",
"python_imaging_library"
] | stackoverflow_0002449115_django_python_python_imaging_library.txt |
Q:
How to get the list of price offers on an item from Amazon with python-amazon-product-api item_lookup function?
I am trying to write a function to get a list of offers (their prices) for an item based on the ASIN:
def price_offers(asin):
from amazonproduct import API, ResultPaginator, AWSError
from config ... | How to get the list of price offers on an item from Amazon with python-amazon-product-api item_lookup function? | I am trying to write a function to get a list of offers (their prices) for an item based on the ASIN:
def price_offers(asin):
from amazonproduct import API, ResultPaginator, AWSError
from config import AWS_KEY, SECRET_KEY
api = API(AWS_KEY, SECRET_KEY, 'de')
str_asin = str(asin)
node = api.item_look... | [
"Seems like there is no Offer element in your response. Try\nnode = api.item_lookup(...)\nfrom lxml import etree\nprint etree.tostring(node, pretty_print=True)\n\nto see how the returned XML looks like.\n",
"OK, thanks. To anwser my own question for others who might have the same problem, the right way to do the ... | [
6,
6
] | [] | [] | [
"amazon",
"amazon_web_services",
"python"
] | stackoverflow_0002445420_amazon_amazon_web_services_python.txt |
Q:
Many to many relation SQLAlchemy (does relation exsist attribute)
I'm re-asking this question but with a different framework this time. I have two Models: User and Book with a M2M-relation. I want Book to have an attribute "read" that is True when the relation exists. Is this possible in SQLAlchemy?
A:
Take a lo... | Many to many relation SQLAlchemy (does relation exsist attribute) | I'm re-asking this question but with a different framework this time. I have two Models: User and Book with a M2M-relation. I want Book to have an attribute "read" that is True when the relation exists. Is this possible in SQLAlchemy?
| [
"Take a look at SQL Expressions as Mapped Attributes. Something like this should do the job for you: \nBook.read = column_property(\n select(\n [func.count(user_to_book_table.c.user_id)],\n user_to_book_table.c.book_id == book_table.c.id\n ).label('read')\n )\n\nEven though it... | [
1
] | [] | [] | [
"pylons",
"python",
"sqlalchemy"
] | stackoverflow_0002449258_pylons_python_sqlalchemy.txt |
Q:
GQL Request BadArgument Error. How to get around with my case?
My query is essentially the following:
entries=Entry.all().order("-votes").order("-date").filter("votes >", VOTE_FILTER).fetch(PAGE_SIZE+1, page* PAGE_SIZE)
I want to grab N of the latest entries that have a voting score above some benchmark (VOTE_FIL... | GQL Request BadArgument Error. How to get around with my case? | My query is essentially the following:
entries=Entry.all().order("-votes").order("-date").filter("votes >", VOTE_FILTER).fetch(PAGE_SIZE+1, page* PAGE_SIZE)
I want to grab N of the latest entries that have a voting score above some benchmark (VOTE_FILTER). Google currently says that I cannot filter on 'votes' because ... | [
"Assuming your 'vote filter' is a fixed threshold, you need to add a property to your model that records if it's above that threshold or not, enabling you to do a simple equality test to determine which records should be included.\n",
"Yep, there are Restrictions on Queries as this is Gql not Sql. It looks like y... | [
4,
0
] | [] | [] | [
"google_app_engine",
"gql",
"python"
] | stackoverflow_0002449090_google_app_engine_gql_python.txt |
Q:
Django: Adding inline formset rows without javascript
This post relates to this:
Add row to inlines dynamically in django admin
Is there a way to achive adding inline formsets WITHOUT using javascript? Obviously, there would be a page-refresh involved.
So, if the form had a button called 'add'...
I figured I could... | Django: Adding inline formset rows without javascript | This post relates to this:
Add row to inlines dynamically in django admin
Is there a way to achive adding inline formsets WITHOUT using javascript? Obviously, there would be a page-refresh involved.
So, if the form had a button called 'add'...
I figured I could do it like this:
if request.method=='POST':
if 'add' in ... | [
"Got it.\nSometimes it's the simplest solution. Just make a copy of the request.POST data and modify the TOTAL-FORMS.\nfor example..\nif request.method=='POST':\n PrimaryFunctionFormSet = inlineformset_factory(Position,Function)\n if 'add' in request.POST:\n cp = request.POST.copy()\n cp['prim-TOTAL_FORMS']... | [
6
] | [] | [] | [
"django",
"django_forms",
"django_models",
"django_views",
"python"
] | stackoverflow_0002448970_django_django_forms_django_models_django_views_python.txt |
Q:
Extending appengine's db.Property with caching
I'm looking to implement a property class for appengine, very similar to the existing db.ReferenceProperty. I am implementing my own version because I want some other default return values. My question is, how do I make the property remember its returned value, so tha... | Extending appengine's db.Property with caching | I'm looking to implement a property class for appengine, very similar to the existing db.ReferenceProperty. I am implementing my own version because I want some other default return values. My question is, how do I make the property remember its returned value, so that the datastore query is only performed the first ti... | [
"A PageProperty instance exists per-model, not per-entity (where an entity is an instance of the model class). So I think you need a dictionary that maps pagename -> Page entity, instead of a single attribute per PageProperty instance. E.g., maybe something like...:\nclass PageProperty(db.Property):\n data_type ... | [
2,
1
] | [] | [] | [
"descriptor",
"google_app_engine",
"python"
] | stackoverflow_0002438496_descriptor_google_app_engine_python.txt |
Q:
Scale 2D coordinates and keep their relative euclidean distances intact?
I have a set of points like: pointA(3302.34,9392.32), pointB(34322.32,11102.03), etc.
I need to scale these so each x- and y-coordinate is in the range (0.0 - 1.0).
I tried doing this by first finding the largest x value in the data set (maxi... | Scale 2D coordinates and keep their relative euclidean distances intact? | I have a set of points like: pointA(3302.34,9392.32), pointB(34322.32,11102.03), etc.
I need to scale these so each x- and y-coordinate is in the range (0.0 - 1.0).
I tried doing this by first finding the largest x value in the data set (maximum_x_value), and the largest y value in the set (minimum_y_value). I then did... | [
"You need to scale the x values and the y values by the same amount! I would suggest scaling by the larger of the two ranges (either x or y). In pseudocode, you'd have something like \nscale = max(maximum_x_value - minimum_x_value,\n maximum_y_value - minimum_y_value)\n\nThen all the distances between po... | [
10,
9,
4,
3,
3
] | [] | [] | [
"coordinates",
"math",
"python",
"scale"
] | stackoverflow_0002450035_coordinates_math_python_scale.txt |
Q:
Django: How to detect if translation is activated?
django.utils.translation.get_language() returns default locale if translation is not activated. Is there a way to find out whether the translation is activated (via translation.activate()) or not?
A:
Horribly hacky, but should work in at least 1.1.1:
import djan... | Django: How to detect if translation is activated? | django.utils.translation.get_language() returns default locale if translation is not activated. Is there a way to find out whether the translation is activated (via translation.activate()) or not?
| [
"Horribly hacky, but should work in at least 1.1.1:\nimport django.utils.translation.trans_real as trans\nfrom django.utils.thread_support import currentThread\n\ndef isactive():\n return currentThread() in trans._active\n\n",
"Depends on application and architecture...\nHack provided by Ignacio should works, bu... | [
3,
0
] | [
"Always inspect source code for such question, it's faster than posting to Web!\nDjango does it's black magic behind the scene, and uses some kind of dispatcher to simulate disabled translations.\nThe best way for you to do is:\nimport setttings\nassert settings.USE_i18N == True\n\n"
] | [
-2
] | [
"django",
"internationalization",
"python"
] | stackoverflow_0001605706_django_internationalization_python.txt |
Q:
String formatting error
Using the code print('{0} is not'.format('That that is not')) in Python 3.1.1, I get the following error:
AttributeError: 'str' object has no attribute 'format'
when I delete the line Netbeans automatically inserted at the beginning:
from distutils.command.bdist_dumb import format
which i... | String formatting error | Using the code print('{0} is not'.format('That that is not')) in Python 3.1.1, I get the following error:
AttributeError: 'str' object has no attribute 'format'
when I delete the line Netbeans automatically inserted at the beginning:
from distutils.command.bdist_dumb import format
which itself causes an error of
Impo... | [
"You must be running an older version of Python. This does work in Python 3.1.1+:\n$ python3\nPython 3.1.1+ (r311:74480, Nov 2 2009, 14:49:22) \n[GCC 4.4.1] on linux2\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> '{0} is not'.format('That that is not')\n'That that is not is n... | [
6
] | [] | [] | [
"format",
"python",
"string"
] | stackoverflow_0002450188_format_python_string.txt |
Q:
Scheduling a JasperServer Report via SOAP using Python
I was able to figure out how to run reports, download files, list folders, etc. on a JasperServer using Python with SOAPpy and xml.dom minidom.
Here's an example execute report request, which works:
repositoryURL = 'http://user@pass:myjasperserver:8080/jaspers... | Scheduling a JasperServer Report via SOAP using Python | I was able to figure out how to run reports, download files, list folders, etc. on a JasperServer using Python with SOAPpy and xml.dom minidom.
Here's an example execute report request, which works:
repositoryURL = 'http://user@pass:myjasperserver:8080/jasperserver/services/repository'
repositoryWSDL = repositoryURL + ... | [
"I've had a lot of bad experiences with minidom. I recommend you use lxml. I haven't had any experience with soap itself, so I can't speak to the rest of the issue. \n",
"Without knowing anything at all about Jasper, I can guarantee you that you'll do better to replace your hardcoded SOAP requests with a simple... | [
1,
1
] | [] | [] | [
"jasper_reports",
"jasperserver",
"python",
"soap"
] | stackoverflow_0000870188_jasper_reports_jasperserver_python_soap.txt |
Q:
Python for loop question
I was wondering how to achieve the following in python:
for( int i = 0; cond...; i++)
if cond...
i++; //to skip an run-through
I tried this with no luck.
for i in range(whatever):
if cond... :
i += 1
A:
Python's for loops are different. i gets reassigned to the next value e... | Python for loop question | I was wondering how to achieve the following in python:
for( int i = 0; cond...; i++)
if cond...
i++; //to skip an run-through
I tried this with no luck.
for i in range(whatever):
if cond... :
i += 1
| [
"Python's for loops are different. i gets reassigned to the next value every time through the loop.\nThe following will do what you want, because it is taking the literal version of what C++ is doing:\ni = 0\nwhile i < some_value:\n if cond...:\n i+=1\n ...code...\n i+=1\n\nHere's why:\nin C++, the... | [
44,
13,
4,
4,
2,
1,
0
] | [] | [] | [
"for_loop",
"loops",
"python"
] | stackoverflow_0002429560_for_loop_loops_python.txt |
Q:
Desktop Application Development with Javascript, Python / Ruby
Besides using Appcelerator's Titanium Desktop, are there other approaches to integrating Javascript and Ruby/Python into cross-platform desktop applications? Just trying to get a sense of the landscape here. From searching the web, it seems Titanium ... | Desktop Application Development with Javascript, Python / Ruby | Besides using Appcelerator's Titanium Desktop, are there other approaches to integrating Javascript and Ruby/Python into cross-platform desktop applications? Just trying to get a sense of the landscape here. From searching the web, it seems Titanium may be leading the charge in terms of this type of integration. I w... | [
"There is Pyjamas Desktop, but might be a bit out of date.\n",
"You can also script Swing or SWT with JRuby, either directly, or via one of the numerous frameworks.\nYou might manage to integrate protovis via a webkit or gecko (like redcar does) embedding, or a java html renderer, there are some. Or just use a ja... | [
2,
0
] | [] | [] | [
"desktop_application",
"javascript",
"python",
"ruby"
] | stackoverflow_0002436078_desktop_application_javascript_python_ruby.txt |
Q:
How can I make a wxPython app constantly update and execute code?
Given the following simple program:
import wx
class TestDraw(wx.Panel):
def __init__(self,parent=None,id=-1):
wx.Panel.__init__(self,parent,id,style=wx.TAB_TRAVERSAL)
self.SetBackgroundColour("#FFFFFF")
self.Bind(wx.EVT_... | How can I make a wxPython app constantly update and execute code? | Given the following simple program:
import wx
class TestDraw(wx.Panel):
def __init__(self,parent=None,id=-1):
wx.Panel.__init__(self,parent,id,style=wx.TAB_TRAVERSAL)
self.SetBackgroundColour("#FFFFFF")
self.Bind(wx.EVT_PAINT,self.onPaint)
self.SetDoubleBuffered(True)
self.c... | [
"Your can use a wxTimer to periodically call an onTimer(self) method.\n"
] | [
3
] | [] | [] | [
"python",
"user_interface",
"wxpython"
] | stackoverflow_0002450972_python_user_interface_wxpython.txt |
Q:
How to write services with CPython?
Does CPython have any library that helps to write binding-independent services?
I have found some SOAP libraries for Python, but it misses the flexibility of choosing the binding at runtime.
A:
Packages such as SimpleXMLRPCServer (part of the Python standard library), SimpleJS... | How to write services with CPython? | Does CPython have any library that helps to write binding-independent services?
I have found some SOAP libraries for Python, but it misses the flexibility of choosing the binding at runtime.
| [
"Packages such as SimpleXMLRPCServer (part of the Python standard library), SimpleJSONRPCServer, and probably at least some of the SOAP server-side libraries you found (the good ones;-), are based on the concept of registering functions and instances with the package to make them available to clients of the service... | [
2
] | [] | [] | [
"cpython",
"python",
"service",
"soa",
"soap"
] | stackoverflow_0002450839_cpython_python_service_soa_soap.txt |
Q:
Storing multiple discarded datas in a single variable using a string accumulator
For an assignment for my intro to python course, we are to write a program that generates 100 sets of x,y coordinates.
X must be a float between -100.0 and 100.0 inclusive, but not 0.
Y is Y = ((1/x) * 3070) but if the absolute value ... | Storing multiple discarded datas in a single variable using a string accumulator | For an assignment for my intro to python course, we are to write a program that generates 100 sets of x,y coordinates.
X must be a float between -100.0 and 100.0 inclusive, but not 0.
Y is Y = ((1/x) * 3070) but if the absolute value of Y is greater than 100, both numbers must be discarded (BUT STORED) and another set ... | [
"\"string accumulator\" is not a Python \"terms of art\". Maybe the teacher meant \"accumulate it all into a single string\" (a horrible approach in Python), or maybe (if the course has already covered lists) he mean a list of strings (the proper Python approach).\nOther answers already cover the first possibility... | [
1,
0,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0002450898_python.txt |
Q:
Deleting object in function
Let's say I have created two objects from class foo and now want to combine the two. How, if at all possible, can I accomplish that within a function like this:
def combine(first, second):
first.value += second.value
del second #this doesn't work, though first.value *does* get c... | Deleting object in function | Let's say I have created two objects from class foo and now want to combine the two. How, if at all possible, can I accomplish that within a function like this:
def combine(first, second):
first.value += second.value
del second #this doesn't work, though first.value *does* get changed
instead of doing somethin... | [
"No. All del does against names is unbind them. This only removes the local reference. The object will be destroyed when there are no references to it anywhere, or all the references are in a reference loop.\n"
] | [
4
] | [] | [] | [
"function",
"python",
"python_3.x"
] | stackoverflow_0002451467_function_python_python_3.x.txt |
Q:
How can I draw to a MemoryDC using the GraphicsContext, and then blit that to a PaintDC?
I'm looking to add double buffering to a drawing function like this.
dc = wx.PaintDC(self)
gc = wx.GraphicsContext.Create(dc)
#draw GraphicsPaths to the gc
I tried to first draw to a MemoryDC and then blit that ba... | How can I draw to a MemoryDC using the GraphicsContext, and then blit that to a PaintDC? | I'm looking to add double buffering to a drawing function like this.
dc = wx.PaintDC(self)
gc = wx.GraphicsContext.Create(dc)
#draw GraphicsPaths to the gc
I tried to first draw to a MemoryDC and then blit that back to the PaintDC:
dc = wx.MemoryDC()
dc.SelectObject(wx.NullBitmap)
gc = wx.Graph... | [
"You need to create a bitmap, not use wx.NullBitmap.\nbitmap = wx.EmptyBitmap(w, h)\ndc = wx.MemoryDC(bitmap)\n\n"
] | [
1
] | [] | [] | [
"graphicscontext",
"python",
"wxpython"
] | stackoverflow_0002451610_graphicscontext_python_wxpython.txt |
Q:
Quicker way than "try" and "except" ? - Python
I'm often having code written as follows
try:
self.title = item.title().content.string
except AttributeError, e:
self.title = None
Is there a quicker way of dealing with this? a one-liner?
A:
What exceptions are you getting from item.title()? The bare except (... | Quicker way than "try" and "except" ? - Python | I'm often having code written as follows
try:
self.title = item.title().content.string
except AttributeError, e:
self.title = None
Is there a quicker way of dealing with this? a one-liner?
| [
"What exceptions are you getting from item.title()? The bare except (horrible practice!) doesn't tell us. If it's an AttributeError (where item doesn't have a title method, for example),\nself.title = getattr(item, 'title', lambda: None)()\n\nmight be the one-liner you seek (but performance won't be enormously di... | [
6,
2,
2,
0,
0,
0
] | [] | [] | [
"beautifulsoup",
"python"
] | stackoverflow_0002443489_beautifulsoup_python.txt |
Q:
How to get a template tag to auto-check a checkbox in Django
I'm using a ModelForm class to generate a bunch of checkboxes for a ManyToManyField but I've run into one problem: while the default behaviour automatically checks the appropriate boxes (when I'm editing an object), I can't figure out how to get that inf... | How to get a template tag to auto-check a checkbox in Django | I'm using a ModelForm class to generate a bunch of checkboxes for a ManyToManyField but I've run into one problem: while the default behaviour automatically checks the appropriate boxes (when I'm editing an object), I can't figure out how to get that information in my own custom templatetag.
Here's what I've got in my ... | [
"In your input tag for the checkbox, you can just add the checked attribute based on some condition. Say your box object has property checked which value is either \"checked\" or empty string \"\"\nr += \"<label for=\\\"id_%s_%d\\\" class=\\\"%s\\\"><input type=\\\"checkbox\\\" name=\\\"%s\\\" value=\\\"%s\\\" id=\... | [
3,
0
] | [] | [] | [
"django",
"python",
"templatetags"
] | stackoverflow_0002447261_django_python_templatetags.txt |
Q:
how to get the index or the element itself of an element found with "if element in list"
Does a direct way to do this exists?
if element in aList:
#get the element from the list
I'm thinking something like this:
aList = [ ([1,2,3],4) , ([5,6,7],8) ]
element = [5,6,7]
if element in aList
#print the 8
A:
... | how to get the index or the element itself of an element found with "if element in list" | Does a direct way to do this exists?
if element in aList:
#get the element from the list
I'm thinking something like this:
aList = [ ([1,2,3],4) , ([5,6,7],8) ]
element = [5,6,7]
if element in aList
#print the 8
| [
"L = [([1, 2, 3], 4), ([5, 6, 7], 8)]\nelement = [5, 6, 7]\n\nfor a, b in L:\n if a == element:\n print b\n break\nelse:\n print \"not found\"\n\nBut it sounds like you want to use a dictionary:\nL = [([1, 2, 3], 4), ([5, 6, 7], 8)]\nelement = [5, 6, 7]\n\nD = dict((tuple(a), b) for a, b in L)\n# keys must ... | [
3,
1,
1,
0,
0,
0,
0
] | [] | [] | [
"list",
"python",
"tuples"
] | stackoverflow_0002452093_list_python_tuples.txt |
Q:
GetAuthSubToken returns None
Hey guys, I am a little lost on how to get the auth token. Here is the code I am using on the return from authorizing my app:
client = gdata.service.GDataService()
gdata.alt.appengine.run_on_appengine(client)
sessionToken = gdata.auth.extract_auth_sub_token_from_url(self.request.uri)
... | GetAuthSubToken returns None | Hey guys, I am a little lost on how to get the auth token. Here is the code I am using on the return from authorizing my app:
client = gdata.service.GDataService()
gdata.alt.appengine.run_on_appengine(client)
sessionToken = gdata.auth.extract_auth_sub_token_from_url(self.request.uri)
client.UpgradeToSessionToken(sessi... | [
"To answer my own question:\nWhen you get the Token just call:\nclient.token_store.add_token(sessionToken)\n\nand App Engine will store it in a new entity type for you. Then when making calls to the calendar service just dont set the authsubtoken as it will take care of that for you also.\n"
] | [
0
] | [] | [] | [
"gdata",
"gdata_api",
"google_app_engine",
"python"
] | stackoverflow_0002441813_gdata_gdata_api_google_app_engine_python.txt |
Q:
Python: Create a duplicate of an array
I have an double array
alist[1][1]=-1
alist2=[]
for x in xrange(10):
alist2.append(alist[x])
alist2[1][1]=15
print alist[1][1]
and I get 15. Clearly I'm passing a pointer rather than an actual variable... Is there an easy way to make a seperate double array (no shared ... | Python: Create a duplicate of an array | I have an double array
alist[1][1]=-1
alist2=[]
for x in xrange(10):
alist2.append(alist[x])
alist2[1][1]=15
print alist[1][1]
and I get 15. Clearly I'm passing a pointer rather than an actual variable... Is there an easy way to make a seperate double array (no shared pointers) without having to do a double for ... | [
"I think copy.deepcopy() is for just this case.\n",
"You can use somelist[:], that is a slice like somelist[1:2] from beginning to end, to create a (shallow) copy of a list. Applying this to your for-loop gives:\nalist2 = []\nfor x in xrange(10):\n alist2.append(alist[x][:])\n\nThis can also be written as a lis... | [
9,
8,
4,
1,
1,
0
] | [] | [] | [
"arrays",
"list",
"pointers",
"python"
] | stackoverflow_0002452321_arrays_list_pointers_python.txt |
Q:
Organizing Python objects for retrieval
I have a Club class and a Player Class. The player class has an attribute Fav.clubs which will have unique club values. So the user is supposed to enter various club names. Based on the club names I must retrieve those club objects and establish the relationship that this pa... | Organizing Python objects for retrieval | I have a Club class and a Player Class. The player class has an attribute Fav.clubs which will have unique club values. So the user is supposed to enter various club names. Based on the club names I must retrieve those club objects and establish the relationship that this particular player has this Fav.clubs.
The attri... | [
"Store all clubs in a dictionary called all_clubs. The key should be the club-name and the value the club object itself. Then you can do all_clubs[clubname] to retrieve the club object for a given name.\nThe player might have an attribute club_names which is the list of the unique names you described and a property... | [
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0002452688_python.txt |
Q:
Encrypting XML database in python
i am using XML as my backend for the application...
LXML is used to parse the xml.
How can i encrypt this xml file to make sure that the data is protected......
thanks in advance.
A:
As XML contains repetitive structure it is better to first compress and then encrypt it.
Downloa... | Encrypting XML database in python | i am using XML as my backend for the application...
LXML is used to parse the xml.
How can i encrypt this xml file to make sure that the data is protected......
thanks in advance.
| [
"As XML contains repetitive structure it is better to first compress and then encrypt it.\nDownload and install PyDes.\nfrom pyDes import *\nimport bz2\n\ndef encrypt(data,password):\n k = des(password, CBC, \"\\0\\0\\0\\0\\0\\0\\0\\0\", pad=None, padmode=PAD_PKCS5)\n d = k.encrypt(data)\n return d\n\ndef ... | [
4
] | [] | [] | [
"encryption",
"lxml",
"python",
"xml"
] | stackoverflow_0002452744_encryption_lxml_python_xml.txt |
Q:
Python evaluation order
Here's the code, I don't quite understand, how does it work. Could anyone tell, is that an expected behavior?
$ipython
In [1]: 1 in [1] == True
Out[1]: False
In [2]: (1 in [1]) == True
Out[2]: True
In [3]: 1 in ([1] == True)
---------------------------------------------------------------... | Python evaluation order | Here's the code, I don't quite understand, how does it work. Could anyone tell, is that an expected behavior?
$ipython
In [1]: 1 in [1] == True
Out[1]: False
In [2]: (1 in [1]) == True
Out[2]: True
In [3]: 1 in ([1] == True)
---------------------------------------------------------------------------
TypeError ... | [
"This is an example of \"chaining\" which is a gotcha in Python. It's a (possibly silly) trick of Python that:\na op b op c\n\nis equivalent to:\n(a op b) and (b op c)\n\nfor all operators of the same precedence. Unfortunately, in and == have the same precedence, as do is and all comparisons. \nSo, here is your ... | [
15
] | [] | [] | [
"python"
] | stackoverflow_0002452837_python.txt |
Q:
Beginner python - stuck in a loop
I have two begininer programs, both using the 'while' function, one works correctly, and the other gets me stuck in a loop. The first program is this;
num=54
bob = True
print('The guess a number Game!')
while bob == True:
guess = int(input('What is your guess? '))
if gu... | Beginner python - stuck in a loop | I have two begininer programs, both using the 'while' function, one works correctly, and the other gets me stuck in a loop. The first program is this;
num=54
bob = True
print('The guess a number Game!')
while bob == True:
guess = int(input('What is your guess? '))
if guess==num:
print('wow! You\'re ... | [
"In the second example, the user doesn't get a chance to enter a new guess inside the loop, so a and b remain the same. \n",
"In the second program you never give the user a chance to pick two new numbers if they're not equal. Put the lines where you get input from the user inside the loop, like this:\n#try a fu... | [
4,
3,
2,
2
] | [] | [] | [
"infinite_loop",
"python",
"python_3.x"
] | stackoverflow_0002452961_infinite_loop_python_python_3.x.txt |
Q:
ZSI.generate.Wsdl2PythonError: unsupported local simpleType restriction
i have this simple type from an external webservice:
<xsd:element name="card_number" maxOccurs="1"
minOccurs="1">
<xsd:simpleType>
<xsd:restriction base="tns:PanType">
<xsd:pattern value="\d{16}"></xsd:pattern>
<xsd:whiteSp... | ZSI.generate.Wsdl2PythonError: unsupported local simpleType restriction | i have this simple type from an external webservice:
<xsd:element name="card_number" maxOccurs="1"
minOccurs="1">
<xsd:simpleType>
<xsd:restriction base="tns:PanType">
<xsd:pattern value="\d{16}"></xsd:pattern>
<xsd:whiteSpace value="collapse"></xsd:whiteSpace>
</xsd:restriction>
</xsd:simpleTyp... | [
"I'm not sure if this is still the case, but a quick google suggests that simpleTypes with user-defined restriction bases aren't supported by ZSI.\nIf this is still the case, then you could modify the restriction for \"card_number\" to remove the base and update the restriction-facets within the simpleType-restrict... | [
1
] | [] | [] | [
"python",
"soap",
"xml",
"zsi"
] | stackoverflow_0002453186_python_soap_xml_zsi.txt |
Q:
How to stop a QDialog from executing while still in the __init__ statement (or immediately after)?
I am wondering how I can go about stopping a dialog from opening if certain conditions are met in its __init__ statement.
The following code tries to call the 'self.close()' function and it does, but (I'm assuming) s... | How to stop a QDialog from executing while still in the __init__ statement (or immediately after)? | I am wondering how I can go about stopping a dialog from opening if certain conditions are met in its __init__ statement.
The following code tries to call the 'self.close()' function and it does, but (I'm assuming) since the dialog has not yet started its event loop, that it doesn't trigger the close event? So is ther... | [
"The dialog will be run only if exec_ method is called. You should therefore check conditions in the exec_ method and if they are met, run exec_ from QDialog.\nOther method is to raise an exception inside the constructor (though I am not sure, it is a good practice; in other languages you generally shouldn't allow ... | [
1
] | [] | [] | [
"pyqt4",
"python",
"qdialog"
] | stackoverflow_0002405750_pyqt4_python_qdialog.txt |
Q:
Doxygen C++ comment string parser in python?
Does anybody know of a python module to parse a doxygen style C++ comment string? I mean a string like this (simple example):
/**
* A constructor.
* A more elaborate description of the constructor.
* @param param1 test1
* @param param2 test2
*/
and I w... | Doxygen C++ comment string parser in python? | Does anybody know of a python module to parse a doxygen style C++ comment string? I mean a string like this (simple example):
/**
* A constructor.
* A more elaborate description of the constructor.
* @param param1 test1
* @param param2 test2
*/
and I would like to extract the brief, the long descripti... | [
"You might be able to set something up using the SimpleParse module, but this does require creating an EBNF grammar which might be more investment than you are interested in.\nThe Sphinx/Doxygen bridge (Breathe) uses the xml output of Doxygen and acts on that instead. Perhaps a similar approach could work here - r... | [
5,
1
] | [] | [] | [
"c++",
"doxygen",
"parsing",
"python"
] | stackoverflow_0002377985_c++_doxygen_parsing_python.txt |
Q:
Python list is not the same reference
This is the code:
L=[1,2]
L is L[:]
False
Why is this False?
A:
L[:] (slice notation) means: Make a copy of the entire list, element by element.
So you have two lists that have identical content, but are separate entities. Since is evaluates object identity, it returns Fa... | Python list is not the same reference | This is the code:
L=[1,2]
L is L[:]
False
Why is this False?
| [
"L[:] (slice notation) means: Make a copy of the entire list, element by element.\nSo you have two lists that have identical content, but are separate entities. Since is evaluates object identity, it returns False.\nL == L[:] returns True.\n",
"When in doubt ask for id ;)\n>>> li = [1,2,4]\n>>> id(li)\n18686240\n... | [
14,
6,
2
] | [] | [] | [
"python"
] | stackoverflow_0002453672_python.txt |
Q:
etree.findall: 'OR'-lookup?
I want to find all stylesheet definitions in a XHTML file with lxml.etree.findall. This could be as simple as
elems = tree.findall('link[@rel="stylesheet"]') + tree.findall('style')
But the problem with CSS style definitions is that the order matters, e.g.
<link rel="stylesheet" type="... | etree.findall: 'OR'-lookup? | I want to find all stylesheet definitions in a XHTML file with lxml.etree.findall. This could be as simple as
elems = tree.findall('link[@rel="stylesheet"]') + tree.findall('style')
But the problem with CSS style definitions is that the order matters, e.g.
<link rel="stylesheet" type="text/css" href="/media/css/first.... | [
"Possible using XPATH:\ndata = \"\"\"<link rel=\"stylesheet\" type=\"text/css\" href=\"/media/css/first.css\" />\n<style>body:{font-size: 10px;}</style>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"/media/css/second.css\" />\n\"\"\"\n\nfrom lxml import etree\n\nh = etree.HTML(data)\n\nh.xpath('//link[@rel=\"s... | [
3
] | [] | [] | [
"elementtree",
"lxml",
"python",
"xpath"
] | stackoverflow_0002453891_elementtree_lxml_python_xpath.txt |
Q:
Django QuerySet ordering by number of reverse ForeignKey matches
I have the following Django models:
class Foo(models.Model):
title = models.CharField(_(u'Title'), max_length=600)
class Bar(models.Model):
foo = models.ForeignKey(Foo)
eg_id = models.PositiveIntegerField(_(u'Example ID'), default=0)
I ... | Django QuerySet ordering by number of reverse ForeignKey matches | I have the following Django models:
class Foo(models.Model):
title = models.CharField(_(u'Title'), max_length=600)
class Bar(models.Model):
foo = models.ForeignKey(Foo)
eg_id = models.PositiveIntegerField(_(u'Example ID'), default=0)
I wish to return a list of Foo objects which have a reverse relationship... | [
"Use Django's lovely aggregation features.\nfrom django.db.models import Count\nqs = Foo.objects.filter(\n bar__eg_id__in=id_list\n ).annotate(\n bar_count=Count('bar')\n ).order_by('bar_count')\n\n",
"You can do that by using aggregation, and more especifically annotation and order_... | [
22,
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0002453821_django_python.txt |
Q:
What is a Pythonic way to get a list of tuples of all the possible combinations of the elements of two lists?
Suppose I have two differently-sized lists
a = [1, 2, 3]
b = ['a', 'b']
What is a Pythonic way to get a list of tuples c of all the possible combinations of one element from a and one element from b?
>>> ... | What is a Pythonic way to get a list of tuples of all the possible combinations of the elements of two lists? | Suppose I have two differently-sized lists
a = [1, 2, 3]
b = ['a', 'b']
What is a Pythonic way to get a list of tuples c of all the possible combinations of one element from a and one element from b?
>>> print c
[(1, 'a'), (1, 'b'), (2, 'a'), (2, 'b'), (3, 'a'), (3, 'b')]
The order of elements in c does not matter.
T... | [
"Use a list comprehension:\n>>> a = [1, 2, 3]\n>>> b = ['a', 'b']\n>>> c = [(x,y) for x in a for y in b]\n>>> print c\n[(1, 'a'), (1, 'b'), (2, 'a'), (2, 'b'), (3, 'a'), (3, 'b')]\n\n",
"Try itertools.product.\n"
] | [
13,
10
] | [] | [] | [
"list",
"python"
] | stackoverflow_0002454626_list_python.txt |
Q:
How do you get SQLAlchemy to override MySQL "on update CURRENT_TIMESTAMP"
I've inherited an older database that was setup with a "on update CURRENT_TIMESTAMP" put on a field that should only describe an item's creation. With PHP I have been using "timestamp=timestamp" on UPDATE clauses, but in SQLAlchemy I can't ... | How do you get SQLAlchemy to override MySQL "on update CURRENT_TIMESTAMP" | I've inherited an older database that was setup with a "on update CURRENT_TIMESTAMP" put on a field that should only describe an item's creation. With PHP I have been using "timestamp=timestamp" on UPDATE clauses, but in SQLAlchemy I can't seem to force the system to use the set timestamp.
Do I have no choice and need... | [
"SQLAlchemy doesn't try to set the field because it thinks the value hasn't changed.\nYou can tell SQLAlchemy to reassign the value by specifying the onupdate attribute on the Column:\n Column('timestamp', ..., onupdate=literal_column('timestamp'))\n\nThis will result in SQLAlchemy automatically adding timestamp=ti... | [
6
] | [] | [] | [
"mysql",
"python",
"sqlalchemy"
] | stackoverflow_0002450593_mysql_python_sqlalchemy.txt |
Q:
How do you run python scripts from other script and have their root in my root?
I have a module "B", I want to run it from a script "C", and I want to call global variables in "B", as they were in the "C" root. Another problem is if I imported sys in "B" when I run "C" it doesn't see sys
# NameError: global name '... | How do you run python scripts from other script and have their root in my root? | I have a module "B", I want to run it from a script "C", and I want to call global variables in "B", as they were in the "C" root. Another problem is if I imported sys in "B" when I run "C" it doesn't see sys
# NameError: global name 'sys' is not defined #
What shall I do?
| [
"When you import a module B (like import B), every line in B will be interpreted. I assume this is what you mean when you say you want to run it. To reference members in B's namespace, you can get them like:\nB.something_defined_in_B.\nIf you wish to use sys explicitly in C, you will need to import it within C as... | [
5,
1
] | [] | [] | [
"global_variables",
"import",
"module",
"python"
] | stackoverflow_0002454576_global_variables_import_module_python.txt |
Q:
Python ctypes callback function to SWIG
I have a SWIG C++ function that expects a function pointer (WNDPROC), and want to give it a Python function that has been wrapped by ctypes.WINFUNCTYPE.
It seems to me that this should be compatible, but SWIG's type checking throws an exception because it doesn't know that t... | Python ctypes callback function to SWIG | I have a SWIG C++ function that expects a function pointer (WNDPROC), and want to give it a Python function that has been wrapped by ctypes.WINFUNCTYPE.
It seems to me that this should be compatible, but SWIG's type checking throws an exception because it doesn't know that the ctypes.WINFUNCTYPE type is acctually a WND... | [
"I don't have a windows machine to really check this, but I think you need to create a typemap to tell swig how to convert the PyObject wrapper to a WNDPROC:\n// assuming the wrapped object has an attribute \"pointer\" which contains \n// the numerical address of the WNDPROC\n%typemap(in) WNDPROC {\n PyObject * ... | [
4
] | [] | [] | [
"c++",
"ctypes",
"python",
"swig"
] | stackoverflow_0002032470_c++_ctypes_python_swig.txt |
Q:
how to make a variable change from the text "1m" into "1000000" in python
I have variables with values like 1.7m 1.8k and 1.2b how can I convert them to a real number value for example
1.7m = 1700000
1.8k = 1800
1.2b = 1200000000
A:
I would define a dictionary:
tens = dict(k=10e3, m=10e6, b=10e9)
then
x='1.7m'... | how to make a variable change from the text "1m" into "1000000" in python | I have variables with values like 1.7m 1.8k and 1.2b how can I convert them to a real number value for example
1.7m = 1700000
1.8k = 1800
1.2b = 1200000000
| [
"I would define a dictionary:\ntens = dict(k=10e3, m=10e6, b=10e9)\n\nthen \nx='1.7m'\nfactor, exp = x[0:-1], x[-1].lower()\nans = int(float(factor) * tens[exp])\n\n",
"You might be interested in a units library like quantities or unum.\n",
"Using lambda:\n>>> tens = {'k': 10e3, 'm': 10e6, 'b': 10e9}\n>>> f = l... | [
11,
1,
1,
0
] | [] | [] | [
"numbers",
"python"
] | stackoverflow_0002449848_numbers_python.txt |
Q:
How do we override the choice field display of a reference property in appengine using Django?
The default choice field display of a reference property in appengine returns the choices
as the string representation of the entire object. What is the best method to override this behaviour? I tried to override str() i... | How do we override the choice field display of a reference property in appengine using Django? | The default choice field display of a reference property in appengine returns the choices
as the string representation of the entire object. What is the best method to override this behaviour? I tried to override str() in the referenced class. But it does not work.
| [
"I got it to work by overriding the init method of the modelform to pick up the correct fields as I had to do filtering of the choices as well. \n",
"The correct way would be to override the __unicode__ method of the class, like:\ndef __unicode__(self):\n return self.name\n\nwhere name is the value that you wa... | [
1,
0
] | [] | [] | [
"django",
"google_app_engine",
"python",
"referenceproperty"
] | stackoverflow_0001635638_django_google_app_engine_python_referenceproperty.txt |
Q:
Matplotlib installation problems
I need to install matplotlib in a remote linux machine, and I am a normal user there.
I downlodad the source and run
python setup.py build
but I get errors, related with numpy, which is not installed, so I decieded to install it first. I download and compile with
python setup.py... | Matplotlib installation problems | I need to install matplotlib in a remote linux machine, and I am a normal user there.
I downlodad the source and run
python setup.py build
but I get errors, related with numpy, which is not installed, so I decieded to install it first. I download and compile with
python setup.py build
My question now is, how do I t... | [
"Since you are a user and not root on the remote machine, it may be that your environement is not configured correctly.\nCheck that you can load numpy from the interperter.\n\n\nimport numpy\n\n\nIf that fails, you may need to add its installed location to sys.path\nimport sys\nsys.path.append(\"\\user\\local\\nump... | [
1,
0
] | [] | [] | [
"matplotlib",
"numpy",
"python"
] | stackoverflow_0002453324_matplotlib_numpy_python.txt |
Q:
How to spell check python docstring with emacs?
I'd like to run a spell checker on the docstrings of my Python code, if possible from within emacs.
I've found the ispell-check-comments setting which can be used to spell check only comments in code, but I was not able to target only the docstrings which are a fair... | How to spell check python docstring with emacs? | I'd like to run a spell checker on the docstrings of my Python code, if possible from within emacs.
I've found the ispell-check-comments setting which can be used to spell check only comments in code, but I was not able to target only the docstrings which are a fairly python-specific thing.
| [
"I recommend you to try flyspell-mode. You could use something like:\n(add-hook 'python-mode-hook 'flyspell-prog-mode)\nin your Emacs configuration.\n"
] | [
19
] | [] | [] | [
"docstring",
"emacs",
"python",
"spell_checking"
] | stackoverflow_0002455062_docstring_emacs_python_spell_checking.txt |
Q:
GAE-mechanize sourcecode
i saw a project that made mechanize compatible to google app engine. But I couldn't find the sourcecode to it
It would be very nice if someone can give me the source of it, because I most likely need this in the app I'm creating currently.
A:
See Mechanize and Google App Engine
I got thi... | GAE-mechanize sourcecode | i saw a project that made mechanize compatible to google app engine. But I couldn't find the sourcecode to it
It would be very nice if someone can give me the source of it, because I most likely need this in the app I'm creating currently.
| [
"See Mechanize and Google App Engine\nI got this by googling mechanize google app engine.\n"
] | [
1
] | [] | [] | [
"google_app_engine",
"mechanize",
"python"
] | stackoverflow_0002456321_google_app_engine_mechanize_python.txt |
Q:
BasicHTTPServer, SimpleHTTPServer and concurrency
I'm writing a small web server for testing purposes using python, BasicHTTPServer and SimpleHTTPServer. It looks like it's processing one request at a time. Is there any way to make it a little faster without messing around too deeply?
Basicly my code looks as the ... | BasicHTTPServer, SimpleHTTPServer and concurrency | I'm writing a small web server for testing purposes using python, BasicHTTPServer and SimpleHTTPServer. It looks like it's processing one request at a time. Is there any way to make it a little faster without messing around too deeply?
Basicly my code looks as the following and I'd like to keep it this simple ;)
os.chd... | [
"You can make your own threading or forking class with a mixin inheritance from SocketServer:\nimport SocketServer\nimport BaseHTTPServer\n\nclass ThreadingHTTPServer(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer):\n pass\n\nThis has its limits as it doesn't use a thread pool, is limited by the GIT, etc... | [
9,
1,
0
] | [] | [] | [
"concurrency",
"python",
"simplehttpserver"
] | stackoverflow_0002455606_concurrency_python_simplehttpserver.txt |
Q:
can't figure out serving static images in django dev environment
I've read the article (and few others on the subject), but still can't figure out how to show an image unless a link to a file existing on a web-service is hard-coded into the html template.
I've got in urls.py:
...
(r'^galleries/(landscapes)... | can't figure out serving static images in django dev environment | I've read the article (and few others on the subject), but still can't figure out how to show an image unless a link to a file existing on a web-service is hard-coded into the html template.
I've got in urls.py:
...
(r'^galleries/(landscapes)/(?P<path>.jpg)$',
'django.views.static.serve', {'document_root':... | [
"This is a long post, basically summarizing all the things I learned about Django in order to get static files to work (it took me a while to understand how all the different parts fit together). \nTo serve static images in your development server (and later, your real server), you're going to have to do a few thin... | [
11,
5,
1
] | [] | [] | [
"django",
"image",
"python"
] | stackoverflow_0002451352_django_image_python.txt |
Q:
Using Python, what's the best way to create a set of files on disk for testing?
I'm looking for a way to create a tree of test files to unit test a packaging tool. Basically, I want to create some common file system structures -- directories, nested directories, symlinks within the selected tree, symlinks outside ... | Using Python, what's the best way to create a set of files on disk for testing? | I'm looking for a way to create a tree of test files to unit test a packaging tool. Basically, I want to create some common file system structures -- directories, nested directories, symlinks within the selected tree, symlinks outside the tree, &c.
Ideally I want to do this with as little boilerplate as possible. Of co... | [
"Automated in what way?\nYou could write a simple format to define a basic file structure using nested dictionaries:\n## if you saved this as tree.py\n## you could use it by doing:\n# from tree import *\n## then following the examples at the bottom of this file\n\nimport os, shutil, time\n\nclass Node:\n def __i... | [
1,
1
] | [] | [] | [
"automation",
"python",
"unit_testing"
] | stackoverflow_0002456226_automation_python_unit_testing.txt |
Q:
how to build good python web application
i never worked with web programming and
i've been asked lately to write a web-based software to manage assets and tasks. to be used by more than 900 persons
what are the recommended modules , frameworks , libraries for this task.
and it will be highly appreciated if you... | how to build good python web application | i never worked with web programming and
i've been asked lately to write a web-based software to manage assets and tasks. to be used by more than 900 persons
what are the recommended modules , frameworks , libraries for this task.
and it will be highly appreciated if you guyz recommend some books and articles that m... | [
"Check out Django. I would say it is the most comprehensive and easy to use python web framework.\nThey have a book and tutorial as well.\nYou might also like to visit Python wiki about web frameworks for more suggestions. But still, I highly recommend Django.\n",
"I've really enjoyed working with CherryPy in my ... | [
10,
2,
1,
1,
0,
0,
0
] | [] | [] | [
"python",
"web_applications"
] | stackoverflow_0002455996_python_web_applications.txt |
Q:
Reading object tree from file into Python
I have a Python app that contains an object structure that the user can manipulate. What I want to do is allow the user to create a file declaring how the object structure should be created.
For example, I would like the user to be able to create the following file:
foo.ba... | Reading object tree from file into Python | I have a Python app that contains an object structure that the user can manipulate. What I want to do is allow the user to create a file declaring how the object structure should be created.
For example, I would like the user to be able to create the following file:
foo.bar.baz = true
x.y.z = 12
and for my app to then... | [
"Typically problems like this one are solved with XML. However in your case you can do something even easier.\nAssuming the dots represent hierarchy delimiters, you could read in the left hand side of the = sign (input.split('=')[0]), and then perform a split('.') on the dots. Next, create a nested dictionary struc... | [
1
] | [] | [] | [
"python"
] | stackoverflow_0002456828_python.txt |
Q:
Serialize a message format to xml
I have a python list as
[
(A,{'a':1,'b':2,'c':3,'d':4}),
B,{'a':1,'b':2,'c':3,'d':4}),
...
]
I want to know if there is a standard library of serializing this kind of list to xml or should I hand code it to a file.
Edit : Added Detail
Assuming this is used to... | Serialize a message format to xml | I have a python list as
[
(A,{'a':1,'b':2,'c':3,'d':4}),
B,{'a':1,'b':2,'c':3,'d':4}),
...
]
I want to know if there is a standard library of serializing this kind of list to xml or should I hand code it to a file.
Edit : Added Detail
Assuming this is used to construct a message such that
message ... | [
"Does it need to be XML? This is the usual domain of the pickle module.\nBut, no, there's no standard serialize-Python-object-to-XML library. (I have one I wrote a while ago, it's not published, much less \"standard\".) There are libraries like lxml for converting XML to Python objects and back, and the usual sax... | [
4,
2,
1
] | [] | [] | [
"python",
"xml",
"xml_serialization"
] | stackoverflow_0002456722_python_xml_xml_serialization.txt |
Q:
fastest way to search through this data object? (python)
I have a data object that looks like this:
{
'node-16': {
'tags': ['cuda'],
'localNodes': [
{
'name': 'nC',
'consumesFrom': ['nA', 'nB'],
'classTy... | fastest way to search through this data object? (python) | I have a data object that looks like this:
{
'node-16': {
'tags': ['cuda'],
'localNodes': [
{
'name': 'nC',
'consumesFrom': ['nA', 'nB'],
'classType': 'VectorAdder.VectorAdder'
},
... | [
"namedict = dict((x['name'], y) for y in data for x in data[y]['localNodes'])\nproddict = dict((z['name'], [y for y in z['consumesFrom'] if namedict[y] != x])\n for x in data for z in data[x]['localNodes'] if z['consumesFrom'] is not None)\n\nprint 'nA' in proddict['nC']\n\n"
] | [
1
] | [] | [] | [
"python"
] | stackoverflow_0002457064_python.txt |
Q:
Looping through columns in a .csv files in Python
I want to be able to use Python to open a .csv file like this:
5,26,42,2,1,6,6
and then perform some operation on them like addition.
total = 0
with open("file.csv") as csv_file:
for row in csv.reader(csv_file, delimiter=','):
for number in ra... | Looping through columns in a .csv files in Python | I want to be able to use Python to open a .csv file like this:
5,26,42,2,1,6,6
and then perform some operation on them like addition.
total = 0
with open("file.csv") as csv_file:
for row in csv.reader(csv_file, delimiter=','):
for number in range(7):
total += int(row[number])
The... | [
"You can just say\nfor col in row:\n total += int(col)\n\nFor example:\nimport csv\nfrom StringIO import StringIO\n\ntotal = 0\nfor row in csv.reader(StringIO(\"1,2,3,4\")):\n for col in row:\n total += int(col)\n\nprint total # prints 10\n\nThe reason why you can do this is that csv.reader returns ... | [
9,
3
] | [] | [] | [
"csv",
"python",
"sum"
] | stackoverflow_0002457193_csv_python_sum.txt |
Q:
Checkboxes with pylons
I have been trying to add some check boxes in a pylons mako. However I don't know how to get their values in the controller. It seems that it can only get the first value of the check boxes. I tried using form encode but i got several errors. Is there an easier way to do this?
Thanks
A:
I'... | Checkboxes with pylons | I have been trying to add some check boxes in a pylons mako. However I don't know how to get their values in the controller. It seems that it can only get the first value of the check boxes. I tried using form encode but i got several errors. Is there an easier way to do this?
Thanks
| [
"I'm assuming that \"I can only get the first value\" means you've got a series of checkboxes with the same value for the 'name' attribute within your form? \nNow, if that's the case and you're wanting a list of boolean values based on whether or not the boxes are checked or not, you'll need to do two things:\nF... | [
0
] | [] | [] | [
"pylons",
"python"
] | stackoverflow_0002456926_pylons_python.txt |
Q:
Python | efficiency and performance
Lets say I'm going to save 100 floating point numbers in a list by running a single script, most probably it will take some memory to process.So if this code executes every time as a requirement of an application there will be performance hits, so my question is how to maintain ... | Python | efficiency and performance | Lets say I'm going to save 100 floating point numbers in a list by running a single script, most probably it will take some memory to process.So if this code executes every time as a requirement of an application there will be performance hits, so my question is how to maintain efficiency in order to gain performance.
... | [
"Bottlenecks occur at unexpected places, so never optimize code just because you think it might be the right code to try to improve. What you need to do is\n\nWrite your program so that it runs completely.\nDevelop tests to make sure your program is correct.\nDecide whether your program is too slow.\n\n\nThere is a... | [
8,
2
] | [] | [] | [
"optimization",
"premature_optimization",
"python"
] | stackoverflow_0002457363_optimization_premature_optimization_python.txt |
Q:
faking a filesystem / virtual filesystem
I have a web service to which users upload python scripts that are run on a server. Those scripts process files that are on the server and I want them to be able to see only a certain hierarchy of the server's filesystem (best: a temporary folder on which I copy the files I... | faking a filesystem / virtual filesystem | I have a web service to which users upload python scripts that are run on a server. Those scripts process files that are on the server and I want them to be able to see only a certain hierarchy of the server's filesystem (best: a temporary folder on which I copy the files I want processed and the scripts).
The server w... | [
"Either a chroot jail or a higher-order security mechanism such as SELinux can be used to restrict access to specific resources. \n",
"You are probably best to use a virtual machine like VirtualBox or VMware (perhaps even creating one per user/session). \nThat will allow you some control over other resources suc... | [
5,
3,
0
] | [] | [] | [
"filesystems",
"python",
"sandbox",
"security"
] | stackoverflow_0002452488_filesystems_python_sandbox_security.txt |
Q:
What is the paste deploy uri syntax?
Paste Deploy can reference code with uris such as
[section]
use = egg:FooBar#baz
What is the full syntax for these uris?
A:
Those URIs are fully detailed in the documentation. It boils down to config:, egg:, and prefix-less URIs that point to other sections.
| What is the paste deploy uri syntax? | Paste Deploy can reference code with uris such as
[section]
use = egg:FooBar#baz
What is the full syntax for these uris?
| [
"Those URIs are fully detailed in the documentation. It boils down to config:, egg:, and prefix-less URIs that point to other sections.\n"
] | [
2
] | [] | [] | [
"paster",
"python"
] | stackoverflow_0002435865_paster_python.txt |
Q:
recurse over a list
I'm trying to recurse over a list (eg. [True, [[True, False], [False, [False, True]]]]) using Python. I know that the list length will always be 2 and both values will be boolean. I'd like to take those values and substitute them back into the list until there are only 2 values left (or 1 boo... | recurse over a list | I'm trying to recurse over a list (eg. [True, [[True, False], [False, [False, True]]]]) using Python. I know that the list length will always be 2 and both values will be boolean. I'd like to take those values and substitute them back into the list until there are only 2 values left (or 1 boolean value). Any help wo... | [
"You haven't said how to combine the two parts, so I'm assuming or but you could use another function instead.\nl = [True, [[True, False], [False, [False, True]]]]\n\ndef foo(x):\n if isinstance(x, list):\n return foo(x[0]) or foo(x[1])\n else:\n return x\n\nprint foo(l)\n\n",
"say your list i... | [
4,
0
] | [] | [] | [
"python",
"recursion"
] | stackoverflow_0002458075_python_recursion.txt |
Q:
How to model a social news feed on Google App Engine
We want to implement a "News feed" where a user can see messages
broadcasted by her friends, sorted with newest message first. But the
feed should reflect changes in her friends list. (If she adds new
friends, messages from those should be included in the feed, ... | How to model a social news feed on Google App Engine | We want to implement a "News feed" where a user can see messages
broadcasted by her friends, sorted with newest message first. But the
feed should reflect changes in her friends list. (If she adds new
friends, messages from those should be included in the feed, and if
she removes friends their messages should not be in... | [
"Pasting the answer I got for this question in the Google Group for Google App Engine http://groups.google.com/group/google-appengine/browse_thread/thread/09a05c5f41163b4d# By Ikai L (Google) \n\nA couple of thoughts here: \n\nis removing of friends a common event? similarly, is adding of \n friends a common ... | [
3
] | [] | [] | [
"google_app_engine",
"google_cloud_datastore",
"python",
"social_networking"
] | stackoverflow_0002447488_google_app_engine_google_cloud_datastore_python_social_networking.txt |
Q:
Should I strip the XML declaration from suds output before parsing with lxml?
I’m trying to implement a SOAP webservice in Python 2.6 using the suds library. That is working well, but I’ve run into a problem when trying to parse the output with lxml.
Suds returns a suds.sax.text.Text object with the reply from the... | Should I strip the XML declaration from suds output before parsing with lxml? | I’m trying to implement a SOAP webservice in Python 2.6 using the suds library. That is working well, but I’ve run into a problem when trying to parse the output with lxml.
Suds returns a suds.sax.text.Text object with the reply from the SOAP service. The suds.sax.text.Text class is a subclass of the Python built-in Un... | [
"You and lxml are correct; a valid XML document must be a stream of bytes encoded as declared in the <?xml ..... header (default: UTF-8).\nI'd suggest a third option: leave it in unicode with an XML header that omits the encoding declaration but leaves the version in there (future-safe). That will keep lxml happy a... | [
2,
1
] | [] | [] | [
"lxml",
"python",
"soap",
"suds",
"unicode"
] | stackoverflow_0002458244_lxml_python_soap_suds_unicode.txt |
Q:
Giving users a "reputation system" - Should I...?
I'm thinking of adding a reputation system to my Django web application; the site is already being used so I'm trying to be careful about my choices.
Reputation is generated in all actions that contribute to the site, similar to Stackoverflow's system.
I know there... | Giving users a "reputation system" - Should I...? | I'm thinking of adding a reputation system to my Django web application; the site is already being used so I'm trying to be careful about my choices.
Reputation is generated in all actions that contribute to the site, similar to Stackoverflow's system.
I know there are literally millions of ways of implementing this, a... | [
"In Django, I'd suggest having a property on the User (or Profile) model that calculates a user's reputation on-demand. Then, cache the reputation with your caching framework and/or store to the database for fast retrieval.\nThis way, in addition to having the records of what impacts reputation, you can change you... | [
6,
4
] | [] | [] | [
"django",
"python",
"web_applications"
] | stackoverflow_0002458355_django_python_web_applications.txt |
Q:
Concatenate multi value into one record
I joined two tables together and what I like to do is concatenate multi vaule in one records without duplicated value.
Input Table
Table name: TAXLOT_ZONE
TID ZONE
1 A
1 A
1 B
1 C
2 D
2 D
2 E
3 A
3 B
4 C
5 D
Desirable output ta... | Concatenate multi value into one record | I joined two tables together and what I like to do is concatenate multi vaule in one records without duplicated value.
Input Table
Table name: TAXLOT_ZONE
TID ZONE
1 A
1 A
1 B
1 C
2 D
2 D
2 E
3 A
3 B
4 C
5 D
Desirable output table looks like;
table name: Taxlot_zone_out
T... | [
"Assuming your table is in sorted order and is iterable, you can use itertools.groupby to group rows with the same first element.\nl = [(1, 'A'), (1, 'A'), (1, 'B'), (1, 'C'),\n (2, 'D'), (2, 'D'), (2, 'E'),\n (3, 'A'), (3, 'B'),\n (4, 'C'),\n (5, 'D')]\n\nfrom itertools import groupby\nfrom operato... | [
1
] | [] | [] | [
"python"
] | stackoverflow_0002458585_python.txt |
Q:
How to apply a function to a collection of elements
Consider I have an array of elements out of which I want to create a new 'iterable' which on every next applies a custom 'transformation'. What's the proper way of doing it under python 2.x?
For people familiar with Java, the equivalent is Iterables#transform fro... | How to apply a function to a collection of elements | Consider I have an array of elements out of which I want to create a new 'iterable' which on every next applies a custom 'transformation'. What's the proper way of doing it under python 2.x?
For people familiar with Java, the equivalent is Iterables#transform from google's collections framework.
Ok as for a dummy examp... | [
"A generator expression:\n(foobar(x) for x in S)\n\n",
"Another way of doing it:\nfrom itertools import imap\nmy_generator = imap(my_function, my_iterable)\n\nThat's the way I'd do it myself, but I'm kind of weird in that I actually like map.\n",
"Or by using map():\ndef foo(x):\n return x**x \n\nfor y in m... | [
5,
3,
1
] | [] | [] | [
"python"
] | stackoverflow_0002458621_python.txt |
Q:
Abort a slow flush to disk after write?
Is there a way to abort a python write operation in such a way that the OS doesn't feel it's necessary to flush the unwritten data to the disc?
I'm writing data to a USB device, typically many megabytes. I'm using 4096 bytes as my block size on the write, but it appears that... | Abort a slow flush to disk after write? | Is there a way to abort a python write operation in such a way that the OS doesn't feel it's necessary to flush the unwritten data to the disc?
I'm writing data to a USB device, typically many megabytes. I'm using 4096 bytes as my block size on the write, but it appears that Linux caches up a bunch of data early on, an... | [
"It's somewhat filesystem dependent, but in some filesystems, if you delete a file before (all of) it is allocated, the IO to write the blocks will never happen. This might also be true if you truncate it so that the part which is still being written is chopped off.\nNot sure that you can really abort a write if yo... | [
2,
2,
1
] | [] | [] | [
"file_io",
"flush",
"linux",
"python"
] | stackoverflow_0002458624_file_io_flush_linux_python.txt |
Q:
How efficient is Python substring extraction?
I've got the entire contents of a text file (at least a few KB) in string myStr.
Will the following code create a copy of the string (less the first character) in memory?
myStr = myStr[1:]
I'm hoping it just refers to a different location in the same internal buffer. I... | How efficient is Python substring extraction? | I've got the entire contents of a text file (at least a few KB) in string myStr.
Will the following code create a copy of the string (less the first character) in memory?
myStr = myStr[1:]
I'm hoping it just refers to a different location in the same internal buffer. If not, is there a more efficient way to do this?
Th... | [
"At least in 2.6, slices of strings are always new allocations; string_slice() calls PyString_FromStringAndSize(). It doesn't reuse memory--which is a little odd, since with invariant strings, it should be a relatively easy thing to do.\nShort of the buffer API (which you probably don't want), there isn't a more e... | [
4,
3,
1,
1
] | [] | [] | [
"memory",
"performance",
"python",
"substring"
] | stackoverflow_0002457367_memory_performance_python_substring.txt |
Q:
Extract substructure from a text file using bash or python
I have a huge text file, which follows the structure:
SET
TAG1
...
...
SET
...
SET
TAG2
...
...
SET
...
...
I would like to extract for a specific TAG, (i.e. TAG54) its individual "substructure", which would be
SET
TAG54
...
...
SET
Each substructure, fo... | Extract substructure from a text file using bash or python | I have a huge text file, which follows the structure:
SET
TAG1
...
...
SET
...
SET
TAG2
...
...
SET
...
...
I would like to extract for a specific TAG, (i.e. TAG54) its individual "substructure", which would be
SET
TAG54
...
...
SET
Each substructure, for a given TAG_i contains always:
first line:SET
second line:TAG_... | [
"Here's a Python approach: you pass in the open file handle as the first argument, the tag number as second argument, and get back as the result a list of the relevant lines (including newline characters), or an empty line if the tag is not found in the file:\ndef lookfor(f, tagnum):\n tag = 'TAG%s\\n' % tagnum\n ... | [
1,
0,
0,
0,
0
] | [] | [] | [
"bash",
"python"
] | stackoverflow_0002456813_bash_python.txt |
Q:
How do I copy only the values and not the references from a Python list?
Specifically, I want to create a backup of a list, then make some changes to that list, append all the changes to a third list, but then reset the first list with the backup before making further changes, etc, until I'm finished making change... | How do I copy only the values and not the references from a Python list? | Specifically, I want to create a backup of a list, then make some changes to that list, append all the changes to a third list, but then reset the first list with the backup before making further changes, etc, until I'm finished making changes and want to copy back all the content in the third list to the first one. Un... | [
"You want copy.deepcopy() for this.\n",
"The first thing to understand is why that setEqual method can't work: you need to know how identifiers work. (Reading that link should be very helpful.) For a quick rundown with probably too much terminology: in your function, the parameter restore is bound to an object, a... | [
8,
5
] | [] | [] | [
"backup",
"list",
"python",
"python_3.x",
"restore"
] | stackoverflow_0002458904_backup_list_python_python_3.x_restore.txt |
Q:
Is there a library in Python that can convert user-dates to timestamp?
If the month is: "12"
Day is: "05"
Year is: "2010"
Can this be converted into a timestamp somehow, in a very simple way?
A:
You can use the datetime module:
import datetime
d = datetime.date(year, month, day)
At this point, d is a date obje... | Is there a library in Python that can convert user-dates to timestamp? | If the month is: "12"
Day is: "05"
Year is: "2010"
Can this be converted into a timestamp somehow, in a very simple way?
| [
"You can use the datetime module:\nimport datetime\n\nd = datetime.date(year, month, day)\n\nAt this point, d is a date object.\nIf you want a timestamp from that, you can do the following:\nimport time\n\ntimestamp = time.mktime(d.timetuple())\n\n",
"import datetime\n\nd = datetime.datetime(year=2010,day=5,month... | [
2,
1,
1,
0
] | [] | [] | [
"date",
"datetime",
"python",
"timestamp"
] | stackoverflow_0002454088_date_datetime_python_timestamp.txt |
Q:
Strange python error
I am trying to write a python program that calculates a histogram, given a list of numbers like:
1
3
2
3
4
5
3.2
4
2
2
so the input parameters are the filename and the number of intervals.
The program code is:
#!/usr/bin/env python
import os, sys, re, string, array, math
import numpy
Lista ... | Strange python error | I am trying to write a python program that calculates a histogram, given a list of numbers like:
1
3
2
3
4
5
3.2
4
2
2
so the input parameters are the filename and the number of intervals.
The program code is:
#!/usr/bin/env python
import os, sys, re, string, array, math
import numpy
Lista = []
db = sys.argv[1]
db... | [
"I believe the problem may be a peculiar off-by one in the line:\nint_number = 1 + int((item-lmin)/width)\n\nWhy that 1 +? Python indices on an array of length N are from 0 to N-1 included. The 1 + here makes int_number go from 1 to 1 + (lmax-lmin)/width i.e. to 1 + nintervals given the formula for width, while y... | [
1,
1,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0002457529_python.txt |
Q:
Python importing
I have a file, myfile.py, which imports Class1 from file.py and file.py contains imports to different classes in file2.py, file3.py, file4.py.
In my myfile.py, can I access these classes or do I need to again import file2.py, file3.py, etc.?
Does Python automatically add all the imports included i... | Python importing | I have a file, myfile.py, which imports Class1 from file.py and file.py contains imports to different classes in file2.py, file3.py, file4.py.
In my myfile.py, can I access these classes or do I need to again import file2.py, file3.py, etc.?
Does Python automatically add all the imports included in the file I imported,... | [
"Best practice is to import every module that defines identifiers you need, and use those identifiers as qualified by the module's name; I recommend using from only when what you're importing is a module from within a package. The question has often been discussed on SO.\nImporting a module, say moda, from many mo... | [
11,
1,
0,
0
] | [] | [] | [
"import",
"python"
] | stackoverflow_0002459300_import_python.txt |
Q:
How to determine if the variable is a function in Python?
Since functions are values in Python, how do I determine if the variable is a function?
For example:
boda = len # boda is the length function now
if ?is_var_function(boda)?:
print "Boda is a function!"
else:
print "Boda is not a function!"
Here hypot... | How to determine if the variable is a function in Python? | Since functions are values in Python, how do I determine if the variable is a function?
For example:
boda = len # boda is the length function now
if ?is_var_function(boda)?:
print "Boda is a function!"
else:
print "Boda is not a function!"
Here hypothetical ?is_var_function(x)? should return true if x is a calla... | [
"The callable built-in mentioned in other answers doesn't answer your question as posed, because it also returns True, besides functions, for methods, classes, instances of classes which define a __call__ method. If your question's title and text are wrong, and you don't care if something is in fact a function but... | [
18,
14,
9,
4,
2,
1,
0,
0
] | [] | [] | [
"function",
"python"
] | stackoverflow_0002459329_function_python.txt |
Q:
How to schedule hundreds of thousands of tasks?
We have hundreds of thousands of tasks that need to be run at a variety of arbitrary intervals, some every hour, some every day, and so on. The tasks are resource intensive and need to be distributed across many machines.
Right now tasks are stored in a database with... | How to schedule hundreds of thousands of tasks? | We have hundreds of thousands of tasks that need to be run at a variety of arbitrary intervals, some every hour, some every day, and so on. The tasks are resource intensive and need to be distributed across many machines.
Right now tasks are stored in a database with an "execute at this time" timestamp. To find tasks t... | [
"Since ACID isn't needed and you're okay with tasks potentially running twice, I wouldn't keep the timestamps in the database at all. For each task, create a list of [timestamp_of_next_run, task_id] and use a min-heap to store all of the lists. Python's heapq module can maintain the heap for you. You'll be able ... | [
5,
3,
1,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0002458296_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.