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:
Python 2.6 write string in C-API using the system encoding
I have a project in Python 2.6 and I'd like to write a utf-8 message to stdout using the system encoding. However it appears that such a function does not exist until Python 3.2:
PySys_FormatStdout
http://docs.python.org/dev/c-api/sys.html
Is there a way ... | Python 2.6 write string in C-API using the system encoding | I have a project in Python 2.6 and I'd like to write a utf-8 message to stdout using the system encoding. However it appears that such a function does not exist until Python 3.2:
PySys_FormatStdout
http://docs.python.org/dev/c-api/sys.html
Is there a way to do this from Python 2.6?
To clarify I have a banner that need... | [
"PyUnicode_DecodeUTF8()\nPyObject_Print()\n",
"You could use PyFile_WriteObject():\nf_stdout = PySys_GetObject(\"stdout\");\ntext = PyUnicode_DecodeUTF8((char*)str, strlen(str), \"strict\");\nPyFile_WriteObject(text, f_stdout, Py_PRINT_RAW);\n\nIf you know the final encoding then you could use PyUnicode_AsEncoded... | [
2,
1
] | [] | [] | [
"python",
"python_c_api",
"unicode"
] | stackoverflow_0004502987_python_python_c_api_unicode.txt |
Q:
How do I route specific paths using WSGIApplication()?
Currently I have foo.com/bar routing to a request handler Main. I also want foo.com/bar/id to route to that request handler (where "id" is an id of an object).
Here's what I tried but it's failing:
application = webapp.WSGIApplication(
... | How do I route specific paths using WSGIApplication()? | Currently I have foo.com/bar routing to a request handler Main. I also want foo.com/bar/id to route to that request handler (where "id" is an id of an object).
Here's what I tried but it's failing:
application = webapp.WSGIApplication(
[('/bar', MainHandler),
... | [
"You need to change the signature of your MainHandler.get method, like so:\nclass MainHandler(webapp.RequestHandler):\n def get(self, bar_id=None):\n if bar_id is None:\n # Handle /bar requests\n else:\n # Handle /bar/whatever requests\n\n"
] | [
2
] | [] | [] | [
"google_app_engine",
"httpwebrequest",
"python",
"web_applications"
] | stackoverflow_0004503576_google_app_engine_httpwebrequest_python_web_applications.txt |
Q:
Mechanize submit
We have a form which has a few separate submit buttons which do different actions. The problem is I have a couple of buttons which have the following HTML:
<input type="submit" name="submit" value="Submit" class="submitLink" title="Submit" />
<input type="submit" name="submit" value="Delete" clas... | Mechanize submit | We have a form which has a few separate submit buttons which do different actions. The problem is I have a couple of buttons which have the following HTML:
<input type="submit" name="submit" value="Submit" class="submitLink" title="Submit" />
<input type="submit" name="submit" value="Delete" class="submitLink" title="... | [
"A fairly ghetto workaround is to manually iterate through all the controls in the form in question and then remove the controls from the form that you do not want based on criteria. For instance:\nfor each in form.controls[:]:\n if each not \"some criteria\":\n form.controls.remove(each)\n\nThe best idea here ... | [
3
] | [] | [] | [
"mechanize",
"python",
"testing"
] | stackoverflow_0004503141_mechanize_python_testing.txt |
Q:
Python / Javascript -- integer bitwise exclusive or problem
I'm proficient with both languages... but I'm having problems with the integer bitwise exclusive or logical operator. In javascript, it gives me one result, in python it gives me another..
Go ahead, open python and execute (-5270299) ^ 2825379669
Now wi... | Python / Javascript -- integer bitwise exclusive or problem | I'm proficient with both languages... but I'm having problems with the integer bitwise exclusive or logical operator. In javascript, it gives me one result, in python it gives me another..
Go ahead, open python and execute (-5270299) ^ 2825379669
Now with javascript, do the same calculation, and alert the result or w... | [
"JavaScript's integers are 32-bit whereas Python automatically converts to the unlimited length long format when values exceed 32 bits. If you explicitly force Python not to sign extend past 32 bits, or if you truncate the result to 32 bits, then the results are the same:\n>>> (-5270299 & 0xFFFFFFFF) ^ 2825379669\n... | [
9,
2,
0
] | [] | [] | [
"bit_manipulation",
"integer",
"javascript",
"python",
"xor"
] | stackoverflow_0004503896_bit_manipulation_integer_javascript_python_xor.txt |
Q:
Python Optparse from Argument String
Typically one may simply call optparse's method parse_args without any arguments. If, however, one needs to supply a different argument set than that of sys.argv, if may be passed to parse_args.
But what does one do if one needs to pass a string, not a list to parse_args?
I re... | Python Optparse from Argument String | Typically one may simply call optparse's method parse_args without any arguments. If, however, one needs to supply a different argument set than that of sys.argv, if may be passed to parse_args.
But what does one do if one needs to pass a string, not a list to parse_args?
I really need a function that does this:
>>> a... | [
"This is what the shlex module is for (well, it's one thing that it's for...):\n>>> import shlex\n>>> argument_string = \"-a arga -b \\\"argument b\\\" arg1 arg2\"\n>>> l = shlex.split(argument_string)\n>>> l\n['-a', 'arga', '-b', 'argument b', 'arg1', 'arg2']\n\n",
"Use the shlex module for this:\n>>> import shl... | [
5,
4
] | [] | [] | [
"command_line_arguments",
"python"
] | stackoverflow_0004504025_command_line_arguments_python.txt |
Q:
Trying to use lxml to return the text inside of the tags
I am trying to use lxml to return the text inside of the tags <ImageSet><LargeImage><URL>this text</URL></LargeImage></ImageSet> my code only returns None for the text under each tag.
Here is my code:
# I am trying to get the URL text using lxml
for attr_l... | Trying to use lxml to return the text inside of the tags | I am trying to use lxml to return the text inside of the tags <ImageSet><LargeImage><URL>this text</URL></LargeImage></ImageSet> my code only returns None for the text under each tag.
Here is my code:
# I am trying to get the URL text using lxml
for attr_list in tree.iterfind(".//"+settings.AMAZON_NS+"ImageSet"):
... | [
"from cStringIO import StringIO\nfrom lxml import etree\n\nURL_TAG = \"{http://webservices.amazon.com/AWSECommerceService/2009-10-01}URL\"\n\ntree = etree.fromstring(body)\nprint tree.findtext(\".//%s\" % (URL_TAG,)) # 1st way\n\nfor ev, el in etree.iterparse(StringIO(body), tag=URL_TAG): # 2nd approach\n print ... | [
1,
0
] | [] | [] | [
"lxml",
"python",
"xml"
] | stackoverflow_0004502976_lxml_python_xml.txt |
Q:
how to create a SSL Secure Connection using django
I want to send data using ssl for data network Security when sending data ,
but how to make a ssl Secure Connection using django ,
thanks
A:
SSL is not a django question.
SSL for a website is done on the web server, not your application, so you'd be setting u... | how to create a SSL Secure Connection using django | I want to send data using ssl for data network Security when sending data ,
but how to make a ssl Secure Connection using django ,
thanks
| [
"SSL is not a django question.\nSSL for a website is done on the web server, not your application, so you'd be setting up SSL in Apache or Nginx. Is that what you're looking to do?\nIf you mean you want to send data to some server via an SSL from within django, then it's a Python question about making SSL connectio... | [
3
] | [] | [] | [
"django",
"python",
"ssl"
] | stackoverflow_0004486173_django_python_ssl.txt |
Q:
How to get attributes from parent?
Let's say we have these classes:
class Foo(object):
_bar = ""
def __init__(self):
self.bar = "hello"
def getBar(self):
return self._bar
def setBar(self, bar):
self._bar = bar
def getAttributes(self):
for attr in self.__dict_... | How to get attributes from parent? | Let's say we have these classes:
class Foo(object):
_bar = ""
def __init__(self):
self.bar = "hello"
def getBar(self):
return self._bar
def setBar(self, bar):
self._bar = bar
def getAttributes(self):
for attr in self.__dict__:
print attr
bar = pro... | [
"You can't. Python stores all object attributes in the same place \"on the object\"; it does not break them out into separate storage areas, one per class in the inheritance hierarchy. The best you could do would be to keep a list of attributes that belonged to each level, maybe by having a __slots__ = [] declarati... | [
4,
2,
2,
0
] | [] | [] | [
"python"
] | stackoverflow_0004502141_python.txt |
Q:
Distributing a Python Software for Linux
I am writing my first software in Python for Ubuntu (or Debian based Linux). I am looking for a good advise on the best way to distribute my software.
The easist alternative that I can think of at the moment is to archive the python code into *.tar.gz, and let user execute... | Distributing a Python Software for Linux | I am writing my first software in Python for Ubuntu (or Debian based Linux). I am looking for a good advise on the best way to distribute my software.
The easist alternative that I can think of at the moment is to archive the python code into *.tar.gz, and let user execute the main python script as an executable to r... | [
"Just sending them the source in a tarball is perfectly fine. You could also put it up on http://pypi.python.org/pypi. How else were you thinking? There are lots of ways of doing it really. Jut distributing source is probably the easiest.\n"
] | [
3
] | [
"Here. This is the official, distribution-agnostic way to package and distribute a python program. Use this one, you'll have to learn it anyway one day.\nHere, instead, is a cheap and dirty hack:\n\nMake a directory /programname/;\nPut your whole project folder in a subdirectory /program/;\nPut a file programname.s... | [
-3
] | [
"packaging",
"python",
"ubuntu"
] | stackoverflow_0004504270_packaging_python_ubuntu.txt |
Q:
Create and parse multipart HTTP requests in Python
I'm trying to write some python code which can create multipart mime http requests in the client, and then appropriately interpret then on the server. I have, I think, partially succeeded on the client end with this:
from email.mime.multipart import MIMEMultipart... | Create and parse multipart HTTP requests in Python | I'm trying to write some python code which can create multipart mime http requests in the client, and then appropriately interpret then on the server. I have, I think, partially succeeded on the client end with this:
from email.mime.multipart import MIMEMultipart, MIMEBase
import httplib
h1 = httplib.HTTPConnection('l... | [
"I used this package by Will Holcomb http://pypi.python.org/pypi/MultipartPostHandler/0.1.0 to make multi-part requests with urllib2, it may help you out.\n",
"After a bit of exploration, the answer to this question has become clear. The short answer is that although the Content-Disposition is optional in a Mime... | [
1,
1
] | [
"There is a number of things wrong with your request. As TokenMacGuy suggests, multipart/mixed is unused in HTTP; use multipart/form-data instead. In addition, parts should have a Content-disposition header. A python fragment to do that can be found in the Code Recipes.\n"
] | [
-1
] | [
"http",
"mime",
"multipart",
"python"
] | stackoverflow_0004434170_http_mime_multipart_python.txt |
Q:
How to pass hex value in uri?
Not sure if this can be done or if there is a good workaround. But I have guids (hex values) to objects in Freebase, and I need to pass those values using GET to fetch the object from Freebase and mash it with some data I have stored in my app.
So the url looks like http://foo.com/ob... | How to pass hex value in uri? | Not sure if this can be done or if there is a good workaround. But I have guids (hex values) to objects in Freebase, and I need to pass those values using GET to fetch the object from Freebase and mash it with some data I have stored in my app.
So the url looks like http://foo.com/object-category/#9202a8c04000641f8000... | [
"The fragment is never sent to the server. It needs to be processed on the client side, in JavaScript.\n"
] | [
3
] | [] | [] | [
"freebase",
"google_app_engine",
"hex",
"httpwebrequest",
"python"
] | stackoverflow_0004504420_freebase_google_app_engine_hex_httpwebrequest_python.txt |
Q:
Controling button/hbox sizes in gtk
I am writing an app in python using getk and I've come across a problem. I am using an hbox to hold the buttons that go on my tool bar (new, open, save, etc) but the hbox seems to be expanding to take up a particular portion of the screen and the buttons are doing so as well mak... | Controling button/hbox sizes in gtk | I am writing an app in python using getk and I've come across a problem. I am using an hbox to hold the buttons that go on my tool bar (new, open, save, etc) but the hbox seems to be expanding to take up a particular portion of the screen and the buttons are doing so as well making them really tall and ugly. How do I g... | [
"You need to contain the entire HBox in a VBox, as follows:\nmain = gtk.VBox(False)\n...\nmain.pack_start(self.hbox4, False)\n\nThe reason for this is that gtk allows for window resizing, so it doesn't allocate fixed heights and widths. By using a VBox, you are telling Gtk that I want the HBox to take up just as mu... | [
3,
0
] | [] | [] | [
"gtk",
"python"
] | stackoverflow_0004436085_gtk_python.txt |
Q:
How to open an audio data
I have a m4a file, and i want to open it...what should i do? i've tried the obvious
>>> q = open('file.m4a').read()
>>> len(q)
6989886
>>> print q[:10000]
>>>
It prints a blank line! i've tried to open the file with 'rb' flag but it doesn't work.
A:
Python Audio Tools ?
A:
Try prin... | How to open an audio data | I have a m4a file, and i want to open it...what should i do? i've tried the obvious
>>> q = open('file.m4a').read()
>>> len(q)
6989886
>>> print q[:10000]
>>>
It prints a blank line! i've tried to open the file with 'rb' flag but it doesn't work.
| [
"Python Audio Tools ?\n",
"Try printing the repr() of the data:\n>>> print repr(q[:10000])\n\nIf you print the data itself, it may contain control character or other unprintable text, which makes for misleading output. The Python repr() function makes that data readable by escaping the characters as needed.\nIn t... | [
2,
2
] | [] | [] | [
"audio",
"m4a",
"python"
] | stackoverflow_0004504467_audio_m4a_python.txt |
Q:
find Key for value in python when key associated with multiple values
For a dictionary of the type
{'key1': ['v1','v2','v3', ...],
'key2': ['v2','v4', ...],
... }
How do I
Find any key associated with a value v
Print that k:[value set] pair to a new dictionary
A:
# answer to 1st question
keys_with_value = [... | find Key for value in python when key associated with multiple values | For a dictionary of the type
{'key1': ['v1','v2','v3', ...],
'key2': ['v2','v4', ...],
... }
How do I
Find any key associated with a value v
Print that k:[value set] pair to a new dictionary
| [
"# answer to 1st question\nkeys_with_value = [k for k, v in old_dict.iteritems() if \"whatever_value\" in v]\n\n# answer to 2nd question\nnew_dict = {} \nfor k in keys_with_value:\n new_dict[k] = old_dict[k]\n\nExample:\n>>> old_dict = {'key1':['v1','v2','v3'], 'key2':['v2','v4']}\n>>> keys_with_value = [k for ... | [
1,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0004504258_python.txt |
Q:
How to get property from ReferenceProperty class when downloading App Engine data using bulkloader?
I want to download my App Engine data so I can operate on it efficiently locally (I'm generating some PDFs based on it). How can I define that the column for a ReferenceProperty gets populated by a particular proper... | How to get property from ReferenceProperty class when downloading App Engine data using bulkloader? | I want to download my App Engine data so I can operate on it efficiently locally (I'm generating some PDFs based on it). How can I define that the column for a ReferenceProperty gets populated by a particular property of the referenced model rather than just the key or id?
Here are my model classes:
class Department(d... | [
"Create a file uploadutil.py and add this method in it:\ndef prop_converter(dept):\n # load the department then return the property you want\n return dept.name\n\nThen add this in bulkloader.yaml:\nAdd import for uploadutil:\nimport: uploadutil\n\nAnd add property:\n- property: dept\n external_name: dept\n ... | [
1
] | [] | [] | [
"bulkloader",
"google_app_engine",
"python"
] | stackoverflow_0004495223_bulkloader_google_app_engine_python.txt |
Q:
sorting lists of list to get unique ids for last column
I have this data saved in a file:
['5',60680,60854,'gene_id "ENS1"']
['5',59106,89211,'gene_id "ENS1"']
['5',58686,58765,'gene_id "ENS1"']
['5',80835,93381,'gene_id "ENS2"']
['5',55555,92223,'gene_id "ENS2"']
['5',73902,74276,'gene_id "ENS2"']
I need help wi... | sorting lists of list to get unique ids for last column | I have this data saved in a file:
['5',60680,60854,'gene_id "ENS1"']
['5',59106,89211,'gene_id "ENS1"']
['5',58686,58765,'gene_id "ENS1"']
['5',80835,93381,'gene_id "ENS2"']
['5',55555,92223,'gene_id "ENS2"']
['5',73902,74276,'gene_id "ENS2"']
I need help with python to get an output which ensures that items in the 4t... | [
">>> from itertools import groupby\n>>> for i, j in groupby(lst, key=lambda x: x[3]):\n t = list(zip(*j))\n print(t[0][0], min(t[1]), max(t[2]), t[3][0])\n\n\n5 58686 89211 gene_id \"ENS1\"\n5 55555 93381 gene_id \"ENS2\"\n\nIt's not clear, what do you mean by getting rid of [], these are just syntax for pyth... | [
0,
0
] | [] | [] | [
"list",
"python"
] | stackoverflow_0004504510_list_python.txt |
Q:
check if a list contains 4 elements of the same value
So I'm stuck on a newbie problem once more :D
I'm trying to mash together a text based game of go-fish against the computer.
Ok so 1 card is actually a tuple of elements from two lists.
suits = ['Clubs', 'Diamonds', 'Spade', 'Hearts']
ranks = [None, 'ace', '2',... | check if a list contains 4 elements of the same value | So I'm stuck on a newbie problem once more :D
I'm trying to mash together a text based game of go-fish against the computer.
Ok so 1 card is actually a tuple of elements from two lists.
suits = ['Clubs', 'Diamonds', 'Spade', 'Hearts']
ranks = [None, 'ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'jack', 'queen', ... | [
"I might suggest a slight refactoring: Represent each card in a hand as a tuple of (rank, suit). So your example hand would be:\nhand = [('2', 'Clubs'),\n ('king', 'Diamonds'),\n ('2', 'Diamonds'),\n ('2', 'Spades'),\n ('2', 'Hearts')]\n\nThen I'd suggest a couple of auxiliary function... | [
4,
1,
0,
0,
0
] | [] | [] | [
"list_comparison",
"python"
] | stackoverflow_0004504273_list_comparison_python.txt |
Q:
Trouble Loading scipy through PyXLL - Has Anyone Succeeded in Loading Scipy via PyXLL?
I am using Python 2.6, Excel 2007 Professional and the latest version of PyXLL. When loading a module in PyXLL that has
import scipy
An exception is thrown and the module is not loaded. Has anyone been able to load Scipy in PyX... | Trouble Loading scipy through PyXLL - Has Anyone Succeeded in Loading Scipy via PyXLL? | I am using Python 2.6, Excel 2007 Professional and the latest version of PyXLL. When loading a module in PyXLL that has
import scipy
An exception is thrown and the module is not loaded. Has anyone been able to load Scipy in PyXLL? Could it be a versioning problem? The exception thrown is:
2010-12-21 17:21:30,915 - ERR... | [
"I suspect this is because you are using the Enthought distribution of NumPy. The current version available has a problem that means it cannot be embedded in Excel.\nTo fix this, you need to remove the manifest resources from the numpy pyd files using cff explorer or any other PE editor.\nEnthought are aware of thi... | [
7
] | [] | [] | [
"excel",
"python",
"pyxll",
"scipy"
] | stackoverflow_0004504769_excel_python_pyxll_scipy.txt |
Q:
AppEngine GeoPt Data Upload
I'm writing a GAE app in Java and only using Python for the data
upload. I'm trying to import a CSV file that looks like this:
POSTAL_CODE_ID,PostalCode,City,Province,ProvinceCode,CityType,Latitude,Longitude
1,A0E2Z0,Monkstown,Newfoundland,NL,D,47.150300000000001,-55.299500000000002
I ... | AppEngine GeoPt Data Upload | I'm writing a GAE app in Java and only using Python for the data
upload. I'm trying to import a CSV file that looks like this:
POSTAL_CODE_ID,PostalCode,City,Province,ProvinceCode,CityType,Latitude,Longitude
1,A0E2Z0,Monkstown,Newfoundland,NL,D,47.150300000000001,-55.299500000000002
I was able to import this file in m... | [
"Ok, I got my answer from Google Groups (thanks Takashi Matsuo and Mike Armstrong). The solution is to modify my CSV file and combine lat and lng in a double-quoted string. The comma within the double-quoted string will not be counted as a CSV delimiter.\nPOSTAL_CODE_ID,PostalCode,City,Province,ProvinceCode,CityTyp... | [
3,
0,
0,
0,
0
] | [] | [] | [
"csv",
"google_app_engine",
"python",
"upload"
] | stackoverflow_0001588633_csv_google_app_engine_python_upload.txt |
Q:
How do I parse uri?
For the uri http://foo.com/apple/123
I want to get '123'.
According to the GAE documentation I can get the uri using self.request.get(), however is there a helper for just grabbing the sections of the uri?
A:
Yes there is - the urlparse module that comes with Python. The ParseResult that you... | How do I parse uri? | For the uri http://foo.com/apple/123
I want to get '123'.
According to the GAE documentation I can get the uri using self.request.get(), however is there a helper for just grabbing the sections of the uri?
| [
"Yes there is - the urlparse module that comes with Python. The ParseResult that you get back will strip off the host/protocol and such in a nice way, and then you can just use str's split() to split on the path separator.\n",
"If you're using webapp, you can 'capture' parts of the regular expression that matche... | [
5,
4
] | [] | [] | [
"google_app_engine",
"httpwebrequest",
"python"
] | stackoverflow_0004503183_google_app_engine_httpwebrequest_python.txt |
Q:
Shared configuration file format between python and C?
I'm looking to implement a shared configuration file that will be written (output) in python, but be read (input) in C.
The only prerequisite of this configuration file is that it can't be human readable.
Anyone have any suggestions on what file format I shoul... | Shared configuration file format between python and C? | I'm looking to implement a shared configuration file that will be written (output) in python, but be read (input) in C.
The only prerequisite of this configuration file is that it can't be human readable.
Anyone have any suggestions on what file format I should use for this project?
Edit: The file can't be human reada... | [
"How secure do you need this config file to be?\nThere is no absolute security, you'll quickly run into DRM like issues (allow users to open a file but not allow them to open it ... I know it's insane).\nOften simple obfuscation is quite effective. Dump the config to a JSON file (please don't use xml). XOR the co... | [
2,
1,
1,
0
] | [] | [] | [
"c",
"c++",
"configuration_files",
"python"
] | stackoverflow_0004504470_c_c++_configuration_files_python.txt |
Q:
Some problem with postgres_psycopg2
Last night I upgraded my machine to Ubuntu 10.04 from 9.10.
It seems to have cluttered my python module. Whenever I run python manage.py I get this error:
ImportError: No module named postgresql_psycopg2.base
Can any one throw any light on this?
A:
Couple of things. I ran i... | Some problem with postgres_psycopg2 | Last night I upgraded my machine to Ubuntu 10.04 from 9.10.
It seems to have cluttered my python module. Whenever I run python manage.py I get this error:
ImportError: No module named postgresql_psycopg2.base
Can any one throw any light on this?
| [
"Couple of things. I ran into the same kind of error - but for a different thing (ie. \"ImportError: No module named django\") when I reinstalled some software. Essentially, it messed up my Python paths.\nSo, you're issue is very reminiscent of the one I had. The issue for me ended up being that the installed I us... | [
1,
0
] | [] | [] | [
"django",
"postgresql",
"psycopg2",
"python"
] | stackoverflow_0002711737_django_postgresql_psycopg2_python.txt |
Q:
Will this make changes to "request", in Django?
# in views.py
def start(request):
initial_dictionary = {"abc":"abc"}
request.session['123'] = "xyz"
return initial_dictionary
def post(request):
dictionary = start(request)
return render_to_response("blah")
This is OOP. Will this make changes ... | Will this make changes to "request", in Django? | # in views.py
def start(request):
initial_dictionary = {"abc":"abc"}
request.session['123'] = "xyz"
return initial_dictionary
def post(request):
dictionary = start(request)
return render_to_response("blah")
This is OOP. Will this make changes to "request", and will the session be set? (request ... | [
"The session object comes from the HttpRequest, so if that's what gets passed into the function as request then what you have should work.\n"
] | [
1
] | [] | [] | [
"django",
"oop",
"python"
] | stackoverflow_0004505599_django_oop_python.txt |
Q:
how to show all of user's properties in django
this is my code :
def callback(req):
token = req.session.get('token', None)
if not token:
return render_to_response('callback.html', {
'token': True
})
token = oauth.OAuthToken.from_string(token)
if token.key != req.GET.get('oauth_token', 'no-token'):
re... | how to show all of user's properties in django | this is my code :
def callback(req):
token = req.session.get('token', None)
if not token:
return render_to_response('callback.html', {
'token': True
})
token = oauth.OAuthToken.from_string(token)
if token.key != req.GET.get('oauth_token', 'no-token'):
return render_to_response('callback.html', {
'mismat... | [
"You should troubleshoot by using a for loop and finding out where the problem is!\nI looped through the User object, and found it doesn't like getattr(user, '_base_manager') or getattr(user, 'objects')\nDo you just want the fields, or really all of the python code associated with the user object? \nIf you just wan... | [
1,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0004487666_django_python.txt |
Q:
How can I restore my default python install on OSX?
I'm trying to install pyobjc (using pyobjc-1.2-python2.3-macosx10.2.dmg) on a Mac running OSX 10.6 and I get the following error message:
To use Python 2.3 I tried re-editing my .bash_profile and I commented out everything with the exception of this line:
# chan... | How can I restore my default python install on OSX? | I'm trying to install pyobjc (using pyobjc-1.2-python2.3-macosx10.2.dmg) on a Mac running OSX 10.6 and I get the following error message:
To use Python 2.3 I tried re-editing my .bash_profile and I commented out everything with the exception of this line:
# change python version
defaults write com.apple.versioner.pyt... | [
"That version of PyObjC is very old. It may not even run on Mac OS X 10.6. Further, Apple doesn't ship a full python2.3 with OS X 10.6. The Apple-supplied Python 2.6 (/usr/bin/python2.6) already has PyObjC installed. If you need an even newer version, installer the latest Python 2.6 (or Python 2.7) using a OS X... | [
1
] | [] | [] | [
"macos",
"osx_snow_leopard",
"pyobjc",
"python"
] | stackoverflow_0004505884_macos_osx_snow_leopard_pyobjc_python.txt |
Q:
50 million+ Rows of Data - CSV or MySQL
I have a CSV file which is about 1GB big and contains about 50million rows of data, I am wondering is it better to keep it as a CSV file or store it as some form of a database. I don't know a great deal about MySQL to argue for why I should use it or another database framewo... | 50 million+ Rows of Data - CSV or MySQL | I have a CSV file which is about 1GB big and contains about 50million rows of data, I am wondering is it better to keep it as a CSV file or store it as some form of a database. I don't know a great deal about MySQL to argue for why I should use it or another database framework over just keeping it as a CSV file. I am b... | [
"I would say that there are a wide variety of benefits to using a database over a CSV for such large structured data so I would suggest that you learn enough to do so. However, based on your description you might want to check out non-server/lighter weight databases. Such as SQLite, or something similar to JavaDB/D... | [
3,
2,
1,
1,
0
] | [] | [] | [
"csv",
"database",
"mysql",
"optimization",
"python"
] | stackoverflow_0004505170_csv_database_mysql_optimization_python.txt |
Q:
Full-text search on App Engine with Whoosh
I need to do full text searching with Google App Engine. I found the project Whoosh and it works really well, as long as I use the App Engine Development Environement... When I upload my application to App Engine, I am getting the following TraceBack. For my tests, I am u... | Full-text search on App Engine with Whoosh | I need to do full text searching with Google App Engine. I found the project Whoosh and it works really well, as long as I use the App Engine Development Environement... When I upload my application to App Engine, I am getting the following TraceBack. For my tests, I am using the example application provided in this pr... | [
"You could probably solve your problems by downloading and using Whoosh-Appengine, the Whoosh version that's specifically targeted to working with Google App Engine.\n",
"This is an official example about implementing full text search: http://code.google.com/p/guestbook-example-appengine-full-text-search/\nI'm cu... | [
7,
4,
3,
1
] | [] | [] | [
"full_text_search",
"google_app_engine",
"python",
"whoosh"
] | stackoverflow_0001028992_full_text_search_google_app_engine_python_whoosh.txt |
Q:
Python Ctypes weird behavior
I am trying to design a bot for an application called Virtual Paradise and the SDK that is given for building the bot is compiled into a shared library, therefore I have to use ctypes.
when I use
import threading
...
from ctypes import CDLL, CFUNCTYPE, c_char_p, c_int, c_void_p
vp = CD... | Python Ctypes weird behavior | I am trying to design a bot for an application called Virtual Paradise and the SDK that is given for building the bot is compiled into a shared library, therefore I have to use ctypes.
when I use
import threading
...
from ctypes import CDLL, CFUNCTYPE, c_char_p, c_int, c_void_p
vp = CDLL("libvpsdk.so")
vp.vp_string.res... | [
"You must maintain a reference to the wrapped function for the lifetime it may be called. See the Important note... at the end of 15.16.1.17. Callback functions in the Python ctypes documentation.\nOne way is to use self.event_chat_func instead, storing it for the lifetime of the containing object.\nAlso, creating... | [
3
] | [] | [] | [
"ctypes",
"python"
] | stackoverflow_0004505839_ctypes_python.txt |
Q:
How to make zebra table with Sphinx? Or how to use jQuery with Sphinx?
I think the table generated from Sphinx is not pretty, as it produces the following HTML code for table.
<table border="1" class="docutils">
<colgroup>
<col width="43%" />
<col width="29%" />
<col width="29%" />
</colgroup>
<thead valign="botto... | How to make zebra table with Sphinx? Or how to use jQuery with Sphinx? | I think the table generated from Sphinx is not pretty, as it produces the following HTML code for table.
<table border="1" class="docutils">
<colgroup>
<col width="43%" />
<col width="29%" />
<col width="29%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Graph</th>
<th class="head">HIR</th>
<th class="hea... | [
"I add the doctools.js the following code\n$(document).ready(function() {\n Documentation.init();\n $('tbody tr:even').css('background-color','#dddddd');\n});\n\n"
] | [
0
] | [] | [] | [
"jquery",
"python",
"python_sphinx"
] | stackoverflow_0004504533_jquery_python_python_sphinx.txt |
Q:
UnicodeEncodeError in Mako Template
I have the following files
dummy.py
#!c:/Python27/python.exe -u
from mako import exceptions
from mako.template import Template
print "Content-type: text/html"
print
#VARIABLE = "WE"
VARIABLE = "我们"
template = Template(filename='../template/dummy.html', output_encoding='utf8'... | UnicodeEncodeError in Mako Template | I have the following files
dummy.py
#!c:/Python27/python.exe -u
from mako import exceptions
from mako.template import Template
print "Content-type: text/html"
print
#VARIABLE = "WE"
VARIABLE = "我们"
template = Template(filename='../template/dummy.html', output_encoding='utf8')
try:
print template.render(VARIABLE... | [
"template = Template(filename='../template/dummy.html', default_filters=['decode.utf8'], input_encoding='utf-8', output_encoding='utf-8')\n\n",
"Yes, because you are trying to render it to ASCII, which doesn't work. You need to say what output_encoding to use:\nTemplate(filename='../template/dummy.html', output_e... | [
6,
2
] | [] | [] | [
"mako",
"python"
] | stackoverflow_0004497515_mako_python.txt |
Q:
uploading file using urllib2
I'm new to python and I'm writing a code to upload a file using urllib2 but I can't make it work.
Here's the code:
class Get(object):
handlers = list()
def __init__(self,url):
self.url = url
self.request = urllib2.Request(url)
self.request.add_header('Us... | uploading file using urllib2 | I'm new to python and I'm writing a code to upload a file using urllib2 but I can't make it work.
Here's the code:
class Get(object):
handlers = list()
def __init__(self,url):
self.url = url
self.request = urllib2.Request(url)
self.request.add_header('User-Agent',"Mozilla/5.0 (X11; U; Li... | [
"Thanks MultipartPostHandler everything is working fine now.\nclass Post(Get): # inherits the Get class above\n def __init__(self,url,data,multipart=False):\n super(HTTP.Post,self).__init__(url)\n if multipart:\n from MultipartPostHandler import MultipartPostHandler\n self._ad... | [
2
] | [] | [] | [
"file_upload",
"python",
"urllib2"
] | stackoverflow_0004496691_file_upload_python_urllib2.txt |
Q:
Google App Engine: LinkProperty to string
An embarrisingly simple question, which makes it all the more frustrating: how do I turn a db.LinkProperty into a string on the google app engine.
Suppose I have the following model:
class MyModel(db.Model):
link = db.LinkProperty()
m = MyModel()
m.link = db.Link("http... | Google App Engine: LinkProperty to string | An embarrisingly simple question, which makes it all the more frustrating: how do I turn a db.LinkProperty into a string on the google app engine.
Suppose I have the following model:
class MyModel(db.Model):
link = db.LinkProperty()
m = MyModel()
m.link = db.Link("http://www.google.com/")
All I'd like to do is get... | [
"You don't need to set the property using db.Link, that should happen for you.\nThe following works for me though:\nclass Test(db.Model):\n link = db.LinkProperty()\n\nt = Test()\nt.link = 'http://google.com'\n\nprint str(t.link)\n\n"
] | [
3
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0004506447_google_app_engine_python.txt |
Q:
what does "*" mean in Python?
I came across with a line in python.
self.window.resize(*self.winsize)
What does the "*" mean in this line?
I haven't seen this in any python tutorial.
A:
One possibility is that self.winsize is list or tuple. The * operator unpacks the arguments out of a list or tuple.... | what does "*" mean in Python? | I came across with a line in python.
self.window.resize(*self.winsize)
What does the "*" mean in this line?
I haven't seen this in any python tutorial.
| [
"One possibility is that self.winsize is list or tuple. The * operator unpacks the arguments out of a list or tuple. \nSee : http://docs.python.org/tutorial/controlflow.html#unpacking-argument-lists\nAh: There is an SO discussion on this: Keyword argument in unpacking argument list/dict cases in Python\nAn example:... | [
8,
2,
2
] | [] | [] | [
"python"
] | stackoverflow_0004506388_python.txt |
Q:
Converting raw binary data into an image file?
I'm trying to read a field from an Active Directory entry which contains raw jpeg binary data. I'd like to read that data and convert it to an image file for use in my django-based application. I cannot for the life of me figure out how to handle this data in a nice w... | Converting raw binary data into an image file? | I'm trying to read a field from an Active Directory entry which contains raw jpeg binary data. I'd like to read that data and convert it to an image file for use in my django-based application. I cannot for the life of me figure out how to handle this data in a nice way. Any ideas?
Edit:
To anyone who might come across... | [
"Here is somebody who was having the same problem -- check out the latest post at the bottom.\nhttp://groups.google.com/group/django-users/browse_thread/thread/4214db6699863ded/5d816b02daca3186\nLooks like passing raw data to SimpleUploadedFile is what you are looking for. \nrequest._raw_post_data\n\nThe raw HTTP P... | [
1
] | [] | [] | [
"django",
"image_processing",
"python",
"python_imaging_library"
] | stackoverflow_0004506608_django_image_processing_python_python_imaging_library.txt |
Q:
Any way to pass an image loaded from PIL to a C++ function using Boost.Python?
I'm trying to make a wrapper to use a C++ Class in Python but I can't find a way to pass this image I already loaded in my Python program.
I could pass the path to the image and load it inside the C++ function again but that's not the s... | Any way to pass an image loaded from PIL to a C++ function using Boost.Python? | I'm trying to make a wrapper to use a C++ Class in Python but I can't find a way to pass this image I already loaded in my Python program.
I could pass the path to the image and load it inside the C++ function again but that's not the solution I want.
| [
"\"that's not the solution I want.\"\nWhy not?\nAnyway, the C++ will not understand the Image object. It is more likely that it does want just the raw image data. You can get that by calling the tostring() method on the image object, passing in a encoder and parameters.\nBut reading the file directly will be much f... | [
0
] | [] | [] | [
"boost",
"boost_python",
"c++",
"python",
"python_imaging_library"
] | stackoverflow_0004506659_boost_boost_python_c++_python_python_imaging_library.txt |
Q:
how to do this in Python (perl snippet to sort a 2D array)
I am trying to write this snippet in Python, to do a 2D array sort. Basically, I have an array of arrays, and I need to sort it by the second element first, then by the first
can anyone help out?
my @result = sort { $a->[0] <=> $b->[0] || $a->[1] <=> $b->... | how to do this in Python (perl snippet to sort a 2D array) | I am trying to write this snippet in Python, to do a 2D array sort. Basically, I have an array of arrays, and I need to sort it by the second element first, then by the first
can anyone help out?
my @result = sort { $a->[0] <=> $b->[0] || $a->[1] <=> $b->[1] } @all
| [
"Like so:\nfrom operator import itemgetter\n\nall = [ [2,2],[2,1],[1,2],[1,1] ]\nresult = sorted(all, key=itemgetter(0,1))\n\n",
"def my_sort(a, b):\n\n return cmp(a[0], b[0]) or cmp(a[1], b[1]);\n\n\nAnArray = [ [3, 3], [2, 6], [2, 2], [0, 4], [0, 1] ];\n\nprint AnArray\nprint sorted(AnArray, cmp=my_sort)\n\n... | [
2,
0
] | [] | [] | [
"perl",
"python"
] | stackoverflow_0004507092_perl_python.txt |
Q:
Read data from specific memory address / reference to object
How can I read (and put into new variable) data stored at specific memory address?
For instance I know that:
<nfqueue.queue; proxy of <Swig Object of type 'queue *' at 0xabd2b00> >
And I want to have data stored at 0xabd2b00 in new variable so that I ... | Read data from specific memory address / reference to object | How can I read (and put into new variable) data stored at specific memory address?
For instance I know that:
<nfqueue.queue; proxy of <Swig Object of type 'queue *' at 0xabd2b00> >
And I want to have data stored at 0xabd2b00 in new variable so that I can work and use all functionalities of the object. Let's assume t... | [
"You can't - there is no way to read data from a specific address. If you don't have (or can't retrieve) a reference to the object you're interested in, you're out of luck.\nBesides, even if you could read data from a given address, that wouldn't help, since there would be no way for you to know which address to re... | [
4
] | [] | [] | [
"memory",
"python",
"reference"
] | stackoverflow_0004507496_memory_python_reference.txt |
Q:
What's the most efficient way to process massive amounts of data from a disk using python?
I was writing a simple python script to read from and reconstruct data from a failed RAID5 array that I've been unable to rebuild in any other way. My script is running but slowly. My original script ran at about 80MB/min.... | What's the most efficient way to process massive amounts of data from a disk using python? | I was writing a simple python script to read from and reconstruct data from a failed RAID5 array that I've been unable to rebuild in any other way. My script is running but slowly. My original script ran at about 80MB/min. I've since improved the script and it's running at 550MB/min but that still seems a bit low. ... | [
"\nmap(takexor, magicpotato) - This is probably better done with direct iteration, map isn't efficient if it needs to call other python code AFAIK, it needs to construct and destroy 16384 frame objects to perform the call, etc.\nUse the array module instead of struct\nIf it's still too slow compile it with cython a... | [
3,
0
] | [] | [] | [
"binary_data",
"hard_drive",
"optimization",
"python",
"raid"
] | stackoverflow_0004507545_binary_data_hard_drive_optimization_python_raid.txt |
Q:
Jabber bot - how to get the availability of contacts?
I need to set up a jabber bot, using python, that will send messages based on the online/offline availability of several contacts.
I've been looking into pyxmpp and xmpppy, but couldn't find any way (at least nothing straightforward) to check the status of a gi... | Jabber bot - how to get the availability of contacts? | I need to set up a jabber bot, using python, that will send messages based on the online/offline availability of several contacts.
I've been looking into pyxmpp and xmpppy, but couldn't find any way (at least nothing straightforward) to check the status of a given contact.
Any pointers on how to achieve this?
Ideally I... | [
"I don't think it is possible in the way you want it because the presence of contacts (which contains the information about their availability) is received asynchronously by the bot.\nYou will have to write a presence handler function and registered it with the connection. This function will get called whenever a p... | [
2,
0,
0
] | [] | [] | [
"bots",
"python",
"xmpp",
"xmpppy"
] | stackoverflow_0003890726_bots_python_xmpp_xmpppy.txt |
Q:
Simple continuously running XMPP client in python
I'm using python-xmpp to send jabber messages. Everything works fine except that every time I want to send messages (every 15 minutes) I need to reconnect to the jabber server, and in the meantime the sending client is offline and cannot receive messages.
So I wa... | Simple continuously running XMPP client in python | I'm using python-xmpp to send jabber messages. Everything works fine except that every time I want to send messages (every 15 minutes) I need to reconnect to the jabber server, and in the meantime the sending client is offline and cannot receive messages.
So I want to write a really simple, indefinitely running xmpp ... | [
"There is a good example on the homepage of xmpppy itself (which is another name for python-xmpp), which does almost what you want: xtalk.py\nIt is basically a console jabber-client, but shouldn't be hard to rewrite into bot you want.\nIt's always online and can send and receive messages. I don't see a need for mul... | [
2,
0
] | [] | [] | [
"python",
"xmpp"
] | stackoverflow_0004269441_python_xmpp.txt |
Q:
Friendly URL with get request form
i have this simple html form:
<form action="test/" method="get" accept-charset="utf-8">
<input type="text" name="first" value="" id="first">
<input type="text" name="second" value="" id="second">
<input type="text" name="third" value="" id="third">
<p><input typ... | Friendly URL with get request form | i have this simple html form:
<form action="test/" method="get" accept-charset="utf-8">
<input type="text" name="first" value="" id="first">
<input type="text" name="second" value="" id="second">
<input type="text" name="third" value="" id="third">
<p><input type="submit" value="Continue →"></p>
... | [
"Where the user ends up after filling out the form and clicking \"Continue\" depends on what you set the action attribute in your form tag to. You've currently set it to test/.\nIf you want them to end up at test/<first_val>/<second_val>/<third_val>/, then you can either use some JavaScript (per pythonFoo's answer)... | [
3,
2
] | [] | [] | [
"django",
"python"
] | stackoverflow_0004507890_django_python.txt |
Q:
Python assign function to dict value
I am trying to write a script that opens files based on dictionary values. For each key/value it opens a file based on that value's name and assigns that file to the name of the value (I think it's going wrong here). So far it opens the files for me, with the right names, so th... | Python assign function to dict value | I am trying to write a script that opens files based on dictionary values. For each key/value it opens a file based on that value's name and assigns that file to the name of the value (I think it's going wrong here). So far it opens the files for me, with the right names, so that works. However, I think the name I assi... | [
"I'd caution against reusing \"value\" in that first loop, for clarity and future bugs that might be introduced there. \nBut, the code you posted actually works, so obviously there's something else going on that we can't diagnose here. What you need to do is inspect the contents of filelist before you try to close ... | [
0,
0,
0,
0,
0,
0
] | [] | [] | [
"dictionary",
"function",
"python"
] | stackoverflow_0004508028_dictionary_function_python.txt |
Q:
passing large number of arguments to struct.pack
I am using struct.pack method which takes variable number of arguments. I want to convert a string to bytes. If a string is short (e.g. 'name') I can do it like:
bytes = struct.pack('4c','n','a','m','e')
But what to do when my string is 80 characters long?
I have ... | passing large number of arguments to struct.pack | I am using struct.pack method which takes variable number of arguments. I want to convert a string to bytes. If a string is short (e.g. 'name') I can do it like:
bytes = struct.pack('4c','n','a','m','e')
But what to do when my string is 80 characters long?
I have tried the format string 's', instead of '80c' for stru... | [
"That doesn't make much sense. Strings are already bytes in python 2.x; So you could just do:\nmy_string = 'I am some big string'\nmy_bytes = my_string\n\nOn python 3, strings are unicode objects by default. To get bytes you have to encode the string.\nmy_bytes = my_string.encode('utf-8')\n\nIf really you want to u... | [
1,
1
] | [] | [] | [
"python",
"struct"
] | stackoverflow_0004508272_python_struct.txt |
Q:
How to implement a python REPL that nicely handles asynchronous output?
I have a Python-based app that can accept a few commands in a simple read-eval-print-loop. I'm using raw_input('> ') to get the input. On Unix-based systems, I also import readline to make things behave a little better. All this is working fin... | How to implement a python REPL that nicely handles asynchronous output? | I have a Python-based app that can accept a few commands in a simple read-eval-print-loop. I'm using raw_input('> ') to get the input. On Unix-based systems, I also import readline to make things behave a little better. All this is working fine.
The problem is that there are asynchronous events coming in, and I'd like ... | [
"Maybe something like this will do the trick:\n#!/usr/bin/env python2.6\n\nfrom __future__ import print_function\n\nimport readline\nimport threading\n\nPROMPT = '> '\n\ndef interrupt():\n print() # Don't want to end up on the same line the user is typing on.\n print('Interrupting cow -- moo!')\n print(PRO... | [
8,
5,
2,
0
] | [
"It's kind of a non-answer, but I would look at IPython's code to see how they're doing it.\n",
"I think you have 2 basic options:\n\nSynchronize your output (i.e. block until it comes back)\nSeparate your input and your (asyncronous) output, perhaps in two separate columns.\n\n"
] | [
-1,
-1
] | [
"python",
"read_eval_print_loop",
"readline"
] | stackoverflow_0000437025_python_read_eval_print_loop_readline.txt |
Q:
Inserting values from for loop into sqlite using python?
is it possible to insert a series of values into a sqlite database ?? using for loop or any other method?
for i in range(100000, 100010):
cursor.execute("""insert into users values(%d, '', '02adcec2263d2127269fcd769c33f029', 1, 1, 0, 0, 0)"""... | Inserting values from for loop into sqlite using python? | is it possible to insert a series of values into a sqlite database ?? using for loop or any other method?
for i in range(100000, 100010):
cursor.execute("""insert into users values(%d, '', '02adcec2263d2127269fcd769c33f029', 1, 1, 0, 0, 0)""", i)
| [
"Yes. Just iterate over values you want to insert and run the sql command with values you want. But please don't use formatting for building sql command and rather use binding.\nI belive this line should a little different:\n'''insert into users values(%d, '', '02adcec2263d2127269fcd769c33f029', 1, 1, 0, 0,... | [
0
] | [] | [] | [
"python",
"sqlite"
] | stackoverflow_0004508647_python_sqlite.txt |
Q:
How important is it to use short names for Python packages and modules?
PEP 8 says that Python package and module names should be short, since some file systems will truncate long names. And I'm trying to follow Python conventions in a new project. But I really like long, descriptive names. So I'm wondering, how s... | How important is it to use short names for Python packages and modules? | PEP 8 says that Python package and module names should be short, since some file systems will truncate long names. And I'm trying to follow Python conventions in a new project. But I really like long, descriptive names. So I'm wondering, how short do names need to be to comply with PEP 8. And does anyone really worry a... | [
"If you need to make sure your code works on DOS, use 8 characters. :p\nOtherwise, it's a free world. But nobody likes to type insanely long strings. (See powershell = fail). So use your best judgement, and be reasonable.\n",
"The common Python platforms all support directory and file names of 32 characters or mo... | [
2,
1,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0004506008_python.txt |
Q:
Batch file downloading using Perl or any other language
I have pretty good knowledge in JS, HTML, CSS, C, C++ and C#. I have this website which offers question papers for us school students, but to download those we have to visit every page and it's too hard for us. There are about 150 files. So... ;)
The downlo... | Batch file downloading using Perl or any other language | I have pretty good knowledge in JS, HTML, CSS, C, C++ and C#. I have this website which offers question papers for us school students, but to download those we have to visit every page and it's too hard for us. There are about 150 files. So... ;)
The download links always look like this:
http://www.example.com/conten... | [
"That's how I usually do such things in bash:\nfor i in `seq 1 1000` ; do wget \"http://www.example.com/content/download_content.php?content_id=$i\" -O $i.html ; done\n\nUPDATE Since the URLs point to more than one file type, you could use the file command to identify the type of a downloaded file, and adjust the e... | [
3,
2,
1
] | [] | [] | [
"batch_file",
"download",
"perl",
"python"
] | stackoverflow_0004508261_batch_file_download_perl_python.txt |
Q:
difference between 2 pieces Python code
I'm doing an exercise as following:
# B. front_x
# Given a list of strings, return a list with the strings
# in sorted order, except group all the strings that begin with 'x' first.
# e.g. ['mix', 'xyz', 'apple', 'xanadu', 'aardvark'] yields
# ['xanadu', 'xyz', 'aardvark', '... | difference between 2 pieces Python code | I'm doing an exercise as following:
# B. front_x
# Given a list of strings, return a list with the strings
# in sorted order, except group all the strings that begin with 'x' first.
# e.g. ['mix', 'xyz', 'apple', 'xanadu', 'aardvark'] yields
# ['xanadu', 'xyz', 'aardvark', 'apple', 'mix']
# Hint: this can be done by ma... | [
"The problem is that you loop over the list and remove elements from it (modifying it):\nfor w in words:\n if w.startswith('x'):\n listX.append(w)\n words.remove(w)\n\nExample:\n>>> a = range(5)\n>>> for i in a:\n... a.remove(i)\n... \n>>> a\n[1, 3]\n\nThis code works as follows:\n\nGet first element,... | [
3,
1,
0,
0
] | [] | [] | [
"list",
"python"
] | stackoverflow_0004508478_list_python.txt |
Q:
python cgi.escape encoding question
I'm using cgi.escape for a Django project, to protect from XSS attacks.
The protection works well, and my escaped content appears well on browsers, BUT if I read the html it is something like this:
<p>Σε μαγικό ταξίδ&io... | python cgi.escape encoding question | I'm using cgi.escape for a Django project, to protect from XSS attacks.
The protection works well, and my escaped content appears well on browsers, BUT if I read the html it is something like this:
<p>Σε μαγικό ταξίδι με προ&omic... | [
"You could try html meta tags to insert keywords and other interesting searchable content.\n"
] | [
1
] | [] | [] | [
"escaping",
"python"
] | stackoverflow_0004509435_escaping_python.txt |
Q:
Variables and Django URLConf
I'm having trouble extracting a string from my URL. Here's what I've got.. it keeps 404ing.
urls.py:
urlpatterns = patterns('',
(r'^user/(?P<username>\w{0,50})/$', profile,),
)
views.py:
def profile(request, username):
...
return ...
See anything obvious? Nee... | Variables and Django URLConf | I'm having trouble extracting a string from my URL. Here's what I've got.. it keeps 404ing.
urls.py:
urlpatterns = patterns('',
(r'^user/(?P<username>\w{0,50})/$', profile,),
)
views.py:
def profile(request, username):
...
return ...
See anything obvious? Need more? Any help is appreciated.
| [
"I usually a /?$ at end of url pattern.\nIt is a common mistake and some browser add or not a trailing '/'.\n",
"Have you imported your views module at the top of your URL file?\nfrom views import profile\n\nurlpatterns = patterns('',\n (r'^user/(?P<username>\\w{0,50})/$', profile), \n # also removed traili... | [
0,
0
] | [] | [] | [
"django",
"python",
"regex",
"urlconf"
] | stackoverflow_0004466945_django_python_regex_urlconf.txt |
Q:
Dividing a string into list according to the format given
I have a string like "SAB_bARGS_D" . What I want is that the string gets divided into list of characters but whenever there is a _ sign the next character gets appended to the previous one.
So the answer to above should be ['S','A','B_b','A','R','G','S_D']
... | Dividing a string into list according to the format given | I have a string like "SAB_bARGS_D" . What I want is that the string gets divided into list of characters but whenever there is a _ sign the next character gets appended to the previous one.
So the answer to above should be ['S','A','B_b','A','R','G','S_D']
It can be done by using a for loop traversing through the list ... | [
"I know, I'll use regular expressions:\n>>> import re\n>>> pattern = \"[^_]_[^_]|[^_]\"\n>>> re.findall(pattern, \"SAB_bARGS_D\", re.IGNORECASE)\n['S', 'A', 'B_b', 'A', 'R', 'G', 'S_D']\n\nThe pattern tries to match 3 characters in a row - non-underscore, underscore, non-underscore - and, failing that, tries to mat... | [
5,
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0004509162_python.txt |
Q:
Python programming. Accessing Windows right click menu options
I'm hoping to automate a few tasks at work. One of them being combining and converting power point files to PDFs. I'm a bit of a newbie (I just finished Magus Heitland's Beginning Python), so I'm not entirely sure what I'm specifically asking.
On wind... | Python programming. Accessing Windows right click menu options | I'm hoping to automate a few tasks at work. One of them being combining and converting power point files to PDFs. I'm a bit of a newbie (I just finished Magus Heitland's Beginning Python), so I'm not entirely sure what I'm specifically asking.
On windows, one can select multiple files, right click, and select combine ... | [
"There is no easy answer to this question. In Windows, context menu entries are created by context menu shell extensions, which is a type of shell extension, which is a COM component registered with Windows Explorer. To invoke an arbitrary context menu entry on a group of files, following operations have to be perf... | [
3,
1,
1
] | [] | [] | [
"python",
"ui_automation"
] | stackoverflow_0004506894_python_ui_automation.txt |
Q:
Unicode in Python on Google App Engine
I need to make a POST request in which the data might be non-ascii (chinese, japanese characters).
I need to convert the input to unicode and encode with utf-8. Here's how I did it:
foo = unicode(self.request.get('foo'), 'utf-8') #convert to unicode
foo = foo.encode('utf-8') ... | Unicode in Python on Google App Engine | I need to make a POST request in which the data might be non-ascii (chinese, japanese characters).
I need to convert the input to unicode and encode with utf-8. Here's how I did it:
foo = unicode(self.request.get('foo'), 'utf-8') #convert to unicode
foo = foo.encode('utf-8') #encode with utf-8
dat... | [
"Unicode can't be decoded because it's already unicode.\nTry this instead:\nif isinstance(var, str):\n var = unicode(var, 'utf-8')\nelse:\n var = unicode(var)\n\n",
"Ok some comments:\n foo = unicode(self.request.get('foo'), 'utf-8') #convert to unicode\n\nDon't call it \"convert\". Call it \"decode\", it m... | [
7,
1
] | [] | [] | [
"google_app_engine",
"non_ascii_characters",
"python",
"unicode"
] | stackoverflow_0004509651_google_app_engine_non_ascii_characters_python_unicode.txt |
Q:
Python: urllib2 handle multiple openers
I have to keep 2 urllib2 openers, one for direct requests and the second to make requests via proxy server and I've to rebuild opener switch between requests.
How to keep context openers for example direct and proxy separately?
A:
I suspect your confusion stems from using... | Python: urllib2 handle multiple openers | I have to keep 2 urllib2 openers, one for direct requests and the second to make requests via proxy server and I've to rebuild opener switch between requests.
How to keep context openers for example direct and proxy separately?
| [
"I suspect your confusion stems from using install_opener and urllib2.urlopen. Instead, just call build_opener twice and store the results in separate objects. Then you can use the appropriate opener when needed.\nExample:\nimport urllib2\ndirect = urllib2.build_opener()\nproxy_handler = urllib2.ProxyHandler({'http... | [
6
] | [] | [] | [
"python",
"request",
"urllib",
"urllib2",
"webrequest"
] | stackoverflow_0004509596_python_request_urllib_urllib2_webrequest.txt |
Q:
Django, a problem about zip file response
I have a problem with sending request as attachments in django. My application writes some data to files and zips it. However, when i return an attachment response, the browser downloads it but the zip file is corrupted. (The original zip contains my files and doesn't give... | Django, a problem about zip file response | I have a problem with sending request as attachments in django. My application writes some data to files and zips it. However, when i return an attachment response, the browser downloads it but the zip file is corrupted. (The original zip contains my files and doesn't give any errors.)
My code is here:
file_pat... | [
"HttpResponse takes a string or an iterator returning strings (like an open file-like object). You are passing it the file path, so the response contains a file whose content is just the file path instead of the valid zip content you wrote to the file. You can just use open as the HTTPResponse object will close the... | [
12
] | [] | [] | [
"django",
"python",
"zip"
] | stackoverflow_0004510352_django_python_zip.txt |
Q:
Multiple imports of the same file name
I am trying to create a plugin system and I have a function that imports all the modules into an array.
Layout of Plugins:
pluginsDir/
pluginsDir/chat
pluginsDir/chat/main.py
And this is the function that finds and imports the plugins:
if os.path.exists(pluginsDir):
for... | Multiple imports of the same file name | I am trying to create a plugin system and I have a function that imports all the modules into an array.
Layout of Plugins:
pluginsDir/
pluginsDir/chat
pluginsDir/chat/main.py
And this is the function that finds and imports the plugins:
if os.path.exists(pluginsDir):
for path, dirArray, fileArray in os.walk(plugin... | [
"sys.path.append(path) will attach the plugin folder to the end of sys.path. Since Python searches folders in sys.path from front to back, appending additional paths to the end of the list will not be found because any main.py modules in folder specified earlier in sys.path will essentially hide modules in folders... | [
4,
2,
0
] | [] | [] | [
"import",
"plugins",
"python",
"system"
] | stackoverflow_0004510570_import_plugins_python_system.txt |
Q:
ugettext and ugettext_lazy
Could you explain what principal difference between ugettext and ugettext_lazy?
When I'm trying to
return HttpResponse(ugettext_lazy("Hello"))
I see nothing, but
return HttpResponse(ugettext("Hello"))
is working.
Why?
A:
ugettext is used to load a translation of a string right now. ... | ugettext and ugettext_lazy | Could you explain what principal difference between ugettext and ugettext_lazy?
When I'm trying to
return HttpResponse(ugettext_lazy("Hello"))
I see nothing, but
return HttpResponse(ugettext("Hello"))
is working.
Why?
| [
"ugettext is used to load a translation of a string right now. ugettext_lazy returns an object that can eventually be turned into a string. You need that if the ugettext_lazy call is evaluated before the proper locale has been set.\nugettext_lazy can be used where you use a Unicode object. Double-check your HTML... | [
43
] | [] | [] | [
"django",
"internationalization",
"python"
] | stackoverflow_0004510871_django_internationalization_python.txt |
Q:
Trouble scheduling and rescheduling posts with Celery
I'm working on a Django blog and I need to be able to schedule posts to publish at a later date. Celery works great for initially scheduling posts, but I run into problems when a user tries to update the post to either have it either reschedule or canceled ind... | Trouble scheduling and rescheduling posts with Celery | I'm working on a Django blog and I need to be able to schedule posts to publish at a later date. Celery works great for initially scheduling posts, but I run into problems when a user tries to update the post to either have it either reschedule or canceled indefinitely.
Here is what I am trying to do:
def save(self, *... | [
"I don't know what your tasks.py file looks like, but I assume it's something like the following:\nfrom celery.decorators import task\n\n@task\ndef publish_post(post_id):\n ''' Sets the status of a post to Published '''\n from blog.models import Post\n\n Post.objects.filter(pk=post_id).update(status=Post.S... | [
3
] | [] | [] | [
"celery",
"django",
"python"
] | stackoverflow_0004510355_celery_django_python.txt |
Q:
Distutils, older rpm, and customized spec file
I finally got my program packaged in a RPM on Fedora 14 yesterday, and I thought that it would be easy to build it the same way on a CentOS 4.8 box. It turns out that the older version of rpm and distutils are severally limited, and I'm not having any luck working aro... | Distutils, older rpm, and customized spec file | I finally got my program packaged in a RPM on Fedora 14 yesterday, and I thought that it would be easy to build it the same way on a CentOS 4.8 box. It turns out that the older version of rpm and distutils are severally limited, and I'm not having any luck working around it.
The basic problem is that distutils with Py... | [
"There isn't. Build the SRPM with rpmbuild -bs and then use Mock to build a package for EL4.\n"
] | [
1
] | [] | [] | [
"distutils",
"python",
"rpm",
"rpm_spec",
"rpmbuild"
] | stackoverflow_0004511750_distutils_python_rpm_rpm_spec_rpmbuild.txt |
Q:
download file with PAMIE
I want to use PAMIE to download a file. However, IE brings up that annoying "blocked this website from downloading" warning. Is there any way to automate bypassing that?
I want to do it this way because I need a programmatic way of browsing that retains cookies and stuff. If there is anot... | download file with PAMIE | I want to use PAMIE to download a file. However, IE brings up that annoying "blocked this website from downloading" warning. Is there any way to automate bypassing that?
I want to do it this way because I need a programmatic way of browsing that retains cookies and stuff. If there is another way to do that, that could... | [
"See this: http://support.microsoft.com/kb/883255. As far as I know, it still works. You could add your site to the Trusted Sites zone and disable the download prompt for that zone.\n"
] | [
0
] | [] | [] | [
"internet_explorer",
"pamie",
"python"
] | stackoverflow_0004511717_internet_explorer_pamie_python.txt |
Q:
Django get IP only returns 127.0.0.1
I have a webserver set up with gunicorn and nginx and django.
I am accessing it remotely, and with this:
def testIP(request):
ip_address = utils.get_ip(request)
I just keep getting an ip address of 127.0.0.1 Like i said I am accessing it remotely and thus it should not be... | Django get IP only returns 127.0.0.1 | I have a webserver set up with gunicorn and nginx and django.
I am accessing it remotely, and with this:
def testIP(request):
ip_address = utils.get_ip(request)
I just keep getting an ip address of 127.0.0.1 Like i said I am accessing it remotely and thus it should not be giving a local address.
I think it might... | [
"How does get_ip() work? \nIf nginx is a reverse proxy and gunicorn is the app server, it's always getting requests from nginx on the local machine.\nThe real ip that nginx sends to the app server is in my case HTTP_X_REAL_IP via the nginx conf line proxy_set_header X-Real-IP $remote_addr;\nSo you might want to set... | [
26
] | [] | [] | [
"django",
"nginx",
"python"
] | stackoverflow_0004512341_django_nginx_python.txt |
Q:
which databases can be used better for pyqt application
i want to create application in windows. i need to use databases which would be preferable best for pyqt application
like
sqlalchemy
mysql
etc.
A:
I would use SQLite every time unless performance became an obvious big problem.
It comes with Python
You don'... | which databases can be used better for pyqt application | i want to create application in windows. i need to use databases which would be preferable best for pyqt application
like
sqlalchemy
mysql
etc.
| [
"I would use SQLite every time unless performance became an obvious big problem.\n\nIt comes with Python\nYou don't need to worry about installing it on a target machine or having an existing installation which might clash (including a potential port clash - SQLite doesn't use a port)\nIt's fairly small (doesn't in... | [
2,
1,
1,
0
] | [] | [] | [
"database",
"pyqt",
"python"
] | stackoverflow_0004168020_database_pyqt_python.txt |
Q:
Popen is no able to process a command that runs in shell
I have already read the previous questions posted on the same argument but I really haven't figured it out yet.
I am trying to run a command that works without issues from the command line :
xyz@klm:~/python-remoteWorkspace/PyLogParser/src:18:43>ush -o PPP -... | Popen is no able to process a command that runs in shell | I have already read the previous questions posted on the same argument but I really haven't figured it out yet.
I am trying to run a command that works without issues from the command line :
xyz@klm:~/python-remoteWorkspace/PyLogParser/src:18:43>ush -o PPP -p PRD -n log 'pwd'
6:43PM PPP:prd:lgsprdppp:/ama/log/PRD/ppp
... | [
"Popen([\"ush\", \"-o\", \"PPP\", \"-p\", \"PRD\", \"-n\", \"log\", \"pwd\"])\n\nshould be right. The extra quoting around 'pwd' in the shell command makes it a single argument, but the quotes aren't actually passed along. Since you're already splitting the arguments, leave the extra quotes out.\n\nApparently (in... | [
2,
1
] | [] | [] | [
"popen",
"python",
"subprocess"
] | stackoverflow_0004512059_popen_python_subprocess.txt |
Q:
Latin to English alphabet hashing
I have to convert all the latin characters to their corresponding English alphabets. Can I use Python to do it? Or is there a mapping available?
Unicode values to non-unicode characters
Ramírez Sánchez should be converted to Ramirez Sanchez.
A:
It looks like what you want is a... | Latin to English alphabet hashing | I have to convert all the latin characters to their corresponding English alphabets. Can I use Python to do it? Or is there a mapping available?
Unicode values to non-unicode characters
Ramírez Sánchez should be converted to Ramirez Sanchez.
| [
"It looks like what you want is accent removal. You can do this with:\ndef strip_accents(text):\n return ''.join(char for char in\n unicodedata.normalize('NFKD', text)\n if unicodedata.category(char) != 'Mn')\n\n>>> strip_accents('áéíñóúü')\n'aeinouu'\n>>> strip_accents('Ramí... | [
11
] | [] | [] | [
"nlp",
"python"
] | stackoverflow_0004512590_nlp_python.txt |
Q:
Import from packages __init__
I got problem I'm not able to fix although I tried almost everything I know or could read somewhere else.
I got a package with this structure:
package/
__init__.py
file.py
file2.py
file3.py
subpackage/
__init__.py
submodule1.py
submodule2.py
Le... | Import from packages __init__ | I got problem I'm not able to fix although I tried almost everything I know or could read somewhere else.
I got a package with this structure:
package/
__init__.py
file.py
file2.py
file3.py
subpackage/
__init__.py
submodule1.py
submodule2.py
Lets say I have variable 'db' declare... | [
"Try from project_top.project import db oder better delete the __init__.py in the directory project_top because that doesn't look like that it is meant to be a package.\n",
"In general you should never put anything into your __init__.py files except perhaps for constants that do not depend on anything else being ... | [
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0004512480_python.txt |
Q:
python equivalent of java OutputStream?
Is there a Python equivalent / pseudo-equivalent to java's OutputStream or PrintWriter?
I want to be able to have a handle that represents either a stream like stdout/sterr, or a file, or something else (a pipe or a socket or a dummy sink) and abstract away what kind of thin... | python equivalent of java OutputStream? | Is there a Python equivalent / pseudo-equivalent to java's OutputStream or PrintWriter?
I want to be able to have a handle that represents either a stream like stdout/sterr, or a file, or something else (a pipe or a socket or a dummy sink) and abstract away what kind of thing it is, so I can just send output to it.
How... | [
"\"Abstracting away what type it is\" happens automatically in Python - it's called 'duck typing'. Just pass any file-like object to the function, and have it use the interface of file-like objects.\nFWIW, the standard input/output/error streams are represented by stdin, stdout and stderr in the sys module. To get ... | [
8,
3,
1
] | [] | [] | [
"abstraction",
"python"
] | stackoverflow_0004512733_abstraction_python.txt |
Q:
How do I disconnect my XMPPPY client object
Connecting to an XMPP server with XMPPPY is simple.
from xmpp.client import Client as XMPPClient
self.xmppClient = XMPPClient("jabber.foo.com")
if not self.xmppClient.connect(server="localhost"):
raise IOError('Cannot connect to server.')
if not self.xmppClient.auth... | How do I disconnect my XMPPPY client object | Connecting to an XMPP server with XMPPPY is simple.
from xmpp.client import Client as XMPPClient
self.xmppClient = XMPPClient("jabber.foo.com")
if not self.xmppClient.connect(server="localhost"):
raise IOError('Cannot connect to server.')
if not self.xmppClient.auth("node", "password", "resource"):
raise IOErr... | [
"Generally speaking, if you want to disconnect from an XMPP server, you'll send a Presence stanze with type='unavailable', like the following:\n<presence type='unavailable' />\n\nNote that Presence does NOT have a recipient address. Here's a link to XMPP's RFC in case you'd like to know more. (Section 5.1.5)\nAfter... | [
1,
1
] | [] | [] | [
"python",
"xmpp",
"xmpppy"
] | stackoverflow_0003835548_python_xmpp_xmpppy.txt |
Q:
python: TypeError: can't write str to text stream
I must be doing something obviously wrong here. But what is it, and how do I fix?
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import io
>>> f1 = io.... | python: TypeError: can't write str to text stream | I must be doing something obviously wrong here. But what is it, and how do I fix?
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import io
>>> f1 = io.open('test.txt','w')
>>> f1.write('bingo')
Traceback (m... | [
"The io module is a fairly new python module (introduced in Python 2.6) that makes working with unicode files easier. Its documentation is at: http://docs.python.org/library/io.html\nIf you just want to be writing bytes (Python 2's \"str\" type) as opposed to text (Python 2's \"unicode\" type), then I would recomm... | [
39,
13,
5,
4,
3
] | [] | [] | [
"io",
"python"
] | stackoverflow_0004512982_io_python.txt |
Q:
Accessing items from a dictionary using pickle efficiently in Python
I have a large dictionary mapping keys (which are strings) to objects. I pickled this large dictionary and at certain times I want to pull out only a handful of entries from it. The dictionary has usually thousands of entries total. When I load t... | Accessing items from a dictionary using pickle efficiently in Python | I have a large dictionary mapping keys (which are strings) to objects. I pickled this large dictionary and at certain times I want to pull out only a handful of entries from it. The dictionary has usually thousands of entries total. When I load the dictionary using pickle, as follows:
from cPickle import *
# my diction... | [
"Pickle serializes object (hierachies), it's not an on-disk store. As you have seen, you must unpickle the entire object to use it - which is of course wasteful. Use shelve, dbm or a database (SQLite) for on-disk storage.\n",
"You'll have to have \"Ghost\" objects, I.e. objects that are only placeholders and load... | [
3,
2,
0
] | [] | [] | [
"pickle",
"python"
] | stackoverflow_0004513059_pickle_python.txt |
Q:
How to re.search html source with regex in python
I bust my head but can not sort this out.
numbers, names are fictional. but the idea is like this
I read a link like 'https://graph.facebook.com/123'
this results to source code:
{
"id": "123",
"name": "John Doe",
"first_name": "John",
"last_name": "Doe... | How to re.search html source with regex in python | I bust my head but can not sort this out.
numbers, names are fictional. but the idea is like this
I read a link like 'https://graph.facebook.com/123'
this results to source code:
{
"id": "123",
"name": "John Doe",
"first_name": "John",
"last_name": "Doe",
"link": "http://www.facebook.com/people/John-Doe/... | [
"That seems JSON, you don't want to use regex to parse that.\nlink = 'https://graph.facebook.com/123'\nresult = browser.open(link)\ndata = json.load(result)\nprint data['id']\n\n"
] | [
7
] | [] | [] | [
"json",
"python",
"regex"
] | stackoverflow_0004513525_json_python_regex.txt |
Q:
simple output of xml from python
I need to output XML from python in a very minimalist way:
I can't use any external libraries beyond what's already in Python 2.6.5
I need to output XML tags, and text contents, with no attributes
At this point I'm using print statements to explicitly print out angle-bracket tags... | simple output of xml from python | I need to output XML from python in a very minimalist way:
I can't use any external libraries beyond what's already in Python 2.6.5
I need to output XML tags, and text contents, with no attributes
At this point I'm using print statements to explicitly print out angle-bracket tags, and the only thing really stopping m... | [
"Well, it looks like SAX isn't that hard to use after all. Here's an example.\nxmltest.py:\nimport xml.sax.xmlreader\nimport xml.sax.saxutils\n\ndef testJunk(file, e2content):\n attr0 = xml.sax.xmlreader.AttributesImpl({})\n x = xml.sax.saxutils.XMLGenerator(file)\n x.startDocument()\n x.startElement(\"documen... | [
4,
2,
2,
1
] | [] | [] | [
"python",
"xml"
] | stackoverflow_0004512085_python_xml.txt |
Q:
Python/postgres: Any advantage to converting mxDateTime to built in datetime objects?
Some code I am inheriting uses Python's psycopg2 module to return mxDateTime objects from Postgres database queries. I am guessing this behavior is for historical reasons, but wondering if there there is another explanation.
Give... | Python/postgres: Any advantage to converting mxDateTime to built in datetime objects? | Some code I am inheriting uses Python's psycopg2 module to return mxDateTime objects from Postgres database queries. I am guessing this behavior is for historical reasons, but wondering if there there is another explanation.
Given that I already have an mxDateTime dependency via the the large library I have inherited, ... | [
"There's big a reason to not change it that is not historical. Built in python timestamps are often only 32-bit.\nPostgresqls timestamp:\n\nmin value 4713 BC\nmax value: 5874897 AD\n\nhttp://www.postgresql.org/docs/current/static/datatype-datetime.html#DATATYPE-DATETIME-TABLE\nPython's: \n\nclassmethod date.fromtim... | [
2
] | [] | [] | [
"datetime",
"postgresql",
"psycopg2",
"python"
] | stackoverflow_0004505345_datetime_postgresql_psycopg2_python.txt |
Q:
Where to initialize Django session variables?
In my Django project I am building a shopping cart system. I want to store the shopping cart data in a session variable, but I don't know where to initialize it.
I have tried doing something like this:
if 'cart' not in request.session:
request.session['cart'] = {}... | Where to initialize Django session variables? | In my Django project I am building a shopping cart system. I want to store the shopping cart data in a session variable, but I don't know where to initialize it.
I have tried doing something like this:
if 'cart' not in request.session:
request.session['cart'] = {}
in a custom context processor, but the context pr... | [
"You could put it in a piece of custom request middleware, but to be honest, I think that would be overkill here. It's probably easier to just initialize the cart when you need it in your view function. Note that you can use request.session.get to automatically grab a default value if the value doesn't already exis... | [
5,
1,
0,
0
] | [] | [] | [
"django",
"python",
"session"
] | stackoverflow_0004513676_django_python_session.txt |
Q:
Geocoding libraries
I'm using python and I need to map locations like "Bloomington, IN" to GPS coordinates so I can measure distances between them.
What Geocoding libraries/APIs do you recommend? Solutions in other languages are also welcome.
A:
Geopy lets you choose from several geocoders (including Google, Yah... | Geocoding libraries | I'm using python and I need to map locations like "Bloomington, IN" to GPS coordinates so I can measure distances between them.
What Geocoding libraries/APIs do you recommend? Solutions in other languages are also welcome.
| [
"Geopy lets you choose from several geocoders (including Google, Yahoo, Virtual Earth).\n",
"The Google's web service is very easy to use. Just put the query in the URL. To make it even easier/lazier, I will shamelessly advertise pygeocoder, a Python wrapper for Google Geocoding. Then you can just do something li... | [
25,
9,
8,
3,
2,
0,
0,
0,
0
] | [] | [] | [
"api",
"geocoding",
"python",
"rest"
] | stackoverflow_0000373383_api_geocoding_python_rest.txt |
Q:
Collecting key/value pairs in Python 2.6
In Python 2.7, I'm used to collect key/value pairs from an array and return it as a hash:
return { u.id : u.name for u in users }
But it turns out it does not work in Python 2.6:
return { u.id : u.name for u in users }
^
SyntaxError: invalid sy... | Collecting key/value pairs in Python 2.6 | In Python 2.7, I'm used to collect key/value pairs from an array and return it as a hash:
return { u.id : u.name for u in users }
But it turns out it does not work in Python 2.6:
return { u.id : u.name for u in users }
^
SyntaxError: invalid syntax
How can I avoid doing something like thi... | [
"Just pass a generator expression that constructs a sequence of tuples to the constructor for dict\nreturn dict((u.id, u.name) for u in users)\n\nThis will create the same dictionary as the dictionary comprehension in later versions.\n",
"return dict((u.id, u.name) for u in users)\n\n",
"The dict constructor ta... | [
10,
1,
1
] | [] | [] | [
"dictionary",
"python",
"python_2.6"
] | stackoverflow_0004514162_dictionary_python_python_2.6.txt |
Q:
django ModelForm override field has no effect
I have a ForeignKey field in a model of mine, and I'm using ModelForm with it to generate the HTML. The thing is, I want to add an Other option as well - I plan to add JavaScript with it so that a textbook appears when that's selected.
I'm looking at http://docs.django... | django ModelForm override field has no effect | I have a ForeignKey field in a model of mine, and I'm using ModelForm with it to generate the HTML. The thing is, I want to add an Other option as well - I plan to add JavaScript with it so that a textbook appears when that's selected.
I'm looking at http://docs.djangoproject.com/en/1.2/topics/forms/modelforms/#overrid... | [
"I haven't used django-nonrel, so take this tip with a grain of salt (YMMV).\nIn your EventForm definition, you're setting cost to be a model.TextField - but you actually want it to be a forms.CharField, with a textarea widget.\n",
"Your problem is that EventForm is overriding cost with a models.TextField() when ... | [
2,
1,
0
] | [] | [] | [
"django",
"django_forms",
"python"
] | stackoverflow_0004514175_django_django_forms_python.txt |
Q:
Django Subdomain URL Dispatch
I have a Django project and I wanted to map a URL to handle subdomains. If there is a subdomain then it should call a function with the subdomain as a parameter. Is this possible? If not then what would be the best way to tell what the subdomain of a request is?
Thanks
A:
This is de... | Django Subdomain URL Dispatch | I have a Django project and I wanted to map a URL to handle subdomains. If there is a subdomain then it should call a function with the subdomain as a parameter. Is this possible? If not then what would be the best way to tell what the subdomain of a request is?
Thanks
| [
"This is definitely possible - you'll need to tweak your configuration files so that subdomain requests are sent to that URL instead of the root of your app, and then you should be good to go (use request.get_host() to retrieve the domain you're being called at).\n"
] | [
4
] | [] | [] | [
"django",
"django_urls",
"python",
"subdomain"
] | stackoverflow_0004514198_django_django_urls_python_subdomain.txt |
Q:
When trying to connect to a remote Oracle database with Django I get an odd error
I'm using Python 2.6 and Django 1.2.3 Final.
Whenever I try to run 'inspectdb' or any other action that would connect to this remote Oracle database, I get the following error:
Traceback (most recent call last):
File "manage.py", l... | When trying to connect to a remote Oracle database with Django I get an odd error | I'm using Python 2.6 and Django 1.2.3 Final.
Whenever I try to run 'inspectdb' or any other action that would connect to this remote Oracle database, I get the following error:
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/var/www/local/server-env/lib... | [
"In general, when you get a cryptic error message, Search The Fantastic Web. In this case, the software is sufficiently professionally organised as to have distinct error message numbers and an error message manual. All you need to do is google(\"ORA-12505\")\n",
"Most probably, you did a mistake in your settings... | [
2,
1
] | [] | [] | [
"django",
"oracle",
"python"
] | stackoverflow_0004513988_django_oracle_python.txt |
Q:
Dynamically loading python source code
I'm currently playing with Flask and I can't figure out how the debug mechanism is working. To be more precise when I save the python file with my application I don't need to restart the server, it will be loaded automatically when I make a request. So my question is how does... | Dynamically loading python source code | I'm currently playing with Flask and I can't figure out how the debug mechanism is working. To be more precise when I save the python file with my application I don't need to restart the server, it will be loaded automatically when I make a request. So my question is how does the running program know it was changed and... | [
"Flask is using Werkzug's underlying run_with_reloader function (found in serving.py) ... which is itself using the restart_with_reloader and reloader_loop function created earlier in the same file. \nrun_with_reloader spawns another python process (running Werkzug again with all the same arguments that you passed... | [
7,
0
] | [] | [] | [
"dynamic",
"flask",
"python"
] | stackoverflow_0004514095_dynamic_flask_python.txt |
Q:
Easiest way to reindent / tidy Python code in Coda?
Anyone have a clever way of quickly fixing indentation problems in Python documents in the Coda editor for Mac?
Some have said that reindent.py is the way to go, but it doesn't even ship with all versions of Python. Thoughts?
A:
You can get reindent.py from th... | Easiest way to reindent / tidy Python code in Coda? | Anyone have a clever way of quickly fixing indentation problems in Python documents in the Coda editor for Mac?
Some have said that reindent.py is the way to go, but it doesn't even ship with all versions of Python. Thoughts?
| [
"You can get reindent.py from the following link: http://svn.python.org/view/python/trunk/Tools/scripts/reindent.py?revision=66903&view=markup\n(Note: Original link from an old Alex Martelli comment whose reference I've lost.\n"
] | [
2
] | [] | [] | [
"coda",
"django",
"indentation",
"python",
"tidy"
] | stackoverflow_0004514360_coda_django_indentation_python_tidy.txt |
Q:
django 2 foreign keys from one model to another model
Is there a way to have 2 foreign keys in a model relate to the same model.In the example, I want to have 'date' and 'supervisor' from Timesheet both as foreign keys to DateTimesheet. What I am trying to accomplish is having Timesheet inline with DateTimesheet i... | django 2 foreign keys from one model to another model | Is there a way to have 2 foreign keys in a model relate to the same model.In the example, I want to have 'date' and 'supervisor' from Timesheet both as foreign keys to DateTimesheet. What I am trying to accomplish is having Timesheet inline with DateTimesheet in the admin and be able to enter date and supervisor once a... | [
"If you have to foreign keys on one model pointing to the same model you have to set fk_name on the corresponding inline admin:\nclass DateInline(admin.TabularInline):\n model = DateTimeSheet\n fk_name = \"date\"\n\n",
"Yes. Give them different values for related_name.\n",
"that's no problem. \nYou should... | [
8,
3,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0004514415_django_python.txt |
Q:
getting django apps packaged as python eggs to work with django admin docs
i've taken over a django (1.1) project which has a number of django apps installed as eggs (in /usr/lib/python2.6/site-packages/). This works fine everywhere except for the django admin docs. Trying to view the docs for tags or filters here... | getting django apps packaged as python eggs to work with django admin docs | i've taken over a django (1.1) project which has a number of django apps installed as eggs (in /usr/lib/python2.6/site-packages/). This works fine everywhere except for the django admin docs. Trying to view the docs for tags or filters here gets me:
File "/usr/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/c... | [
"Have you actually specified a directory writable by user that Apache is running your code, for the egg cache directory.\nhttp://code.google.com/p/modwsgi/wiki/ApplicationIssues#Access_Rights_Of_Apache_User\n"
] | [
0
] | [] | [] | [
"django",
"egg",
"python"
] | stackoverflow_0004508654_django_egg_python.txt |
Q:
Google App Engine + Form Validation
I would like to do google app engine form validation but I dont know how to do it?
I tried like this:
from google.appengine.ext.db import djangoforms
from django import newforms as forms
class SurveyForm(forms.Form):
occupations_choices = (
('1', ""),
('2', "Undergr... | Google App Engine + Form Validation | I would like to do google app engine form validation but I dont know how to do it?
I tried like this:
from google.appengine.ext.db import djangoforms
from django import newforms as forms
class SurveyForm(forms.Form):
occupations_choices = (
('1', ""),
('2', "Undergraduate student"),
('3', "Postgraduat... | [
"The builtin method is_valid() should validate.\nWhen submitting a form I do it with HTTP POST\n def post(self):\n try:\n upload_files = self.get_uploads('file') # 'file' is file upload field in the form\n if upload_files:\n blob_info = upload_files[0] \n except:\n self.re... | [
1,
0
] | [] | [] | [
"checkbox",
"django",
"google_app_engine",
"python",
"radiobuttonlist"
] | stackoverflow_0004511529_checkbox_django_google_app_engine_python_radiobuttonlist.txt |
Q:
Beginner's Language app
Hi I'm a techie with no programing experience. I know html and css, but I'd like to someday be able to make an app for my phone (I have an android) and possibly mobile websites.
I made learning a programing language and creating a mobile app a goal for my job, and now my boss would like me... | Beginner's Language app | Hi I'm a techie with no programing experience. I know html and css, but I'd like to someday be able to make an app for my phone (I have an android) and possibly mobile websites.
I made learning a programing language and creating a mobile app a goal for my job, and now my boss would like me to pick a programing languag... | [
"A few things stood out to me as your goals:\n\nYou want formal training on how to program (this is independent of a language)\nYou want to learn how to develop apps for a mobile device\nYour boss is on board with goals 1 and 2, but wants to see the best return on her investment. \n\nI think the easiest way for yo... | [
2,
1,
0,
0,
0
] | [] | [] | [
"android",
"iphone",
"python"
] | stackoverflow_0004514389_android_iphone_python.txt |
Q:
Get another app's templates in Django
This is the structure of my site:
mysite
app_a
templates
a.html
app_b
templates
b.html
views.py
In views.py, I want to get a.html,
So I use this :
return render_to_response('app_a/a.html')
but it shows an error :
TemplateDoe... | Get another app's templates in Django | This is the structure of my site:
mysite
app_a
templates
a.html
app_b
templates
b.html
views.py
In views.py, I want to get a.html,
So I use this :
return render_to_response('app_a/a.html')
but it shows an error :
TemplateDoesNotExist
What do I need to do?
| [
"just use render_to_response('a.html')\nAssuming you have the default app directory template loaders on, the problem is that the template path is actually a.html\nSo in your current format, you would write a.html not app_a/a.html\nThe recommended format for template directories is \nmysite\n app_a\n templa... | [
6,
1,
1
] | [] | [] | [
"django",
"python",
"templates"
] | stackoverflow_0004515101_django_python_templates.txt |
Q:
Python + Cairo: How Do I Save a Drawing?
Suppose I create a blank area in a window and draw some lines in it, how can I save that in a .png or .jpg? Or maybe convert it to an object PIL could understand?
A:
Answer here: Using Pycairo to generate images dynamically and serve in Django though it only says how to s... | Python + Cairo: How Do I Save a Drawing? | Suppose I create a blank area in a window and draw some lines in it, how can I save that in a .png or .jpg? Or maybe convert it to an object PIL could understand?
| [
"Answer here: Using Pycairo to generate images dynamically and serve in Django though it only says how to save to .png.\nsurface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 100, 100)\ncontext = cairo.Context(surface)\n# Draw something ...\n\nsurface.write_to_png('filename')\n\n"
] | [
6
] | [] | [] | [
"cairo",
"python"
] | stackoverflow_0004515226_cairo_python.txt |
Q:
Python Multiprocessing Question
My program has 2 parts divided into the core and downloader. The core handles all the app logic while the downloader just downloads urls. Right now, I am trying to use the python multiprocessing module to accomplish the task of the core as a process and the downloader as a process.
... | Python Multiprocessing Question | My program has 2 parts divided into the core and downloader. The core handles all the app logic while the downloader just downloads urls. Right now, I am trying to use the python multiprocessing module to accomplish the task of the core as a process and the downloader as a process.
The first problem I noticed was that ... | [
"On the p = Process(target=d.start()) line, you're calling d.start(). Remove the parens, like below:\n...\ndef main():\n jobQueue = Queue()\n jobQueue.put(\"http://google.com\")\n d = Downloader(jobQueue)\n p = Process(target=d.start)\n p.start()\n\nif __name__ == '__main__':\n freeze_support()\n... | [
5
] | [] | [] | [
"multiprocessing",
"python"
] | stackoverflow_0004515491_multiprocessing_python.txt |
Q:
How can this insertion sort routine be improved?
This is my implementation of the insertion sort as described in that Cormen, Leiserson, Rivest book. The only difference is that I'm using an inner for loop instead of a while loop. I feel it is a bit clunky. How can I simplify this ?
def isort(list):
if len(list)... | How can this insertion sort routine be improved? | This is my implementation of the insertion sort as described in that Cormen, Leiserson, Rivest book. The only difference is that I'm using an inner for loop instead of a while loop. I feel it is a bit clunky. How can I simplify this ?
def isort(list):
if len(list) <= 1:
return list
# pick the next item for ins... | [
"\nInstead of iterating through range(len(list) do for index, item in enumerate(list). In that case index will be your index and item will be the value of the item you're looking at.\nDo the same for your nested for loop.\n\nBTW, Franck Ribery is one of my favorite soccer players.\n"
] | [
0
] | [] | [] | [
"insertion_sort",
"python",
"sorting"
] | stackoverflow_0004515481_insertion_sort_python_sorting.txt |
Q:
Trying to develop python in emacs
I am trying to follow the setup on http://hide1713.wordpress.com/2009/01/30/setup-perfect-python-environment-in-emacs/
I have steps 1 - 3 running great.
Then I get to part 4: Setup Rope, Ropemacs and Pymacs.
We need the latest development version of Rope and Ropemacs. Otherwise, ... | Trying to develop python in emacs | I am trying to follow the setup on http://hide1713.wordpress.com/2009/01/30/setup-perfect-python-environment-in-emacs/
I have steps 1 - 3 running great.
Then I get to part 4: Setup Rope, Ropemacs and Pymacs.
We need the latest development version of Rope and Ropemacs. Otherwise, emacs can not find the rope-completions... | [
"apt-get is only on Debian-based systems like Ubuntu and *buntu. RPM distributions use a variety of other systems, but yum seems to be predominant.\nSince you're on a Mac, install MacPorts. You'll need to install XCode first, which you can get from Apple after you register (for free). \n",
"Give a try to el-get... | [
3,
2,
1
] | [] | [] | [
"emacs",
"gnu",
"python"
] | stackoverflow_0004515535_emacs_gnu_python.txt |
Q:
Caching external javascript for a QtWebkit widget in a PyQt app
I have a QWebView in my app which renders a html page stored in the app as a Qresource. This page, however requires meaty external Javascript libraries such as MathJax, which I would want to include as a resource due to its size.
My problem is that i... | Caching external javascript for a QtWebkit widget in a PyQt app | I have a QWebView in my app which renders a html page stored in the app as a Qresource. This page, however requires meaty external Javascript libraries such as MathJax, which I would want to include as a resource due to its size.
My problem is that it seems that QtWebkit does not cache these files as a regular browser... | [
"You should try if a simple QtNetwork-based download honor the cache setting or not. Also, see if the settings (QWebSettings) are set properly.\nIn all case, you should be able to inject a custom QNetworkAccessManager that handles the caching of your custom JS library. See http://ariya.blogspot.com/2010/05/qnetwork... | [
1,
0
] | [] | [] | [
"javascript",
"pyqt",
"python",
"qtwebkit"
] | stackoverflow_0003872033_javascript_pyqt_python_qtwebkit.txt |
Q:
django-admin.py makemessages issues (1) Duplicated message (2) .pot not .po?
Hi I'm working on the Localization of a website frontend, and I met two issues with django-admin.py makemessages -l zh_CN.
1) It's generating .pot files instead of .po files? Why is that? How do I change this?
2) When I'm editing the tran... | django-admin.py makemessages issues (1) Duplicated message (2) .pot not .po? | Hi I'm working on the Localization of a website frontend, and I met two issues with django-admin.py makemessages -l zh_CN.
1) It's generating .pot files instead of .po files? Why is that? How do I change this?
2) When I'm editing the translation I got this kind of error message "duplicate message definition". It makes ... | [
"All solved. It's because there were errors when I did \"makemessage\", e.g. \nSyntaxError: Translation blocks must not include other block tags: url alerts_main (file: ./templates/default/alerts/base.html)\n\nI've fixed those errors one by one it'll completed generating a .po file without any duplicated message.\n... | [
0
] | [] | [] | [
"django",
"localization",
"po",
"python",
"translation"
] | stackoverflow_0004497847_django_localization_po_python_translation.txt |
Q:
Overriding hostname IP address in qtwebkit request
I'm downloading a web page (with PyQt4/QtWebKit) using given hostname, but I would like to use a pre-defined IP address for that hostname. For example, I need to hit "http://www.mysite.com" but use the IP address 1.2.3.4 instead of the actual resolved IP address. ... | Overriding hostname IP address in qtwebkit request | I'm downloading a web page (with PyQt4/QtWebKit) using given hostname, but I would like to use a pre-defined IP address for that hostname. For example, I need to hit "http://www.mysite.com" but use the IP address 1.2.3.4 instead of the actual resolved IP address. Is this at all possible in QtWebKit? I've tried a couple... | [
"Use custom network access manager, something like this (C++): http://ariya.blogspot.com/2010/05/qnetworkaccessmanager-tracenet-speed.html, so that you can \"hijack\" the network request and \"redirect\" it to other domain.\n"
] | [
0
] | [] | [] | [
"pyqt",
"pyqt4",
"python",
"qtwebkit"
] | stackoverflow_0003670091_pyqt_pyqt4_python_qtwebkit.txt |
Q:
how to capture the right click event using getMouse()
I am trying to use graphics.py to write a user graphics interface. The problem is that how can I capture the right click event? It seems that the function getMouse() could just returns where the mouse was left-clicked as a Point object.
from graphics impor... | how to capture the right click event using getMouse() | I am trying to use graphics.py to write a user graphics interface. The problem is that how can I capture the right click event? It seems that the function getMouse() could just returns where the mouse was left-clicked as a Point object.
from graphics import *
def main():
win = GraphWin("My Circle", 100... | [
"I would recommend you try TkInter for a python GUI.\nHere is an example that detects a right click:\nfrom Tkinter import *\n\n\ndef showPosEvent(event):\n print 'Widget=%s X=%s Y=%s' % (event.widget, event.x, event.y)\n\n\n\ndef onRightClick(event):\n print 'Got right mouse button click:', \n showPosEvent... | [
1
] | [] | [] | [
"graphics",
"python"
] | stackoverflow_0004515929_graphics_python.txt |
Q:
python: check if variable is defined and return its value or return other value
I am trying to use this code
result = arr['key1'] or arr['key2'] or arr['key3']
explanation:
I want to have value in result from either or dict keys .. the availability of keys depends on the environment. This is not about None .. on... | python: check if variable is defined and return its value or return other value | I am trying to use this code
result = arr['key1'] or arr['key2'] or arr['key3']
explanation:
I want to have value in result from either or dict keys .. the availability of keys depends on the environment. This is not about None .. only one of the arr keys might be defined ...
so is there a function or method like is... | [
"result = arr.get('key1', arr.get('key2', arr.get('key3')))\n\n"
] | [
7
] | [] | [] | [
"exists",
"python"
] | stackoverflow_0004516418_exists_python.txt |
Q:
Get path of inserted usb in dbus
I'm writing a program in python using dbus that detects inserted usb drives and manipulates the files inside of them. However, I can't seem to retrieve the path on my system of an inserted usb. Is there someway that I can get the path of an inserted usb in dbus, perhaps by using th... | Get path of inserted usb in dbus | I'm writing a program in python using dbus that detects inserted usb drives and manipulates the files inside of them. However, I can't seem to retrieve the path on my system of an inserted usb. Is there someway that I can get the path of an inserted usb in dbus, perhaps by using the GetProperty() method? I have tried u... | [
"Try the \"NativePath\" Property.\nHere is an example of getting the property (using C# not python)\nhttps://bitbucket.org/hindlemail/udisk-sharp/src/1a4d3e031fa1/src/test/Main.cs\n"
] | [
1
] | [] | [] | [
"dbus",
"detect",
"path",
"python",
"usb"
] | stackoverflow_0004370638_dbus_detect_path_python_usb.txt |
Q:
python: problem with dictionary get method default value
I'm having a new problem here ..
CODE 1:
try:
urlParams += "%s=%s&"%(val['name'], data.get(val['name'], serverInfo_D.get(val['name'])))
except KeyError:
print "expected parameter not provided - "+val["name"]+" is missing"
exit(0)
CODE 2:
try:
u... | python: problem with dictionary get method default value | I'm having a new problem here ..
CODE 1:
try:
urlParams += "%s=%s&"%(val['name'], data.get(val['name'], serverInfo_D.get(val['name'])))
except KeyError:
print "expected parameter not provided - "+val["name"]+" is missing"
exit(0)
CODE 2:
try:
urlParams += "%s=%s&"%(val['name'], data.get(val['name'], serve... | [
"From the docs (dict.get):\n\nReturn the value for key if key is in\n the dictionary, else default. If\n default is not given, it defaults to\n None, so that this method never raises\n a KeyError.\n\nThat is why your first code works and second doesn't. \n"
] | [
5
] | [] | [] | [
"python"
] | stackoverflow_0004516794_python.txt |
Q:
Python Script Won't Run Via TextMate, OK in IDLE and Eclipse
I wrote the following for a homework assignment and it works fine in IDLE and Eclipse running Python 3.
However, I tried to run it from TextMate with the new line 1 -- which I found here -- to point it to Python 3 on the Mac. It seems to be running Pyth... | Python Script Won't Run Via TextMate, OK in IDLE and Eclipse | I wrote the following for a homework assignment and it works fine in IDLE and Eclipse running Python 3.
However, I tried to run it from TextMate with the new line 1 -- which I found here -- to point it to Python 3 on the Mac. It seems to be running Python 3 but returns an error. It says: EOFError: EOF when reading a ... | [
"The problem you are seeing has nothing to do with the Python version. The problem is that TextMate does not try to redirect standard input so, when you are running via the TextMate's Python bundle Run Script command, the Python program sees an immediate end-of-file. As explained here, TextMate used to be fancier... | [
2,
0
] | [] | [] | [
"eoferror",
"python",
"textmate"
] | stackoverflow_0004516358_eoferror_python_textmate.txt |
Q:
Diamond problem when using MixIns in Python
Please consider the following code implementing a simple MixIn:
class Story(object):
def __init__(self, name, content):
self.name = name
self.content = content
class StoryHTMLMixin(object):
def render(self):
return ("<html><title>%s</title>"... | Diamond problem when using MixIns in Python | Please consider the following code implementing a simple MixIn:
class Story(object):
def __init__(self, name, content):
self.name = name
self.content = content
class StoryHTMLMixin(object):
def render(self):
return ("<html><title>%s</title>"
"<body>%s</body></html>"
% (se... | [
"Why don't you use mixins directly instead of hacking around in the mro?\nclass Story(object):\n def __init__(self, name, content): \n self.name = name\n self.content = content \n\nclass StoryHTMLMixin(object):\n def render(self):\n return (\"<html><title>%s</title>\"\n \"<body>%s</bod... | [
5,
4,
2,
2,
1,
1
] | [] | [] | [
"diamond_problem",
"mixins",
"multiple_inheritance",
"python"
] | stackoverflow_0004514803_diamond_problem_mixins_multiple_inheritance_python.txt |
Q:
Cant find facebook button using django-socialauth
i want to Login via twitter, facebook, openid, yahoo, google using a single app.
so i choose django-socialauth
i read this artile : django-socialauth-login-via-twitter-facebook-openid-yahoo-google/
but when i download the code , and run it , i cant find the faceboo... | Cant find facebook button using django-socialauth | i want to Login via twitter, facebook, openid, yahoo, google using a single app.
so i choose django-socialauth
i read this artile : django-socialauth-login-via-twitter-facebook-openid-yahoo-google/
but when i download the code , and run it , i cant find the facebook button ,
what can i do ?
thanks
this is my demo ima... | [
"So I had to slightly tweak their view code in order to get this to work. Looking in socialauth.views, you see that we're getting the attribute FACEBOOK_APP_ID from our settings file. This is good.\nLooking at the socialauth/login_page.html template, there's a section:\n{% if FACEBOOK_APP_ID %}\n <div id=\"faceboo... | [
0
] | [] | [] | [
"django",
"django_socialauth",
"facebook",
"python"
] | stackoverflow_0004384275_django_django_socialauth_facebook_python.txt |
Q:
Multiple Crawling using Scrapy
How can i use Scrapy for crawling multiple URL.
A:
Follow the tutorial on the Scrapy website?
http://doc.scrapy.org/intro/tutorial.html
| Multiple Crawling using Scrapy | How can i use Scrapy for crawling multiple URL.
| [
"Follow the tutorial on the Scrapy website?\nhttp://doc.scrapy.org/intro/tutorial.html\n"
] | [
4
] | [] | [] | [
"python"
] | stackoverflow_0004517085_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.