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:
GCC error when installing MySQL_python 1.2.2 (Mac OS 10.6 Snow Leopard)
I'm trying to install MySQL_python 1.2.2 (I specifically need this version, not the current 1.2.3) on Snow Leopard, and getting this error below.
Command to install:
pip install -Iv http://sourceforge.net/projects/mysql-python/files/mysql-pyt... | GCC error when installing MySQL_python 1.2.2 (Mac OS 10.6 Snow Leopard) | I'm trying to install MySQL_python 1.2.2 (I specifically need this version, not the current 1.2.3) on Snow Leopard, and getting this error below.
Command to install:
pip install -Iv http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.2/MySQL-python-1.2.2.tar.gz/download
And a portion of the trace:
cop... | [
"A quick google search yielded this answer:\n\nTo get mysqldb working on leopard I found I had to edit _mysql.c and edit out the lines:\n#ifndef uint\n#define uint unsigned int\n#endif \n\nI also had to edit site.cfg and mark threadsafe to False.\nAfter doing this, I managed to get MySQLdb to install, great! No... | [
3,
0
] | [] | [] | [
"gcc",
"mysql",
"mysql_python",
"python"
] | stackoverflow_0005226945_gcc_mysql_mysql_python_python.txt |
Q:
Click on a javascript link within python?
I am navigating a site using python's mechanize module and having trouble clicking on a javascript link for next page. I did a bit of reading and people suggested I need python-spidermonkey and DOMforms. I managed to get them installed by I am not sure of the syntax to a... | Click on a javascript link within python? | I am navigating a site using python's mechanize module and having trouble clicking on a javascript link for next page. I did a bit of reading and people suggested I need python-spidermonkey and DOMforms. I managed to get them installed by I am not sure of the syntax to actually click on the link.
I can identify the c... | [
"I mainly use HtmlUnit under jython for these use cases. Also I published a simple article on the subject: Web Scraping Ajax and Javascript sites.\n",
"instead of struggling with python-spidermonkey try webkit's qt python bindings.\nHere is a full example to execute JavaScript and extract the final HTML.\n",
"h... | [
6,
2,
0
] | [] | [] | [
"javascript",
"mechanize",
"python",
"screen_scraping",
"spidermonkey"
] | stackoverflow_0005207948_javascript_mechanize_python_screen_scraping_spidermonkey.txt |
Q:
A complicated python except
stmt = "Iomrscr yn wore"
mix = "C'r eotrA,snep!"
for i in range(0, len(stmt), 2):
stmt = stmt[:i] + mix[i] + stmt[i + 1:]
print stmt
I know the answer for this question. However, I just do not know how this works. Can someone helps explain how you read this code? thx
A:
Let... | A complicated python except | stmt = "Iomrscr yn wore"
mix = "C'r eotrA,snep!"
for i in range(0, len(stmt), 2):
stmt = stmt[:i] + mix[i] + stmt[i + 1:]
print stmt
I know the answer for this question. However, I just do not know how this works. Can someone helps explain how you read this code? thx
| [
"Let me break down the lines for you:\nstmt = \"Iomrscr yn wore\"\nmix = \"C'r eotrA,snep!\"\n\nThese two lines simply defined 2 strings.\nfor i in range(0, len(stmt), 2):\nThis for statement says loop over every value of i in the array created by range(0, len(stmt), 2) Importantly, the final 2 in the call to ran... | [
3,
0
] | [] | [] | [
"python"
] | stackoverflow_0005223270_python.txt |
Q:
What is the maximum number of methods on a Python class?
I am automatically generating unit tests for some Python code which number in the thousands. The unittest module uses classes to contain the tests however I'm guessing there is an upper limit to the number of methods a class may contain - is this the case?
... | What is the maximum number of methods on a Python class? | I am automatically generating unit tests for some Python code which number in the thousands. The unittest module uses classes to contain the tests however I'm guessing there is an upper limit to the number of methods a class may contain - is this the case?
| [
"Methods (and in fact all attributes) of a class are stored in a dict. There is no limit to the number of items a dict can contain, save that each key must be unique.\n",
"I strongly doubt that you'd ever hit the limit, even if there was one. As far as I know though, the number of methods an object can have is li... | [
8,
6
] | [] | [] | [
"class",
"methods",
"python",
"unit_testing"
] | stackoverflow_0005227198_class_methods_python_unit_testing.txt |
Q:
key corresponding to maximum value in python dictionary
a = dict(((1,3),(0,-1),(3,21)))
m = max(a, key=a.get)
Can someone give me an explanation on why this returns the key corresponding to the maximum value? It's stumped me for quite a while. Thanks!
A:
The dictionary "a" is an iterable structure in python. ... | key corresponding to maximum value in python dictionary | a = dict(((1,3),(0,-1),(3,21)))
m = max(a, key=a.get)
Can someone give me an explanation on why this returns the key corresponding to the maximum value? It's stumped me for quite a while. Thanks!
| [
"The dictionary \"a\" is an iterable structure in python. When you loop through with for x in a, you are looping over the keys in the dictionary.\nIn the second line, the max function takes two arguments: An iterable object (a), and an optional \"key\" function. The Key function is going to be used to evaluate the ... | [
23,
1
] | [] | [] | [
"python"
] | stackoverflow_0005227291_python.txt |
Q:
What does this mean in my boss's python code?
This is the code :
modulename, classname = settings.APP_USER_CLASS.rsplit('.',1 )
modulemeta = __import__(modulename, globals(), locals(), [classname])
I don't understand this: __import__(modulename, globals(), locals(), [classname]) mean ,
so what is it ,
thanks... | What does this mean in my boss's python code? | This is the code :
modulename, classname = settings.APP_USER_CLASS.rsplit('.',1 )
modulemeta = __import__(modulename, globals(), locals(), [classname])
I don't understand this: __import__(modulename, globals(), locals(), [classname]) mean ,
so what is it ,
thanks
| [
"__import__ is a built-in function that imports a module. The first argument is the module to load, the fourth is a list of names to import from the module. So his call is equivalent to:\nfrom modulename import classname\n\n[Edit]\nBut I have to agree with Jon's comment to your post. This is the kind of thing th... | [
4
] | [] | [] | [
"python"
] | stackoverflow_0005227424_python.txt |
Q:
Python re-using same socket and getting problems
I'm using Python to write a simple script that will connect to a host/port using a socket. I know sockets can only be used once which is why I'm not closing the socket at all but when I connect to localhost on port 80 and try a simple command like GET / it works the... | Python re-using same socket and getting problems | I'm using Python to write a simple script that will connect to a host/port using a socket. I know sockets can only be used once which is why I'm not closing the socket at all but when I connect to localhost on port 80 and try a simple command like GET / it works the first time but the second time I execute GET / or any... | [
"Given information from the comments on @samplebias' answer, I think this is similar to what you're looking to accomplish:\nimport errno\nimport socket\n\nsize = 1024\nhost = 'localhost'\nport = 80\n\n\ndef connectsocket(userHost, userPort):\n\n while(1):\n s = socket.socket(socket.AF_INET, socket.SOCK_ST... | [
1,
0
] | [] | [] | [
"http",
"python",
"sockets",
"tcp"
] | stackoverflow_0005227222_http_python_sockets_tcp.txt |
Q:
Example of Python + Redland for RDF Storage and Retrieval
Would someone please point to an example of using Python to store RDF data using Redland / RDF, and later to retrieve the data.
I see there is a lot of Redland documentation out there, and I'm sure it's excellent, but I'm quite new to RDF and don't have a s... | Example of Python + Redland for RDF Storage and Retrieval | Would someone please point to an example of using Python to store RDF data using Redland / RDF, and later to retrieve the data.
I see there is a lot of Redland documentation out there, and I'm sure it's excellent, but I'm quite new to RDF and don't have a strong grasp of C, so I can't quite make my way through it.
Than... | [
"The redland-bindings Github project has a Python example which shows storage of statements into an RDF store and then querying for them.\n"
] | [
6
] | [] | [] | [
"python",
"rdf",
"redland"
] | stackoverflow_0005227202_python_rdf_redland.txt |
Q:
How to access & modify Django template context variables
In my urls.py, I map the url accounts/login/ to the login module, with a reference to the template i want to use:
url(r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'templates/login.html'})
This works fine, but I want to change t... | How to access & modify Django template context variables | In my urls.py, I map the url accounts/login/ to the login module, with a reference to the template i want to use:
url(r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'templates/login.html'})
This works fine, but I want to change the value of the next property, which specified where the user ... | [
"Direct the url to a view:\n(r'^accounts/login/', 'myproj.login.views.mylogin')\n\nThen handle redirection in your view code:\ndef mylogin(request, **kwargs):\n if request.user.is_authenticated():\n if 'next_url' in request.session:\n url = request.session['next_url']\n del request.s... | [
1
] | [] | [] | [
"django",
"django_templates",
"python"
] | stackoverflow_0005227440_django_django_templates_python.txt |
Q:
all path in a DAG (a kind of connected binary tree)
i have this DAG (it is similar to a binary tree, but it is a graph.. has this a specified name?):
(each number is a node and numbers in the node are for example, the program should run with random numbers)
it is represented as a list of list:
[[1],[2,3],[4,5,6]]... | all path in a DAG (a kind of connected binary tree) | i have this DAG (it is similar to a binary tree, but it is a graph.. has this a specified name?):
(each number is a node and numbers in the node are for example, the program should run with random numbers)
it is represented as a list of list:
[[1],[2,3],[4,5,6]]
i have to find in the more functional way as possible t... | [
"Looks like a variation on the longest path problem. You'll need to treat the node values as edge weights.\n",
"As I understand your problem, node of depth n and rank r at that level will be connected to nodes of level n+1 with rank r and r+1.\nThe direct path is certainly to look for some recurrence relation usi... | [
1,
1,
1
] | [] | [] | [
"binary_tree",
"directed_acyclic_graphs",
"python"
] | stackoverflow_0005226930_binary_tree_directed_acyclic_graphs_python.txt |
Q:
django: how to get a substring?
I was modifying satchmo(a python online store project), but I found that I can't use [0, 5] to get the substring in the model. And I found the type is class 'django.utils.safestring.SafeUnicode' in django string processing.
Does class 'django.utils.safestring.SafeUnicode' support [... | django: how to get a substring? | I was modifying satchmo(a python online store project), but I found that I can't use [0, 5] to get the substring in the model. And I found the type is class 'django.utils.safestring.SafeUnicode' in django string processing.
Does class 'django.utils.safestring.SafeUnicode' support [0, 5] to get the substring as in pyth... | [
"Slice it.\nhttp://docs.python.org/tutorial/introduction.html\n>>> 'foobar'[0:5]\n[Out] 'fooba'\n\n\nUpdate: sure, why not?\n>>> django.utils.safestring.SafeUnicode('foobar')[0:5]\n[Out] 'fooba'\n\n"
] | [
5
] | [] | [] | [
"django",
"python",
"satchmo"
] | stackoverflow_0005227902_django_python_satchmo.txt |
Q:
Are there any sandboxable scripting engines which can be integrated with PHP/Python/other?
I'm performing a thought-experiment which, judging by other questions, isn't so novel after all, but I think I'll proceed anyway. I want to sandbox a user-supplied server-side script by, among other things, confining it to ... | Are there any sandboxable scripting engines which can be integrated with PHP/Python/other? | I'm performing a thought-experiment which, judging by other questions, isn't so novel after all, but I think I'll proceed anyway. I want to sandbox a user-supplied server-side script by, among other things, confining it to a virtual filesystem and setting the root directory, and further mapping certain virtual directo... | [
"The Java sandbox (in the way implemented for browser applets) does not offer file access at all.\nIn general, the Java security model has only \"allow or not allow\" decisions for the security manager in most cases.\nOf course you could design another API instead of the normal File IO api (and similar), and have y... | [
1,
1
] | [] | [] | [
"java",
"mono",
"php",
"python",
"security"
] | stackoverflow_0005213421_java_mono_php_python_security.txt |
Q:
Problems when compiling python-ast.c on win32
I have downloaded the Python 2.7.1 source code, after extraction issued this command:
D:\sources\Python-2.7.1>gcc -c -I.\Include -I.\PC -I.\Python .\Python\Python-ast.c
.\Python\Python-ast.c:464: error: initializer element is not constant
.\Python\Python-ast.c:464: err... | Problems when compiling python-ast.c on win32 | I have downloaded the Python 2.7.1 source code, after extraction issued this command:
D:\sources\Python-2.7.1>gcc -c -I.\Include -I.\PC -I.\Python .\Python\Python-ast.c
.\Python\Python-ast.c:464: error: initializer element is not constant
.\Python\Python-ast.c:464: error: (near initialization for 'AST_type.ob_type')
T... | [
"Python on Windows expects to be compiled with MSVC. The #defines and the like are set up for it. They probably look for the macro _WIN32 or something, which is defined by MSVC and (if I remember correctly) by mingw32. Since you're compiling with mingw and not MSVC, that may be part of the problem.\nI would also ... | [
1
] | [] | [] | [
"compilation",
"python"
] | stackoverflow_0005227515_compilation_python.txt |
Q:
Looking for forum engine that is easy to integrate with existing user tables
I have a custom made web-site in Python/MySQL with custom user/session tables and users already using it.
I am looking for forum to integrate with the current site:
Users of the main site should automatically get an account and get logged... | Looking for forum engine that is easy to integrate with existing user tables | I have a custom made web-site in Python/MySQL with custom user/session tables and users already using it.
I am looking for forum to integrate with the current site:
Users of the main site should automatically get an account and get logged into forum. They would just pick a different visible name for the forum (no email... | [
"I ended up with Simple Machines Forum. It provides a set of integration hooks.\nWith a bit of php hacking, you can connect it to anything you want.\nSMF 2.0 is still in beta, but get much more control on customization. T\n",
"Consider Nearforums: it is developed in .NET (C#), it uses a MySQL database, runs on II... | [
1,
0
] | [] | [] | [
"forum",
"forums",
"python"
] | stackoverflow_0004755941_forum_forums_python.txt |
Q:
How to use xgoogle
I am using the xgoogle library, whenever i ask it to get the number of search results it comes up with zero. (its not my code i copied it directly from the examples) any ideas?
A:
This shows 1000000 results on my Debian system:
jcomeau@intrepid:/usr/src/xgoogle$ cat xg.py
#!/usr/bin/python
f... | How to use xgoogle | I am using the xgoogle library, whenever i ask it to get the number of search results it comes up with zero. (its not my code i copied it directly from the examples) any ideas?
| [
"This shows 1000000 results on my Debian system:\n\njcomeau@intrepid:/usr/src/xgoogle$ cat xg.py \n#!/usr/bin/python\nfrom xgoogle.search import GoogleSearch, SearchError\ntry:\n gs = GoogleSearch(\"quick and dirty\")\n gs.results_per_page = 50\n results = gs.get_results()\n print 'results', gs.num_results # n... | [
1
] | [] | [] | [
"python",
"search",
"xgoogle"
] | stackoverflow_0005227985_python_search_xgoogle.txt |
Q:
transforming images in pygame
I'm trying to resize an image in pygame. I want my background image to fill the entire screen. I'd like to setup the entire screen based on the new (stretched) dimensions of the background. The following isn't working and I'm trying to figure out why.
Suggestions?
background = py... | transforming images in pygame | I'm trying to resize an image in pygame. I want my background image to fill the entire screen. I'd like to setup the entire screen based on the new (stretched) dimensions of the background. The following isn't working and I'm trying to figure out why.
Suggestions?
background = pygame.image.load("data/stars.bmp")
p... | [
"#pygame.transform.scale(background, (1200,800)) #or some size x,y here.\nbackground = pygame.transform.scale(background, (1200,800))\n\n"
] | [
7
] | [] | [] | [
"pygame",
"python"
] | stackoverflow_0005228026_pygame_python.txt |
Q:
Downloading videos in FLV format from YouTube
I can’t really understand how YouTube serves videos, but I have been reading through what I can.
It seems like the old method get_video is now obsolete and can't be used any more. Is there another Pythonic and simple method for collecting YouTube videos?
A:
You migh... | Downloading videos in FLV format from YouTube | I can’t really understand how YouTube serves videos, but I have been reading through what I can.
It seems like the old method get_video is now obsolete and can't be used any more. Is there another Pythonic and simple method for collecting YouTube videos?
| [
"You might have some luck with youtube-dl\nhttp://rg3.github.com/youtube-dl/documentation.html\nI'm not sure if there's a good API, but it's written in Python, so theoretically you could do something a little better than Popen :)\n",
"Here is a quick Python script which downloads a YouTube video. No bells and whi... | [
15,
6,
4
] | [] | [] | [
"download",
"python",
"urllib2",
"youtube"
] | stackoverflow_0004287748_download_python_urllib2_youtube.txt |
Q:
How do I match a word in a text file using python?
I want to search and match a particular word in a text file.
with open('wordlist.txt', 'r') as searchfile:
for line in searchfile:
if word in line:
print line
This code returns even the words that contain substrings of the ... | How do I match a word in a text file using python? | I want to search and match a particular word in a text file.
with open('wordlist.txt', 'r') as searchfile:
for line in searchfile:
if word in line:
print line
This code returns even the words that contain substrings of the target word. For example if the word is "there" then the... | [
"import re\n\nfile = open('wordlist.txt', 'r')\n\nfor line in file.readlines():\n if re.search('^there$', line, re.I):\n print line\n\nThe re.search function scans the string line and returns true if it finds the regular expression defined in the first parameter, ignoring case with re.I. The ^ character m... | [
7,
5,
2,
0,
0
] | [] | [] | [
"match",
"python",
"string",
"text_files"
] | stackoverflow_0005228448_match_python_string_text_files.txt |
Q:
How do I interface python progam with the web
I have a python program and need to run that program in the background and get the output in the browser .we are using a plug-in for this purpose and I found that only html and Java script can be run in chrome extension.
A:
Are you trying to build a web application? ... | How do I interface python progam with the web | I have a python program and need to run that program in the background and get the output in the browser .we are using a plug-in for this purpose and I found that only html and Java script can be run in chrome extension.
| [
"Are you trying to build a web application? If so, web.py is my personal favorite. It's very lightweight and easy to use.\nHere's an entire web application -- albeit a trivial one.\nimport web\n\nurls = (\n '/(.*)', 'hello'\n)\napp = web.application(urls, globals())\n\nclass hello: \n def GET(self, n... | [
1
] | [] | [] | [
"python",
"webpage"
] | stackoverflow_0005228672_python_webpage.txt |
Q:
Change HTML with variables in Django
I have the dict latest_status:
{'What': 10, "Study'": 10, 'all': 10, 'to': 10, "facebook'": 10, 'has': 10, 'worth': 20, 'hurting': 10 }
I am trying to make a text cloud by doing something like this in my template:
{% for word,count in latest_status.items %}
<style="font-size:{... | Change HTML with variables in Django | I have the dict latest_status:
{'What': 10, "Study'": 10, 'all': 10, 'to': 10, "facebook'": 10, 'has': 10, 'worth': 20, 'hurting': 10 }
I am trying to make a text cloud by doing something like this in my template:
{% for word,count in latest_status.items %}
<style="font-size:{{ count }}px"> {{ word }}</style>
{% endf... | [
"The <style> tag is used to introduce a block (or external resource) containing style definitions. You'll want to encapsulate your text in a presentation tag of some sort--for example:\n{% for word,count in latest_status.items %}\n<p style=\"font-size:{{ count }}px;\"> {{ word }}</p>\n{% endfor %}\n\n"
] | [
5
] | [] | [] | [
"django",
"django_templates",
"python"
] | stackoverflow_0005228717_django_django_templates_python.txt |
Q:
How come when I paste this in vim, I get syntax errors?
def latlong_distance(origin, destination):
lat1, lon1 = origin
lat2, lon2 = destination
radius = 6371
dlat = math.radians(lat2-lat1)
dlon = math.radians(lon2-lon1) a = math.sin(dlat/2) * math.sin(dlat/2) + math.cos(math.radians(lat1)) *... | How come when I paste this in vim, I get syntax errors? | def latlong_distance(origin, destination):
lat1, lon1 = origin
lat2, lon2 = destination
radius = 6371
dlat = math.radians(lat2-lat1)
dlon = math.radians(lon2-lon1) a = math.sin(dlat/2) * math.sin(dlat/2) + math.cos(math.radians(lat1)) * math.cos(math.radians(lat2)) * math.sin(dlon/2) * math.sin(d... | [
"It's probably a spacing issue (\\xc2 is a space character), try and reindent using only spaces, nothing else. You can also put # -*- coding:utf-8 -*- at the top of the file and see if that helps. \n",
"I modified that code a little:\ndlon = math.radians(lon2-lon1) a = math.sin(dlat/2) * math.sin(dlat/2) + mat... | [
7,
1
] | [] | [] | [
"python"
] | stackoverflow_0005228707_python.txt |
Q:
Importing modules inside of modules in Python
I'm trying to create a hierarchy of options. I'm able to create the first list of options:
lemur
gorillas
chimps
if the user chooses option 1 for lemurs then I run the Lemur.LE() function cause I already imported the lemur module. They are then presented with anoth... | Importing modules inside of modules in Python | I'm trying to create a hierarchy of options. I'm able to create the first list of options:
lemur
gorillas
chimps
if the user chooses option 1 for lemurs then I run the Lemur.LE() function cause I already imported the lemur module. They are then presented with another set of options:
Brandy
Cigars
Shaving Cream
Cho... | [
"It's not clear what you are doing wrong without a code sample. In general import is a statement like any other and can be used in any scope. So:\ndef LE():\n ...\n if option == 'Shaving Cream':\n import Shaven\n Shaven.SC()\n elif option == ...\n\nshould work just fine.\n",
"\nget a strang... | [
0,
0
] | [] | [] | [
"hierarchy",
"import",
"menu",
"python"
] | stackoverflow_0005220718_hierarchy_import_menu_python.txt |
Q:
Use of python in javascript
All I'm looking for is a multi-platform python-independent way of, say, printing "hi" on the screen using Python, but in an HTML file
A:
I guess you might want to check out Skulpt and Pyjamas.
| Use of python in javascript | All I'm looking for is a multi-platform python-independent way of, say, printing "hi" on the screen using Python, but in an HTML file
| [
"I guess you might want to check out Skulpt and Pyjamas.\n"
] | [
1
] | [] | [] | [
"javascript",
"python"
] | stackoverflow_0005228920_javascript_python.txt |
Q:
numpy recarray minimum differences
I have a numpy recarray I want to find record where difference of 1st element and last element of record is maximum.
can someone suggest a way to do this.
A:
Set up:
import numpy
ra = numpy.recarray((10,), 'int,int,int')
Find the index of the maximum of the difference between ... | numpy recarray minimum differences | I have a numpy recarray I want to find record where difference of 1st element and last element of record is maximum.
can someone suggest a way to do this.
| [
"Set up:\nimport numpy\nra = numpy.recarray((10,), 'int,int,int')\n\nFind the index of the maximum of the difference between first field and last field.\nidx = numpy.argmax(ra['f0']-ra['f2'])\n\nRetrieve the record using that index\nprint ra[idx]\n\n"
] | [
2
] | [] | [] | [
"numpy",
"python",
"recarray"
] | stackoverflow_0005228972_numpy_python_recarray.txt |
Q:
django: how to get a substring from django.utils.safestring.SafeUnicode
I noticed django use this to process the string, but can I get a substring from django.utils.safestring.SafeUnicode?
A:
Yes, you can. Just treat SafeUnicode as a normal string -- to get a substring, take a slice. The slice will have type uni... | django: how to get a substring from django.utils.safestring.SafeUnicode | I noticed django use this to process the string, but can I get a substring from django.utils.safestring.SafeUnicode?
| [
"Yes, you can. Just treat SafeUnicode as a normal string -- to get a substring, take a slice. The slice will have type unicode (not SafeUnicode!); if you want to make it a SafeUnicode string, just make a new one based on the slice:\n>>> from django.utils.safestring import SafeUnicode\n>>> su = SafeUnicode(\"This is... | [
1,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0005227991_django_python.txt |
Q:
How can I interact with another program in Python?
I want to write a Python script that runs another program, reading the output of the other program and manipulating it. The problem is that this program prompts for a password, and I cannot figure out how to supply it automatically. (For the purposes of this scrip... | How can I interact with another program in Python? | I want to write a Python script that runs another program, reading the output of the other program and manipulating it. The problem is that this program prompts for a password, and I cannot figure out how to supply it automatically. (For the purposes of this script, it really does not matter if the password is stored i... | [
"I had some similar problems with terminal-based interprocess communication that didn't seem to be solvable using popen (et al.). I ended up learning how to use pty by reading the source of pexpect, which contains examples of how (and comments of why) to get pty to jump through the necessary hoops.\nDepending on y... | [
3,
0,
0
] | [] | [] | [
"linux",
"pty",
"python"
] | stackoverflow_0005225542_linux_pty_python.txt |
Q:
How do I deserialize this JSON object?
import simplejson
from urllib2 import urlopen
from simplejson import loads
from django.core import serializers
content = loads(urlopen('https://graph.facebook.com/1234676502/feed').read())
content = simplejson.dumps(content,sort_keys=True, indent=4)
print content
json_serial... | How do I deserialize this JSON object? | import simplejson
from urllib2 import urlopen
from simplejson import loads
from django.core import serializers
content = loads(urlopen('https://graph.facebook.com/1234676502/feed').read())
content = simplejson.dumps(content,sort_keys=True, indent=4)
print content
json_serializer = serializers.get_serializer("json")()
... | [
"Your error has nothing to with json per se, it clearly states that it cannot import DJANGO_SETTINGS which means that you do not have the django app context in place. The easiest way to go about this is install django extensions which provides the command ./manage.py runscript which runs your script with your djang... | [
1
] | [] | [] | [
"deserialization",
"django",
"json",
"python"
] | stackoverflow_0005229253_deserialization_django_json_python.txt |
Q:
py2exe - How do I reduce dll dependencies?
My program depends on USER32.dll, SHELL32.dll, ADVAPI32.dll WS2_32.dll, GDI32.dll, and KERNEL32.dll. All are in the system32 folder. Is there any way I can include these in my program so it will run on all Windows computers? Or are these dlls that can already be found ... | py2exe - How do I reduce dll dependencies? | My program depends on USER32.dll, SHELL32.dll, ADVAPI32.dll WS2_32.dll, GDI32.dll, and KERNEL32.dll. All are in the system32 folder. Is there any way I can include these in my program so it will run on all Windows computers? Or are these dlls that can already be found on all installations of Windows?
| [
"\nWhen py2exe comes across a DLL file that is required by the application, it decides whether or not includes the DLL file in the distribution directory using various criteria. Generally, it doesn't include DLLs if it thinks they belong to the \"system\" rather than the \"application\". \n\nYou need to override th... | [
3,
2
] | [] | [] | [
"dependencies",
"dll",
"py2exe",
"python",
"windows"
] | stackoverflow_0005227170_dependencies_dll_py2exe_python_windows.txt |
Q:
How can printf corrupt strings?
I'm trying to reverse engineer a function over which i have no source, and is protected by a anti debugger.
Anyway, i'm interested the function PyRun_ConsoleString in the caller assembly is:
CPU Disasm
Address Hex dump Command ... | How can printf corrupt strings? | I'm trying to reverse engineer a function over which i have no source, and is protected by a anti debugger.
Anyway, i'm interested the function PyRun_ConsoleString in the caller assembly is:
CPU Disasm
Address Hex dump Command Comments
200DAB20 /... | [
"Hmmm, nice puzzle.\nFWIW:\nprintf(\"%s 1 \\n\", str) prints ' 1 rty \"what\"' ?!?\n... looks to me like what you are seeing on the console, right?) is:\nqwerty \"what\"\nfollowed by return (no line feed), overwritten by:\n' 1 '\nthen \\n\nThis suggests that the string you are supplying (from a file?) includes a te... | [
1
] | [] | [] | [
"assembly",
"c",
"python",
"reverse_engineering"
] | stackoverflow_0005229500_assembly_c_python_reverse_engineering.txt |
Q:
Getting group name using gdata api
I am trying to access the group name of all entries in my contact list. How can I access the details of a group given the href link?
This is the current output:
9 Albert Gandhi 2011-03-07T09:48:19.824Z
I was thrown out of college for cheating on the metaphysics exam; I looked... | Getting group name using gdata api | I am trying to access the group name of all entries in my contact list. How can I access the details of a group given the href link?
This is the current output:
9 Albert Gandhi 2011-03-07T09:48:19.824Z
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next t... | [
"For reference, you can find a solution to this issue here\n"
] | [
0
] | [] | [] | [
"gdata",
"python"
] | stackoverflow_0005218805_gdata_python.txt |
Q:
Understanding A Chain of Imports in Python
I know there are several similar questions, but I'm struggling to understand the error I'm getting and browsing the docs and similar questions hasn't helped yet. If anything, the similar questions make me feel like what I'm doing is right.
I have the following files:
src... | Understanding A Chain of Imports in Python | I know there are several similar questions, but I'm struggling to understand the error I'm getting and browsing the docs and similar questions hasn't helped yet. If anything, the similar questions make me feel like what I'm doing is right.
I have the following files:
src/main.py
from pack import pack
if __name__ == '... | [
"You will have trouble making the import work in both cases. This is because in one case you are running pack.py as the main file and in another you run it as part of a package.\nWhen you run it as a standalone script python pack.py, the \"pack\" directory gets added to the PYTHONPATH, meaning that you can import a... | [
6,
4,
2,
0
] | [] | [] | [
"import",
"python",
"python_3.x"
] | stackoverflow_0005226893_import_python_python_3.x.txt |
Q:
itertools.chain to chain an iter list?
import itertools
def _yield_sample():
it = iter(itertools.combinations('ABCD', 2))
it2 = iter(itertools.combinations('EFGH', 3))
itc = itertools.chain(it,it2)
for x in itc:
yield x
def main():
for x in _yield_sample():
print x
This works ... | itertools.chain to chain an iter list? | import itertools
def _yield_sample():
it = iter(itertools.combinations('ABCD', 2))
it2 = iter(itertools.combinations('EFGH', 3))
itc = itertools.chain(it,it2)
for x in itc:
yield x
def main():
for x in _yield_sample():
print x
This works to print the combinations.
>>>
('A', 'B')
(... | [
"Yes.\nBut itertools.chain.from_iterable().\n",
"\nis it means iter, iter, iter = *(iter, iter, iter) ?\n\nNot by itself. Argument unpacking only works when calling a function, so the following two calls are equivalent:\nf(1,2,3)\nf(*[1,2,3])\n\nBut *[1,2,3] won't compile unless it's a part of a call. You can mix... | [
16,
4
] | [] | [] | [
"chain",
"python",
"python_itertools"
] | stackoverflow_0005229188_chain_python_python_itertools.txt |
Q:
Where to Put Python Utils Folder?
I've a whole bunch of scripts organized like this:
root
group1
script1.py
script2.py
group2
script1.py
script2.py
group3
script1.py
script2.py
utils
utils1.py
utils2.py
All the scripts*.py use functions inside the utils folder. At the momen... | Where to Put Python Utils Folder? | I've a whole bunch of scripts organized like this:
root
group1
script1.py
script2.py
group2
script1.py
script2.py
group3
script1.py
script2.py
utils
utils1.py
utils2.py
All the scripts*.py use functions inside the utils folder. At the moment, I append the utils path to the scrip... | [
"Make all your directories importable first i.e. use __init__.py. \nThen have a top level script that accepts arguments and invokes scripts based on that.\nFor long term what Keith has mentioned about distutils holds true. Otherwise here is a simpler (sure not the best) solution. \nOrganization \nrunscript.py\ngrou... | [
5,
1,
1,
1
] | [] | [] | [
"code_organization",
"python"
] | stackoverflow_0005229783_code_organization_python.txt |
Q:
convert a list of strings that i would like to convert to a list of tuples
i have a list of strings that i would like to convert to a list of tuples. Below is an example.
['(0, "ass\'")', "(-1, '\\n print self.amount')", "(0, '\\n\\n ')"]
to be converted to.
[(0, "ass\'"), (-1, '\\n print self.amoun... | convert a list of strings that i would like to convert to a list of tuples | i have a list of strings that i would like to convert to a list of tuples. Below is an example.
['(0, "ass\'")', "(-1, '\\n print self.amount')", "(0, '\\n\\n ')"]
to be converted to.
[(0, "ass\'"), (-1, '\\n print self.amount'), (0, '\\n\\n ')]
any ideas?
| [
"[ast.literal_eval(x) for x in L]\n\n",
"map(ast.literal_eval, list_of_tuple_strings)\n\nUnlike eval, ast.literal_eval will only evaluate literals, not function calls, so it much more secure.\n",
"The function eval is what you need I think, but be careful with its use:\n>>> l = ['(0, \"ass\\'\")', \"(-1, '\\\\n... | [
5,
1,
0
] | [] | [] | [
"list",
"python",
"string"
] | stackoverflow_0005230274_list_python_string.txt |
Q:
How do I find the distance between two points?
Let's say I have x1, y1 and also x2, y2.
How can I find the distance between them?
It's a simple math function, but is there a snippet of this online?
A:
dist = sqrt( (x2 - x1)**2 + (y2 - y1)**2 )
As others have pointed out, you can also use the equivalent built-in... | How do I find the distance between two points? | Let's say I have x1, y1 and also x2, y2.
How can I find the distance between them?
It's a simple math function, but is there a snippet of this online?
| [
"dist = sqrt( (x2 - x1)**2 + (y2 - y1)**2 )\n\nAs others have pointed out, you can also use the equivalent built-in math.hypot():\ndist = math.hypot(x2 - x1, y2 - y1)\n\n",
"Let's not forget math.hypot:\ndist = math.hypot(x2-x1, y2-y1)\n\nHere's hypot as part of a snippet to compute the length of a path defined b... | [
142,
71,
18
] | [] | [] | [
"math",
"python"
] | stackoverflow_0005228383_math_python.txt |
Q:
How is membership testing different for a list and a set?
I'm having trouble with figuring out why the first of these assertions is OK and the second raises an error.
subject_list = [Subject("A"), Subject("B"), Subject("C")]
subject_set = set()
subject_set.add(Subject("A"))
subject_set.add(Subject("B"))
subject_se... | How is membership testing different for a list and a set? | I'm having trouble with figuring out why the first of these assertions is OK and the second raises an error.
subject_list = [Subject("A"), Subject("B"), Subject("C")]
subject_set = set()
subject_set.add(Subject("A"))
subject_set.add(Subject("B"))
subject_set.add(Subject("C"))
self.assertIn(Subject("A"), subject_list)
... | [
"The expression\nSubject(\"A\") in subject_list\n\nwill compare Subject(\"A\") to each entry in subject_list using the Subject.__eq__() method. If this method is not overwritten, it defaults to always return False unless the two operands are the same object. The above expression would always return False if Subje... | [
12,
4,
3,
2
] | [] | [] | [
"list",
"member",
"python",
"set"
] | stackoverflow_0005230522_list_member_python_set.txt |
Q:
numpy tensordot related issue
I have a specific issue with multiplying matrices in numpy.
Here is an example:
P=np.arange(30).reshape((-1,3))
array([[ 0, 1, 2],
[ 3, 4, 5],
[ 6, 7, 8],
[ 9, 10, 11],
[12, 13, 14],
[15, 16, 17],
[18, 19, 20],
[21, 22, 23],
[24, 25, 26],
[27, 28, 29]]... | numpy tensordot related issue | I have a specific issue with multiplying matrices in numpy.
Here is an example:
P=np.arange(30).reshape((-1,3))
array([[ 0, 1, 2],
[ 3, 4, 5],
[ 6, 7, 8],
[ 9, 10, 11],
[12, 13, 14],
[15, 16, 17],
[18, 19, 20],
[21, 22, 23],
[24, 25, 26],
[27, 28, 29]])
I want to multiply each row by i... | [
"It's just simple like this:\nIn []: P= arange(30).reshape(-1, 3)\nIn []: P[:, :, None]* P[:, None, :]\nOut[]:\narray([[[ 0, 0, 0],\n [ 0, 1, 2],\n [ 0, 2, 4]],\n [[ 9, 12, 15],\n [ 12, 16, 20],\n [ 15, 20, 25]],\n [[ 36, 42, 48],\n [ 42, 49, ... | [
3,
1,
0
] | [] | [] | [
"matrix_multiplication",
"numpy",
"python"
] | stackoverflow_0005228634_matrix_multiplication_numpy_python.txt |
Q:
What is the difference between {} and [] in python?
What is the difference between columnNames = {} and columnNames = [] in python?
How can i iterate each one? using {% for value in columnNames %} OR for idx_o, val_o in enumerate(columnNames):
A:
columnNames = {} defines an empty dict
columnNames = [] defines ... | What is the difference between {} and [] in python? | What is the difference between columnNames = {} and columnNames = [] in python?
How can i iterate each one? using {% for value in columnNames %} OR for idx_o, val_o in enumerate(columnNames):
| [
"\ncolumnNames = {} defines an empty dict\ncolumnNames = [] defines an empty list\n\nThese are fundamentally different types. A dict is an associative array, a list is a standard array with integral indices.\nI recommend you consult your reference material to become more familiar with these two very important Pytho... | [
31,
13
] | [] | [] | [
"python",
"syntax"
] | stackoverflow_0005230874_python_syntax.txt |
Q:
What is the standard for 'application/x-www-form-urlencoded' and an empty value?
A while ago, I had noticed that when encoding a map name: value to 'application/x-www-form-urlencoded, it renders something like that (here I use Python):
>>> from urllib import urlencode
>>> urlencode({'hello': '', 'blabla': 'hihi'})... | What is the standard for 'application/x-www-form-urlencoded' and an empty value? | A while ago, I had noticed that when encoding a map name: value to 'application/x-www-form-urlencoded, it renders something like that (here I use Python):
>>> from urllib import urlencode
>>> urlencode({'hello': '', 'blabla': 'hihi'})
'blabla=hihi&hello='
But the parsing (at least with Python), just strips the pairs t... | [
"As far as I know, there is no \"standard\" for this. The only thing that is described (in the html spec, as you have found out), is how a browser should encode form data. What you want to do (or not) with empty values is up to you.\nNote that urlparse.parse_qs() has an optional parameter, keep_blank_values that al... | [
4
] | [] | [] | [
"html",
"http",
"python",
"standards",
"urlencode"
] | stackoverflow_0005230181_html_http_python_standards_urlencode.txt |
Q:
Python httplib, urllib syntax error
I'm trying to run the simplest python script to perform a http request and print the response:
import urllib2
f = urllib2.urlopen('http://www.python.org/')
print f.read(100)
And I tried many variation of this "hello http" including httplib, urllib(2), HTTPConnection and treatin... | Python httplib, urllib syntax error | I'm trying to run the simplest python script to perform a http request and print the response:
import urllib2
f = urllib2.urlopen('http://www.python.org/')
print f.read(100)
And I tried many variation of this "hello http" including httplib, urllib(2), HTTPConnection and treating connection as a file descriptor. But I ... | [
"You forgot the shebang at the top of the script. And make sure that you erase the urllib2 file that ImageMagick has created.\n"
] | [
1
] | [] | [] | [
"python",
"syntax",
"urllib",
"urllib2"
] | stackoverflow_0005231005_python_syntax_urllib_urllib2.txt |
Q:
How do I search for integer (x,y) in a textfile using python?
I have a matrix stored in a textfile as:
(i, j) count
I need to search for the pair (i,j). How do I do that?
with open("matrix.txt","r") as searchmat:
for line in searchmat:
word=str((x,y))
if wo... | How do I search for integer (x,y) in a textfile using python? | I have a matrix stored in a textfile as:
(i, j) count
I need to search for the pair (i,j). How do I do that?
with open("matrix.txt","r") as searchmat:
for line in searchmat:
word=str((x,y))
if word in line:
t=line.split('\t')
f=t[1]
... | [
"The code looks fine (assuming you got your indentations right). Maybe there is an issue with your data file format. More than one tab character in the separator perhaps? Try using t=line.split() instead.\n",
"Looks like you have messed up indentation. From looking at the code you've (I assume) pasted here, it lo... | [
1,
0,
0
] | [] | [] | [
"keyword",
"matrix",
"python",
"search"
] | stackoverflow_0005230933_keyword_matrix_python_search.txt |
Q:
python code to read registry
from _winreg import *
areg=ConnectRegistry(None,HKEY_LOCAL_MACHINE)
akey=OpenKey(areg,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
"""for i in range (259):"""
subkey=EnumKey(akey,0)
print subkey
demo=[]
demo=QueryValueEx(akey,"")
print demo
i am trying to obtain the value w... | python code to read registry | from _winreg import *
areg=ConnectRegistry(None,HKEY_LOCAL_MACHINE)
akey=OpenKey(areg,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
"""for i in range (259):"""
subkey=EnumKey(akey,0)
print subkey
demo=[]
demo=QueryValueEx(akey,"")
print demo
i am trying to obtain the value within the subkey ,what is wrong in... | [
"Try to replace this line: \nakey=OpenKey(areg,\"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\")\n\nwith\nakey=OpenKey(areg,r\"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\")\n\n"
] | [
1
] | [] | [] | [
"python",
"registry"
] | stackoverflow_0005231177_python_registry.txt |
Q:
Django TemplateSyntaxError Could not parse the remainder: '()'
I'm trying to iterate a dictionary of dictionary in Django template page
{% for (key_o, value_o) in f_values.items() %}
<tr class="row {% cycle 'odd' 'even' %}">
{% for (key_i, val_i) in value_o.items() %}
... | Django TemplateSyntaxError Could not parse the remainder: '()' | I'm trying to iterate a dictionary of dictionary in Django template page
{% for (key_o, value_o) in f_values.items() %}
<tr class="row {% cycle 'odd' 'even' %}">
{% for (key_i, val_i) in value_o.items() %}
<td class="tile ">
{{ val_i }}
... | [
"You don't need to use () to call methods in templates, you can just use f_values.items. This notation works for lists, tuples, and functions.\nFor example, if you have these Python values:\n lst = ['a', 'b', 'c']\n di = {'a': 'a'}\n class Foo:\n def bar(self): pass\n foo = Foo()\n\nin your templa... | [
61
] | [] | [] | [
"django",
"django_templates",
"python"
] | stackoverflow_0005231171_django_django_templates_python.txt |
Q:
How to check if a node is up/online?
I want my script to [ssh] remote login to a different machine to do something but before that I want to check: that node is not the localhost and the node is online, otherwise exit. What's the best [easiest??] way of doing that? Thanks for your advise in advance. Cheers!!
Upda... | How to check if a node is up/online? | I want my script to [ssh] remote login to a different machine to do something but before that I want to check: that node is not the localhost and the node is online, otherwise exit. What's the best [easiest??] way of doing that? Thanks for your advise in advance. Cheers!!
Update-1 @Jakob: Error message
Am I doing some... | [
"As sven says. I think there is a method to set a new timeout on socket. So just connect and if it times out consider it offline.\nEDIT:\nCode examples\nimport subprocess\ndef ping(target):\n process = subprocess.Popen('ping %s' % target, stdout = subprocess.PIPE)\n results = process.communicate()[0]\n ret... | [
0
] | [] | [] | [
"python"
] | stackoverflow_0005231416_python.txt |
Q:
Python Last Iteration in For Loop
Is there any simple way to find the Last Iteration of the for Loop in Python? I just want to convert a list to CSV.
A:
To convert a list to CSV, use the join-function:
>>> lst = [1,2,3,4]
>>> ",".join(str(item) for item in lst)
"1,2,3,4"
If the list already contains only string... | Python Last Iteration in For Loop | Is there any simple way to find the Last Iteration of the for Loop in Python? I just want to convert a list to CSV.
| [
"To convert a list to CSV, use the join-function:\n>>> lst = [1,2,3,4]\n>>> \",\".join(str(item) for item in lst)\n\"1,2,3,4\"\n\nIf the list already contains only string, you just do \",\".join(l).\n",
"Your best solution is probably to use the csv module, as suggested elsewhere. However, to answer your question... | [
13,
13,
12,
9,
5
] | [] | [] | [
"python"
] | stackoverflow_0005231040_python.txt |
Q:
Calculating point-wise mutual information (PMI) score for n-grams in Python
I have a large corpus of n-grams and several external n-grams. I want to calculate the PMI score of each external n-gram based on this corpus (the counts).
Are there any tools to do this or can someone provide me with a piece of code in P... | Calculating point-wise mutual information (PMI) score for n-grams in Python | I have a large corpus of n-grams and several external n-grams. I want to calculate the PMI score of each external n-gram based on this corpus (the counts).
Are there any tools to do this or can someone provide me with a piece of code in Python that can do this?
The problem is that my n-grams are 2-grams, 3-grams, 4-gr... | [
"If I'm understanding your problem correctly, you want to compute things like log { P(\"x1 x2 x3 x4 x5\") / P(\"x1\") P(\"x2\") ... P(\"x5\") } where P measures the probability that any given 5-gram or 1-gram is a given thing (and is basically a ratio of counts, perhaps with Laplace-style offsets). So, make a singl... | [
5
] | [] | [] | [
"n_gram",
"python"
] | stackoverflow_0005231627_n_gram_python.txt |
Q:
Problem with installing Node.JS on Windows
I'm trying to install Node.JS on Windows 7 with help of this tutorial.
I downloaded Cygwin, installed it. I have installed Python 2.7.
After this i downloaded last version of Node.JS in tar.gz. Than I opened cygwin bash and typed this command there:
tar zxvf node<tab>
It... | Problem with installing Node.JS on Windows | I'm trying to install Node.JS on Windows 7 with help of this tutorial.
I downloaded Cygwin, installed it. I have installed Python 2.7.
After this i downloaded last version of Node.JS in tar.gz. Than I opened cygwin bash and typed this command there:
tar zxvf node<tab>
It unzipped it to directory: node-v0.4.2
But what ... | [
"Did you install all the required packages? Run setup.exe again and check.\n",
"I think the issue might be that the environment variables in Cygwin need to be configured:\nGetting Make to place nice with Cygwin\n"
] | [
2,
0
] | [] | [] | [
"cygwin",
"javascript",
"node.js",
"python",
"windows"
] | stackoverflow_0005231805_cygwin_javascript_node.js_python_windows.txt |
Q:
Deploy Django (mod_python)
FIXED
my setup:
apache + mod_python
VPS with CentOS
django 1.2.5
I have uploaded my files to /mysite
and set httpd.conf as followed:
< VirtualHost *:80 >
DocumentRoot /var/www/html/domain
ServerName www.domain.com
ServerAlias domain.com
#django...
<Location "/mysite... | Deploy Django (mod_python) | FIXED
my setup:
apache + mod_python
VPS with CentOS
django 1.2.5
I have uploaded my files to /mysite
and set httpd.conf as followed:
< VirtualHost *:80 >
DocumentRoot /var/www/html/domain
ServerName www.domain.com
ServerAlias domain.com
#django...
<Location "/mysite">
SetHandler python-pro... | [
"You are defining the handler for www.domain.com/mysite\nHave you tried to access that URL?\nIf you want www.domain.com showing your mysite app use\n<Location \"/\">\n ...\n # remove django.root /mysite\n</Location>\n\nEDIT\nTo your second problem: mysite.settings is not in your python path. Either add '/var/... | [
1
] | [] | [] | [
"apache",
"django",
"python"
] | stackoverflow_0005232106_apache_django_python.txt |
Q:
503 error while deploying Google App Engine application
I am trying to deploy an application on Google App Engine. While using appcfg.py to update my application, it is showing the following error:
Precompilation starting.
Error 503: --- begin server output ---
Try Again (503)
An unexpected failure has occurred. P... | 503 error while deploying Google App Engine application | I am trying to deploy an application on Google App Engine. While using appcfg.py to update my application, it is showing the following error:
Precompilation starting.
Error 503: --- begin server output ---
Try Again (503)
An unexpected failure has occurred. Please try again.
--- end server output ---
Precompilation fai... | [
"I believe this is just temporary. See here.\n"
] | [
2
] | [] | [] | [
"google_app_engine",
"http_status_code_503",
"python"
] | stackoverflow_0005232216_google_app_engine_http_status_code_503_python.txt |
Q:
How to access dictionary values in django template
How to access the dictionary value in django template? I want to get the value of the variable a actually
class Emp(models.Model):
name = models.CharField(max_length=255, unique=True)
address1 = models.CharField(max_length=255)
def get_names(self):
na... | How to access dictionary values in django template | How to access the dictionary value in django template? I want to get the value of the variable a actually
class Emp(models.Model):
name = models.CharField(max_length=255, unique=True)
address1 = models.CharField(max_length=255)
def get_names(self):
names = {}
names_desc = {}
nbl = {}
names.upda... | [
"{{ emp.get_names.names.a }} will get you 1 in the template\n\n{{ emp.get_names.names }} will get you {'A':1} in the template\n\n{{ emp.get_names }} will get you {'names_desc': {'b': 2}, 'names': {'a': 1}} in the template\n\n",
"{{emp.get_names}} \nThis will return the whole 'nb1' dict.\nYou should go with the se... | [
9,
1
] | [] | [] | [
"django",
"django_models",
"django_templates",
"django_views",
"python"
] | stackoverflow_0005232236_django_django_models_django_templates_django_views_python.txt |
Q:
Create two columns of dynamic lists sorted vertically (IE7 Float problem)
I am wondering what the best way to create two columns of dynamic lists would be?
I have been able to create two columns of lists sorted vertically with column 1 being floated to the left and column 2 starting at the top level with column 1.... | Create two columns of dynamic lists sorted vertically (IE7 Float problem) | I am wondering what the best way to create two columns of dynamic lists would be?
I have been able to create two columns of lists sorted vertically with column 1 being floated to the left and column 2 starting at the top level with column 1. However in IE7, it doesn't seem to like the float and ends up starting on the ... | [
"I can't find a quick solution to fix this behaviour in IE7 (it does work in IE8 and above, FF and Chrome) but you could just split the <ul> element into two and float the first one. That should work in every browser that knows the float attribute.\n",
"Try this\n.location-wrapper {\n margin:0;\n width:42em... | [
1,
0
] | [] | [] | [
"css",
"django",
"python",
"xhtml"
] | stackoverflow_0005224214_css_django_python_xhtml.txt |
Q:
Lambda and functions in Python
I have beginner two questions
What does *z or *foo or **foo mean regarding function in Python.
This works - a = lambda *z :z But this does not - a = lambda **z: z. Because it is supposed to take 0 arguments. What does this actually mean?
A:
*z and **z in Python refer to args and k... | Lambda and functions in Python | I have beginner two questions
What does *z or *foo or **foo mean regarding function in Python.
This works - a = lambda *z :z But this does not - a = lambda **z: z. Because it is supposed to take 0 arguments. What does this actually mean?
| [
"*z and **z in Python refer to args and kwargs. args are positional arguments and kwargs are keyword arguments. lambda **z doesn't work in your example because z isn't a keyword argument: it's merely positional. Compare these different results:\n >>> a = lambda z: z\n >>> b = lambda *z: z\n >>> c = lambda ... | [
20,
4,
4,
2
] | [] | [] | [
"python"
] | stackoverflow_0005232719_python.txt |
Q:
gtk custom spin button
I want to make a gtk SpinButton, but for inputting dates.
Is there an easier way to input dates into GTK?
If not, how can I create a SpinButton look-alike, but whose output is text representing dates instead of integers? Ideally I'd re-use the arrows, the clicks, the integration with the ad... | gtk custom spin button | I want to make a gtk SpinButton, but for inputting dates.
Is there an easier way to input dates into GTK?
If not, how can I create a SpinButton look-alike, but whose output is text representing dates instead of integers? Ideally I'd re-use the arrows, the clicks, the integration with the adjustment, etc. I really just... | [
"The calendar is a bit large, but you can find code putting it in a popup. Personally I use a regular text entry and parse the date.\nAs for SpinButton, it is based on a text entry, so you might be able to modify its display only by fiddling with inherited signals and returning False. See also the update-policy and... | [
3,
2,
2
] | [] | [] | [
"gtk",
"pygtk",
"python",
"user_interface"
] | stackoverflow_0004404825_gtk_pygtk_python_user_interface.txt |
Q:
gtk create small up + down buttons as in a gtk.SpinButton
Related to this, but more specific: how can I create tiny button widgets like in a gtk.SpinButton?
A:
This is also my question for many monthes.
You can use gtk.Arrow, unless that's not exactly the same as SpinButton.
| gtk create small up + down buttons as in a gtk.SpinButton | Related to this, but more specific: how can I create tiny button widgets like in a gtk.SpinButton?
| [
"This is also my question for many monthes.\nYou can use gtk.Arrow, unless that's not exactly the same as SpinButton.\n"
] | [
0
] | [] | [] | [
"gtk",
"pygtk",
"python",
"user_interface"
] | stackoverflow_0004404859_gtk_pygtk_python_user_interface.txt |
Q:
How to override an app in Django properly?
I'm running Satchmo. There are many apps and I've changed some of the source in the Product app.
So my question is how can I override this properly because the change is site specific. Do I have to copy over the whole Satchmo framework and put it into my project or can I... | How to override an app in Django properly? | I'm running Satchmo. There are many apps and I've changed some of the source in the Product app.
So my question is how can I override this properly because the change is site specific. Do I have to copy over the whole Satchmo framework and put it into my project or can I just copy one of the apps out and place it in s... | [
"What I have done which works is to copy the application that I have changed. In this case satchmo\\apps\\product. \nI copied the app into my project folder\nAmended my setting.py INSTALLED_APPS from 'product', to 'myproject.product',\nThis now carries the changes I've made to this app for this project only and lea... | [
5,
4,
2
] | [] | [] | [
"django",
"python",
"satchmo"
] | stackoverflow_0005135453_django_python_satchmo.txt |
Q:
Is there a library for large precision complex numbers in Python?
Is there a library for large precision complex numbers in Python?
A:
Take a look at mpmath which offers real and complex floating-point arithmetic with arbitrary precision.
A:
You can also try numpy.
| Is there a library for large precision complex numbers in Python? | Is there a library for large precision complex numbers in Python?
| [
"Take a look at mpmath which offers real and complex floating-point arithmetic with arbitrary precision.\n",
"You can also try numpy.\n"
] | [
3,
0
] | [] | [] | [
"complex_numbers",
"largenumber",
"python"
] | stackoverflow_0005231798_complex_numbers_largenumber_python.txt |
Q:
How to save a dictionary containing utf-8 characters as its keys to a file with cPickle Python?
I want to know How to save a dictionary containing utf-8 characters as its keys to a file in Python with cPickle? this dictionary is very large and I've heard that cPickle is much faster than pickle. Also I suppose havi... | How to save a dictionary containing utf-8 characters as its keys to a file with cPickle Python? | I want to know How to save a dictionary containing utf-8 characters as its keys to a file in Python with cPickle? this dictionary is very large and I've heard that cPickle is much faster than pickle. Also I suppose having utf-8 encoded keys is also problematic.
Any other fast solutions are also welcome.
here is what I ... | [
"\nPickle is a binary format, so you shouldn't open the file with any codecs, just:\nfile('ngram_dict', 'w')\n\nIt's not a reason it's failing, just quite inefficient.\nThe actual problem is the object you are trying to save contains a function reference\n(the default value lambda: 0) and pickle format does not sup... | [
2,
0
] | [] | [] | [
"dictionary",
"pickle",
"python"
] | stackoverflow_0005233020_dictionary_pickle_python.txt |
Q:
Python replication of Java web applic?
Can this Java web applic be replicated in Python and/or related toolkit (e.g., AI-Labs's Orange)?:
http://www.xjtek.com/anylogic/demo_models/38/
A:
Check out GarlicSim as well.
| Python replication of Java web applic? | Can this Java web applic be replicated in Python and/or related toolkit (e.g., AI-Labs's Orange)?:
http://www.xjtek.com/anylogic/demo_models/38/
| [
"Check out GarlicSim as well.\n"
] | [
1
] | [] | [] | [
"data_visualization",
"java",
"python",
"simulation",
"statistics"
] | stackoverflow_0004578170_data_visualization_java_python_simulation_statistics.txt |
Q:
Load Pymacs & Ropemacs only when opening a Python file?
I use Pymacs to load ropemacs and rope with the following lines in my .emacs file as described here.
(autoload 'pymacs-load "pymacs" nil t)
(pymacs-load "ropemacs" "rope-")
It however slows down the start-up of Emacs significantly as it takes a while to load... | Load Pymacs & Ropemacs only when opening a Python file? |
I use Pymacs to load ropemacs and rope with the following lines in my .emacs file as described here.
(autoload 'pymacs-load "pymacs" nil t)
(pymacs-load "ropemacs" "rope-")
It however slows down the start-up of Emacs significantly as it takes a while to load Ropemacs.
I tried the following line instead but that load... | [
"\nIn my .emacs I have:\n(autoload 'python-mode \"my-python-setup\" \"\" t)\n\nAnd in a separate file my-python-setup.el I keep:\n(require 'python)\n(add-to-list 'auto-mode-alist '(\"\\\\.py\\\\'\" . python-mode))\n;; Initialize Pymacs\n(autoload 'pymacs-apply \"pymacs\")\n(autoload 'pymacs-call \"pymacs\")\n(autol... | [
9,
2,
1
] | [] | [] | [
"emacs",
"pymacs",
"python",
"ropemacs"
] | stackoverflow_0002890199_emacs_pymacs_python_ropemacs.txt |
Q:
Getting wikipedia abstracts only
I have searched around but not gotten much help. Here's my problem. I want to start from a portal page on wikipedia, say Computer_science and go its categories pages. There are some pages in that category and there are links to subcategories. I will visit some of these pages and ge... | Getting wikipedia abstracts only | I have searched around but not gotten much help. Here's my problem. I want to start from a portal page on wikipedia, say Computer_science and go its categories pages. There are some pages in that category and there are links to subcategories. I will visit some of these pages and get the page abstracts alone. Then go to... | [
"There isn't necessarily a category corresponding to a portal, although you could try looking for a category with the same name as the portal, the categories the portal page is in (using the API, you can query this with prop=categories), or the category pages linked from the portal page (prop=links&plnamespace=14).... | [
3,
1,
1,
1
] | [] | [] | [
"javascript",
"parsing",
"python",
"web_crawler",
"wikipedia"
] | stackoverflow_0005231671_javascript_parsing_python_web_crawler_wikipedia.txt |
Q:
Unmasking last printed expression variable
I have just started studying Python.
I am referring to the tutorials at http://docs.python.org/tutorial/
Quoting from the tutorial about the variable _
This variable should be treated as
read-only by the user. Don’t
explicitly assign a value to it — you
would creat... | Unmasking last printed expression variable | I have just started studying Python.
I am referring to the tutorials at http://docs.python.org/tutorial/
Quoting from the tutorial about the variable _
This variable should be treated as
read-only by the user. Don’t
explicitly assign a value to it — you
would create an independent local
variable with the same ... | [
"del _ unmasks the redefined _:\n>>> 7*2\n>>> _\n14\n>>> _ = 88\n>>> _\n88\n>>> 1+2\n3\n>>> _\n88\n>>> del _\n>>> _\n88\n>>> 1+2\n3\n>>> _\n3\n\n",
"del _ will do it.\nIn [1]: _ = 1\n\nIn [2]: _\nOut[2]: 1\n\nIn [3]: 2\nOut[3]: 2\n\nIn [4]: _\nOut[4]: 1\n\nIn [5]: del _\n\nIn [6]: 3\nOut[6]: 3\n\nIn [7]: _\nOut[7... | [
3,
2,
1
] | [] | [] | [
"python",
"variables"
] | stackoverflow_0005233885_python_variables.txt |
Q:
beautiful soup malformed start tag error
>>> soup = BeautifulSoup( data )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/pymodules/python2.6/BeautifulSoup.py", line 1499, in __init__
BeautifulStoneSoup.__init__(self, *args, **kwargs)
File "/usr/l... | beautiful soup malformed start tag error | >>> soup = BeautifulSoup( data )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/pymodules/python2.6/BeautifulSoup.py", line 1499, in __init__
BeautifulStoneSoup.__init__(self, *args, **kwargs)
File "/usr/lib/pymodules/python2.6/BeautifulSoup.py", line... | [
"Pyparsing has some HTML tag support that makes for more robust scripts than just straight RE's. And since it doesn't try to parse/process the entire HTML body but instead just looks for matching string expressions, it can handle badly formed HTML:\nhtml = \"\"\"<script> \nregisterImage(\"original_image\", \n\"t... | [
2,
0
] | [] | [] | [
"beautifulsoup",
"html_parsing",
"python"
] | stackoverflow_0005232199_beautifulsoup_html_parsing_python.txt |
Q:
calling python function from django template tags
How can we pass a variable from a django template tag i.e, i want to do something like this
{{emp.get_names('a')}}
emp is the object that i am passing from my views
class Emp(models.Model):
name = models.CharField(max_length=255, unique=True)
address1 = m... | calling python function from django template tags | How can we pass a variable from a django template tag i.e, i want to do something like this
{{emp.get_names('a')}}
emp is the object that i am passing from my views
class Emp(models.Model):
name = models.CharField(max_length=255, unique=True)
address1 = models.CharField(max_length=255)
def get_names(self,... | [
"You can not call a function that takes a parameter like that. Maybe writing a custom template tag can help, but, why do you need to do it in the template, but not in the view??\nCustom template tags\n",
"Django templates are designed to prevent people from doing what you are trying to do. Use a template tag.\n",... | [
4,
1,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0005233841_django_python.txt |
Q:
Triple quote escape ambiguity
>>> sample7 = """including 'quote1' "quote2" and 'quote3" """
>>> sample7
'including \'quote1\' "quote2" and \'quote3" '
>>> print sample7
including 'quote1' "quote2" and 'quote3"
Here, the quotes inside the string sample7 was properly escaped by the triple quotes. But,
>>> sample4 ... | Triple quote escape ambiguity | >>> sample7 = """including 'quote1' "quote2" and 'quote3" """
>>> sample7
'including \'quote1\' "quote2" and \'quote3" '
>>> print sample7
including 'quote1' "quote2" and 'quote3"
Here, the quotes inside the string sample7 was properly escaped by the triple quotes. But,
>>> sample4 = """c:\ntext\text\file.rtf"""
>>> ... | [
"Python is evaluating \\f Just use raw strings\nr\"c:\\ntext\\text\\file.rtf\"\n\n"
] | [
7
] | [] | [] | [
"python",
"string"
] | stackoverflow_0005234081_python_string.txt |
Q:
Python Variable Scope (passing by reference or copy?)
Why does the variable L gets manipulated in the sorting(L) function call? In other languages, a copy of L would be passed through to sorting() as a copy so that any changes to x would not change the original variable?
def sorting(x):
A = x #Passed by ref... | Python Variable Scope (passing by reference or copy?) | Why does the variable L gets manipulated in the sorting(L) function call? In other languages, a copy of L would be passed through to sorting() as a copy so that any changes to x would not change the original variable?
def sorting(x):
A = x #Passed by reference?
A.sort()
def testScope():
L = [5,4,3,2,1... | [
"Long story short: Python uses pass-by-value, but the things that are passed by value are references. The actual objects have 0 to infinity references pointing at them, and for purposes of mutating that object, it doesn't matter who you are and how you got a reference to the object.\nGoing through your example step... | [
21,
11,
1,
0
] | [] | [] | [
"python",
"scope"
] | stackoverflow_0005234126_python_scope.txt |
Q:
Xpath not finding elements past the first
I'm working on a scraper using xpath, but xpath seems inexplicably incapable of retreiving the information that I need. I've been able to get the below code to print out the table element and all of its contents, but as soon as I try to go to the tbody or tr elements, it ... | Xpath not finding elements past the first | I'm working on a scraper using xpath, but xpath seems inexplicably incapable of retreiving the information that I need. I've been able to get the below code to print out the table element and all of its contents, but as soon as I try to go to the tbody or tr elements, it starts returning None. You can see the url be... | [
"Firefox adds the implicit tbody inside the table element, but this doesn't exist in the source HTML for that page. This XPATH should work to find all the tr tags:\nfor node in page.xpath('.//table[@class=\"gridtable\"]/tr'):\n\n"
] | [
2
] | [] | [] | [
"lxml",
"python",
"xpath"
] | stackoverflow_0005234128_lxml_python_xpath.txt |
Q:
How do I raise a custom exception from a package __init__?
I have a package __init__.py that looks something like this:
import sys
__required_python_version = (2,6, 0)
if sys.version_info < __required_python_version:
this_version = '.'.join([str(x) for x in sys.version_info[0:3]])
required_version = '.'.... | How do I raise a custom exception from a package __init__? | I have a package __init__.py that looks something like this:
import sys
__required_python_version = (2,6, 0)
if sys.version_info < __required_python_version:
this_version = '.'.join([str(x) for x in sys.version_info[0:3]])
required_version = '.'.join([str(x) for x in __required_python_version])
raise Pyth... | [
"Since it looks like you won't have any user for that exception -- \nunless this module is to be used by other modules you are impleemnting as part of a larger system, I say you don't need a custom exception here.\nThere is very little to gain from it, apart from the error message given. Ay module trying to import ... | [
3,
2
] | [] | [] | [
"python"
] | stackoverflow_0005234233_python.txt |
Q:
while loop python question
The following is a method in a particular class that creates a simple calculator in python. It's intended to wait for a button to be clicked and return the label of that that button:
def getButton(self):
while True:
p = self.win.getMouse()
for b in self.buttons:
... | while loop python question | The following is a method in a particular class that creates a simple calculator in python. It's intended to wait for a button to be clicked and return the label of that that button:
def getButton(self):
while True:
p = self.win.getMouse()
for b in self.buttons:
if b.clicked(p):
... | [
"This is an example of a busy wait. This program will get stuck in this loop, eternally checking to see if any button b in self.buttons has been clicked. At this point, it will break from the busy wait to return b's label.\nSo, in essence, it's not testing for anything. It's just waiting until a condition is met... | [
4,
2,
1,
1,
1,
0
] | [] | [] | [
"python",
"while_loop"
] | stackoverflow_0005234471_python_while_loop.txt |
Q:
Python Get function parent attribute
I have a function in python that return an inner function
def parent_func(func):
def decorator(a,b):
return a + b
return decorator
for simplify lets consider this code
def in_func ( a, b)
return a*b
child = parent_func ( in_func)
Does someone know a way to ... | Python Get function parent attribute | I have a function in python that return an inner function
def parent_func(func):
def decorator(a,b):
return a + b
return decorator
for simplify lets consider this code
def in_func ( a, b)
return a*b
child = parent_func ( in_func)
Does someone know a way to get the "func" attribute of parent_func fr... | [
"The func attribute only exists in the scope of the parent_func() function.\nIf you really need that value, you can expose it:\ndef parent_func(func):\n def decorator(a,b):\n return a + b\n\n decorator.original_function = func\n return decorator\n\nNext question is, why would you want to do that?\nW... | [
2,
0
] | [] | [] | [
"python"
] | stackoverflow_0005234609_python.txt |
Q:
urllib2 is throwing an error for an url , while it's opening properly in browser
I am trying to open an url through python like this
import urllib2
f = urllib2.urlopen('http://www.futurebazaar.com/Search/laptop')
It's throwing following error
File "C:\Python26\lib\urllib2.py",
line 1134, in do_open
... | urllib2 is throwing an error for an url , while it's opening properly in browser | I am trying to open an url through python like this
import urllib2
f = urllib2.urlopen('http://www.futurebazaar.com/Search/laptop')
It's throwing following error
File "C:\Python26\lib\urllib2.py",
line 1134, in do_open
r = h.getresponse() File "C:\Python26\lib\httplib.py", line
986, in getresponse
... | [
"The website is broken. If the optional \"Accept\" header isn't supplied, the site closes the connection without responding; this is invalid behavior.\nWorkaround:\nimport urllib2\nreq = urllib2.Request('http://www.futurebazaar.com/Search/laptop')\nreq.add_header('Accept', '*/*')\nf = urllib2.urlopen(req)\n\n"
] | [
5
] | [] | [] | [
"python",
"urllib2"
] | stackoverflow_0005234944_python_urllib2.txt |
Q:
Python's `urlparse`: Adding GET keywords to a URL
I'm doing this:
urlparse.urljoin('http://example.com/mypage', '?name=joe')
And I get this:
'http://example.com/?name=joe'
While I want to get this:
'http://example.com/mypage?name=joe'
What am I doing wrong?
A:
You could use urlparse.urlunparse :
import urlpar... | Python's `urlparse`: Adding GET keywords to a URL | I'm doing this:
urlparse.urljoin('http://example.com/mypage', '?name=joe')
And I get this:
'http://example.com/?name=joe'
While I want to get this:
'http://example.com/mypage?name=joe'
What am I doing wrong?
| [
"You could use urlparse.urlunparse :\nimport urlparse\nparsed = list(urlparse.urlparse('http://example.com/mypage'))\nparsed[4] = 'name=joe'\nurlparse.urlunparse(parsed)\n\n",
"You're experiencing a known bug which affects Python 2.4-2.6. \nIf you can't change or patch your version of Python, @jd's solution will ... | [
5,
1,
1,
0
] | [] | [] | [
"python",
"url",
"urlparse"
] | stackoverflow_0005232743_python_url_urlparse.txt |
Q:
failed to interpret date regular expression
GetUsage/08-03-2011
to match this url i have used following regular expression in urls.py ( python & django)
('^GetData/((0?[1-9]|[12][0-9]|3[01])[- /.](0?[1-9]|1[012])[- /.](19|20)?[0-9]{2})*',GetData)
and inside the views.py following method is configured to accept th... | failed to interpret date regular expression | GetUsage/08-03-2011
to match this url i have used following regular expression in urls.py ( python & django)
('^GetData/((0?[1-9]|[12][0-9]|3[01])[- /.](0?[1-9]|1[012])[- /.](19|20)?[0-9]{2})*',GetData)
and inside the views.py following method is configured to accept the date
def GetDataData(request,sdate):
but when ... | [
"Each regexp group within () is being passed to GetData() as an argument. If you don't want groups to be generated by some of them, but still want to use parens, use (?:whatever) for non-grouping parens.\nEDIT: You probably want something like:\n('^GetData/((?:0?[1-9]|[12][0-9]|3[01])[- /.](?:0?[1-9]|1[012])[- /.]... | [
2
] | [] | [] | [
"django",
"python",
"regex"
] | stackoverflow_0005235479_django_python_regex.txt |
Q:
How to stop a TimerService from within the LoopingCall
Background
I've recently been a part of a project where twisted was used. We utilized a TimerService to daemonize a process. And yes, I realize that this approach may have been overkill, but we're trying to stay consistent and use a proven framework. Yester... | How to stop a TimerService from within the LoopingCall | Background
I've recently been a part of a project where twisted was used. We utilized a TimerService to daemonize a process. And yes, I realize that this approach may have been overkill, but we're trying to stay consistent and use a proven framework. Yesterday, an exception went unhandled within the LoopingCall whic... | [
"You can't stop the reactor before it starts:\n>>> from twisted.internet import reactor\n>>> reactor.stop()\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\n File \"/home/exarkun/Projects/Twisted/branches/simplify-ssl-4905/twisted/internet/base.py\", line 570, in stop\n \"Can't stop... | [
5
] | [] | [] | [
"python",
"twisted"
] | stackoverflow_0005235263_python_twisted.txt |
Q:
Problem with creating variable in loop
I'm learning python with a book that teaches by creating games. I have to write the code so I input a number and the computer makes educated guesses based on higher or lower input. I keep getting an error after inputting my number:
Traceback (most recent call last):
File "... | Problem with creating variable in loop | I'm learning python with a book that teaches by creating games. I have to write the code so I input a number and the computer makes educated guesses based on higher or lower input. I keep getting an error after inputting my number:
Traceback (most recent call last):
File "C:\Users\Rayvenx\Desktop\My_programs\Number_... | [
"highlow = raw_input(\"\\nIs it %s?:\"%guess)\n\nOr, using the format method (introduced in Python 2.6):\nhighlow = raw_input(\"\\nIs it {0}?:\".format(guess))\n\nOr, using if Python3:\nhighlow = raw_input(\"\\nIs it {}?:\".format(guess))\n\n",
"This line is passing 3 arguments.\nhighlow = raw_input(\"\\nIs it\",... | [
1,
1,
0
] | [] | [] | [
"loops",
"python"
] | stackoverflow_0005235527_loops_python.txt |
Q:
What is the easiest way to compare two web pages using python?
Hello I want to Compare two webpages using python script.
how can i achieve it? thanks in advance!
A:
First, you want to retrieve both webpages. You can use wget, urlretrieve, etc.:
wget Vs urlretrieve of python
Second, you want to "compare" the page... | What is the easiest way to compare two web pages using python? | Hello I want to Compare two webpages using python script.
how can i achieve it? thanks in advance!
| [
"First, you want to retrieve both webpages. You can use wget, urlretrieve, etc.:\nwget Vs urlretrieve of python\nSecond, you want to \"compare\" the pages. You can use a \"diff\" tool as Chinmay noted. You can also do a keyword analysis of the two pages: \n\nParse all keywords from page. e.g. How do I extract k... | [
4,
2
] | [] | [] | [
"comparison",
"nlp",
"python"
] | stackoverflow_0005235537_comparison_nlp_python.txt |
Q:
Using both memcached and taskqueue on the google app engine
I am trying to achieve the above on the google apps engine, and was wondering if anyone knows of a project that this has already been done? or an example?
So far in my implementation I can write a single object to memory. However, I am having issues in us... | Using both memcached and taskqueue on the google app engine |
I am trying to achieve the above on the google apps engine, and was wondering if anyone knows of a project that this has already been done? or an example?
So far in my implementation I can write a single object to memory. However, I am having issues in using add_multi to input multiple objects.
Thanks for any help.
| [
"It looks like you're describing a write-behind cache. You should bear in mind that data can be evicted from memcache at any time, so there could easily be a window in which submitted data is not available, as it's been evicted from memcache and not yet written to the datastore. You should also be aware that there'... | [
3
] | [] | [] | [
"google_app_engine",
"memcached",
"python",
"task_queue"
] | stackoverflow_0005232771_google_app_engine_memcached_python_task_queue.txt |
Q:
How to find information from the last 24 hours
I'm a beginner in programming and I want to find the easiest way of doing this. I have information which has a line in it that shows when it was updated in UTC time, now i want to write my program to ask if info is within the last 24 hours than print the info. I'm wor... | How to find information from the last 24 hours | I'm a beginner in programming and I want to find the easiest way of doing this. I have information which has a line in it that shows when it was updated in UTC time, now i want to write my program to ask if info is within the last 24 hours than print the info. I'm working in Python 3, Thanks
import datetime
import url... | [
"Looking at the data being provided by USGS, it seems they already provide this info to you. For example, in the first entry I see <category label=\"Age\" term=\"Past day\"/>, while the last is <category label=\"Age\" term=\"Past week\"/>.\nAssuming you trust this information, you can extract it just as you do the... | [
2,
0
] | [] | [] | [
"datetime",
"python",
"python_3.x",
"utc"
] | stackoverflow_0005235761_datetime_python_python_3.x_utc.txt |
Q:
Securely storing account balances in a database?
So I have a Django web application and I need to add a payment module to it.
Basically a user will prepay for a certain amount of service and this will slowly reduce over as the user uses the service. I'm wondering what is the best practice to facilitate this? I can... | Securely storing account balances in a database? | So I have a Django web application and I need to add a payment module to it.
Basically a user will prepay for a certain amount of service and this will slowly reduce over as the user uses the service. I'm wondering what is the best practice to facilitate this? I can process payments using Satchmo, but then just storing... | [
"I don't know about a \"well-tested solution\" as you put it, but I would strongly caution against just storing a dollar value in the database and increasing or decreasing that dollar value. Instead, I would advise storing transactions that can be audited if anything goes wrong. Calculate the amount available fro... | [
6,
1
] | [] | [] | [
"database",
"django",
"python",
"web_applications"
] | stackoverflow_0005236855_database_django_python_web_applications.txt |
Q:
word frequency program in python
Say I have a list of words called words i.e. words = ["hello", "test", "string", "people", "hello", "hello"] and I want to create a dictionary in order to get word frequency.
Let's say the dictionary is called 'counts'
counts = {}
for w in words:
counts[w] = counts.get(w,0) + 1... | word frequency program in python | Say I have a list of words called words i.e. words = ["hello", "test", "string", "people", "hello", "hello"] and I want to create a dictionary in order to get word frequency.
Let's say the dictionary is called 'counts'
counts = {}
for w in words:
counts[w] = counts.get(w,0) + 1
The only part of this I don't really... | [
"If you have a dictionary, get() is a method where w is a variable holding the word you're looking up and 0 is the default value. If w is not present in the dictionary, get returns 0.\n",
"FWIW, with Python 2.7 and above you may prefer to operate with collections.Counter, like:\nIn []: from collections import Co... | [
7,
6,
4,
0
] | [] | [] | [
"dictionary",
"python",
"word_frequency"
] | stackoverflow_0005235916_dictionary_python_word_frequency.txt |
Q:
Python String Comparison--Problems With Special/Unicode Characters
I'm writing a Python script to process some music data. It's supposed to merge two separate databases by comparing their entries and matching them up. It's almost working, but fails when comparing strings containing special characters (i.e. accente... | Python String Comparison--Problems With Special/Unicode Characters | I'm writing a Python script to process some music data. It's supposed to merge two separate databases by comparing their entries and matching them up. It's almost working, but fails when comparing strings containing special characters (i.e. accented letters). I'm pretty sure it's a ASCII vs. Unicode encoding issue, as ... | [
"Unicode vs Bytes\nFirst, some terminology. There are two types of strings, encoded and decoded:\n\nEncoded. This is what's stored on disk. To Python, it's a bunch of 0's and 1's that you might treat like ASCII, but it could be anything -- binary data, a JPEG image, whatever. In Python 2.x, this is called a \"strin... | [
5,
0,
0,
0
] | [] | [] | [
"python",
"string"
] | stackoverflow_0005228925_python_string.txt |
Q:
Python/Numpy - Set Values within some Tolerance to the Value
If I have an array and I want to set values 'close' to some value as that value, what is the best way to do this? I'm wondering if their is a numpy function for this. If there is no numpy function, then is the code below the "best" (i.e. quickest/most ... | Python/Numpy - Set Values within some Tolerance to the Value | If I have an array and I want to set values 'close' to some value as that value, what is the best way to do this? I'm wondering if their is a numpy function for this. If there is no numpy function, then is the code below the "best" (i.e. quickest/most efficient) way to do this? It works for multi-dimensional arrays ... | [
"http://docs.scipy.org/doc/numpy/reference/generated/numpy.clip.html\n",
"It's not so quite clear what you are trying to achieve, but my interpretation is that around is the solution for your case.\n"
] | [
3,
3
] | [] | [] | [
"numpy",
"python"
] | stackoverflow_0005236879_numpy_python.txt |
Q:
Getting data from amazon.com + python
Basically I need to get data from amazon.com such as product and their prices just for viewing database design and then insert them in sql tables .
But how should i proceed in getting and parsing the data...
Can anybody lead me to the correct direction and even tell me the leg... | Getting data from amazon.com + python | Basically I need to get data from amazon.com such as product and their prices just for viewing database design and then insert them in sql tables .
But how should i proceed in getting and parsing the data...
Can anybody lead me to the correct direction and even tell me the legalities involved in the issue.
Thanks a lot... | [
"For parsing the HTML, you will want to use something like Beautiful Soup:\nhttp://www.crummy.com/software/BeautifulSoup/\nFor downloading the HTML, use urllib or urllib2, which is included in the Python standard library.\nFor legalese, talk to a lawyer. But the standard library does include a robotsparser library ... | [
1,
0
] | [] | [] | [
"mysql",
"python"
] | stackoverflow_0005236751_mysql_python.txt |
Q:
Fastest way to get pixel color in Python or C++?
I'm trying to add a blur effect to a transparent Tkinter widget I'm making.
I made the widget partially transparent with this line (snippet)
self.attributes("-alpha", 0.85)
In order to add the effect I desire I need to get the RGB values of each individual pixel in... | Fastest way to get pixel color in Python or C++? | I'm trying to add a blur effect to a transparent Tkinter widget I'm making.
I made the widget partially transparent with this line (snippet)
self.attributes("-alpha", 0.85)
In order to add the effect I desire I need to get the RGB values of each individual pixel in the widget. Seeing as the widget is only partially op... | [
"You may wish to take a look at the Python Image Library you could call something like this\nimport Image\nim = Image.open(\"name_of_file.jpg\")\nlist_of_pixels = list(im.getdata())\nprint list_of_pixels[0]\n\nThat would output the very first pixel in a RGB format like (255,255,255)\nIt is pretty fast but it wont e... | [
3
] | [] | [] | [
"blur",
"c++",
"pixel",
"python",
"tkinter"
] | stackoverflow_0004836925_blur_c++_pixel_python_tkinter.txt |
Q:
Need to recall a TAG to refresh the DIV the TAG created with new DATA, how to do it?
I have a generated html page ("ContactMaster.html") from a view. ContactMaster.html uses a custom template tag to create a FORM within a DIV.
The custom template tag (%form% --- %endform%) creates a DIV that contains an empty f... | Need to recall a TAG to refresh the DIV the TAG created with new DATA, how to do it? | I have a generated html page ("ContactMaster.html") from a view. ContactMaster.html uses a custom template tag to create a FORM within a DIV.
The custom template tag (%form% --- %endform%) creates a DIV that contains an empty form generated from a model ..
- class PrefixForm(ModelForm)
class Meta:
... | [
"If you have the page allready loaded and do not want to reload the compelete page, you will definitely need AJAX. That's exactly what the first A (asynchronous) of that abbreviation stands: loading content without reloading the complete page. As far as i can see you will have to extend your view as well. You can f... | [
0
] | [] | [] | [
"ajax",
"django",
"python"
] | stackoverflow_0005236238_ajax_django_python.txt |
Q:
Beautiful Soup - identify tag based on position next to comment
I'm using Beautiful Soup.
Is there any way that I can get hold of a tag based on its position next to a comment (something not included in the parse tree)?
For example, let's say I have...
<html>
<body>
<p>paragraph 1</p>
<p>paragraph 2</p>
<!--text-... | Beautiful Soup - identify tag based on position next to comment | I'm using Beautiful Soup.
Is there any way that I can get hold of a tag based on its position next to a comment (something not included in the parse tree)?
For example, let's say I have...
<html>
<body>
<p>paragraph 1</p>
<p>paragraph 2</p>
<!--text-->
<p>paragraph 3</p>
</body>
</html>
In this example, how might I i... | [
"Comments appear in the BeautifulSoup parse tree like any other node. For example, to find the comment with the text some comment text and then print out the previous <p> element you could do:\nfrom BeautifulSoup import BeautifulSoup, Comment\n\nsoup = BeautifulSoup('''<html>\n<body>\n<p>paragraph 1</p>\n<p>paragr... | [
6
] | [] | [] | [
"beautifulsoup",
"python"
] | stackoverflow_0005237273_beautifulsoup_python.txt |
Q:
What's a good way to load and store data in global constants for caching in Django?
How do you normally load and store stuff from the DB in global constants for caching during initialisation? The global constants will not change again later.
Do you just make the DB query during load time and put it in a constant, ... | What's a good way to load and store data in global constants for caching in Django? | How do you normally load and store stuff from the DB in global constants for caching during initialisation? The global constants will not change again later.
Do you just make the DB query during load time and put it in a constant, or use a lazy loading mechanism of some sort?
What I have in mind is code in the global s... | [
"Django has a cache framework that you could use.\nhttp://docs.djangoproject.com/en/dev/topics/cache/\nIt's got a low level caching api that does what you want.\nfrom django.core.cache import cache\ncache.set('my_key', 'hello, world!', 30)\ncache.get('my_key')\n\nTo use it, you'd do something like\nif cache.get(\"k... | [
2,
0
] | [] | [] | [
"caching",
"database",
"django",
"memoization",
"python"
] | stackoverflow_0005236013_caching_database_django_memoization_python.txt |
Q:
Setting an Excel Range with an Array using Python and comtypes?
Using comtypes to drive Python, it seems some magic is happening behind the scenes that is not converting tuples and lists to VARIANT types:
# RANGE(“C14:D21”) has values
# Setting the Value on the Range with a Variant should work, but
# list or tuple... | Setting an Excel Range with an Array using Python and comtypes? | Using comtypes to drive Python, it seems some magic is happening behind the scenes that is not converting tuples and lists to VARIANT types:
# RANGE(“C14:D21”) has values
# Setting the Value on the Range with a Variant should work, but
# list or tuple is not getting converted properly it seems
>>>from comtypes.client ... | [
"I've spent a lot of time trying to figure out a solution to this problem to be able to fully substitute python for matlab, reading on various different forums with no real direct answer. \nHere is my robust solution that works very well. I have to write daily/weekly/monthly/quarterly reports that write to xlsx a l... | [
5,
1
] | [] | [] | [
"arrays",
"com",
"excel",
"python",
"range"
] | stackoverflow_0002150017_arrays_com_excel_python_range.txt |
Q:
List comprehension on Python dict doesn't perform well
I have the following loop:
for row in rows:
print row.value('customer', 'name')
# print [customer for customer in customers if customer['name'] == row.value('customer', 'name')]
When I uncomment the second print, the loop runs much more slowly. Is there... | List comprehension on Python dict doesn't perform well | I have the following loop:
for row in rows:
print row.value('customer', 'name')
# print [customer for customer in customers if customer['name'] == row.value('customer', 'name')]
When I uncomment the second print, the loop runs much more slowly. Is there a way I can write this to make it perform faster?
My overal... | [
"\"It runs much more slowly\" because you are looking at the entire customer-list for each row.\nEither make a dictionary of customers and use a lookup:\ncustomerIndex = { customer['name']:customer for customer in customers }\nfor row in rows:\n name = row.value('customer','name')\n print name, customerIndex[... | [
4,
0
] | [] | [] | [
"python"
] | stackoverflow_0005237485_python.txt |
Q:
How to aggreate in html django
Wrote a excel format html metrics to represent the date wise counts
def get_detail(usr,dt):
res = Dataset.objects.filter(user = usr, date = dt).values('expense')
try :
output=res[0]['expense']
except IndexError:
output=" "
return output
above code is a functi... | How to aggreate in html django | Wrote a excel format html metrics to represent the date wise counts
def get_detail(usr,dt):
res = Dataset.objects.filter(user = usr, date = dt).values('expense')
try :
output=res[0]['expense']
except IndexError:
output=" "
return output
above code is a function
def metrics_new(request, year = ... | [
"Remove all the HTML creating code from the view. \nThe view needs to create the needed variables for the template, and the template should deal with formatting. Perhaps create a list of users, and for each user, a list of length calendar.mdays[month], containing the expanses of this user, and a sum variable.\nuser... | [
0
] | [] | [] | [
"django",
"django_templates",
"django_views",
"python"
] | stackoverflow_0005223093_django_django_templates_django_views_python.txt |
Q:
Should sockets be non-blocking to work with select in Python?
Should sockets be set to non-blocking when used with select.select in Python?
What difference does it make if they are or aren't?
Occasionally I find that calling send on a socket that returns sendable will block. Furthermore I find that blocking socke... | Should sockets be non-blocking to work with select in Python? |
Should sockets be set to non-blocking when used with select.select in Python?
What difference does it make if they are or aren't?
Occasionally I find that calling send on a socket that returns sendable will block. Furthermore I find that blocking sockets will generally send the whole buffer given (128 KiB). In non-bl... | [
"The answer might be OS dependent unfortunately. I'm replying only regarding Linux.\nI'm not aware of differences regarding blocking/non-blocking sockets in select, but on linux, the select system call man page has this in it 'BUGS' section:\n\nUnder Linux, select() may report a\n socket file descriptor as \"r... | [
5
] | [] | [] | [
"blocking",
"python",
"python_3.x",
"select",
"sockets"
] | stackoverflow_0005237733_blocking_python_python_3.x_select_sockets.txt |
Q:
Use smart builders or a lot of schedulers to compile and test 5 builds
I want to setup a continuous integration environment with three operating systems (MacOSX, Windows and Linux). I need to build five different builds: win32bit, win64bit, lin32bit, lin64bit, and mac. For each build I need to make the following s... | Use smart builders or a lot of schedulers to compile and test 5 builds | I want to setup a continuous integration environment with three operating systems (MacOSX, Windows and Linux). I need to build five different builds: win32bit, win64bit, lin32bit, lin64bit, and mac. For each build I need to make the following steps:
-compile
-put some files in the binary folder
-make a 7z-archive of th... | [
"This kind of thing is handled nicely by Ant and Cruise Control on the Java side.\nI wonder if PyAnt could help you with Python.\n",
"You pretty much can't beat Hudson (now called Jenkins) as a Continuous Integration system for Python. Google for 'hudson python'.\n",
"Instead of using single builder for both 3... | [
0,
0,
0
] | [] | [] | [
"buildbot",
"continuous_integration",
"python"
] | stackoverflow_0004903017_buildbot_continuous_integration_python.txt |
Q:
Uploading a Single Static File to GAE Using app.yaml
Greetings,
I am trying to upload two single static files (a CSS & an HTML) to my appspot. However, they're in the root directory. I've tried static_dir and static_files but they don't work.
What I'm trying to do is to upload page.html to /site/ but I have it on ... | Uploading a Single Static File to GAE Using app.yaml | Greetings,
I am trying to upload two single static files (a CSS & an HTML) to my appspot. However, they're in the root directory. I've tried static_dir and static_files but they don't work.
What I'm trying to do is to upload page.html to /site/ but I have it on root directory because I need it to be on the same dir as ... | [
"\\1 is replaced by the first matched group in the regular expression for the url. Your URL has no groups, so it will do nothing.\nYou can simply do:\n- url: /page.html\n static_files: page.html\n upload: /page.html\n- url: /page.css\n static_files: page.css\n upload: /page.css\n\n"
] | [
6
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0005238035_google_app_engine_python.txt |
Q:
Python - Dijsktra's Algorithm Distance Problem
I've run into a problem with my code, i'm not able to calculate the distance to a node from the starting node. I have a text file of the form:
1,2,3,4,5,6,7,8,9
1,2,3,4,5,6,7,8,9
This represents the node distances in the graph. Here is my code, unfortunately, despite... | Python - Dijsktra's Algorithm Distance Problem | I've run into a problem with my code, i'm not able to calculate the distance to a node from the starting node. I have a text file of the form:
1,2,3,4,5,6,7,8,9
1,2,3,4,5,6,7,8,9
This represents the node distances in the graph. Here is my code, unfortunately, despite trying a few different methods I still keep coming ... | [
"I have been programming the Dijkstra's Algorithm in Python a few months ago; its tested and it should work:\ndef dijkstra(u,graph):\n n = graph.numNodes\n l = { u : 0 } ; W = graph.V()\n F = [] ; k = {}\n for i in range(0,n):\n lv,v = min([ (l[lk],lk) for lk in l.keys() if lk in W ])\n W.remove... | [
0
] | [] | [] | [
"dijkstra",
"python"
] | stackoverflow_0005237855_dijkstra_python.txt |
Q:
python list confusion
hi i have a situation like this:
>>> def get():
... for i in range(3):
... yield [0]
...
and i want to get this: [0,0,0]
my code now works in this way:
>>> r = []
>>> r.extend(i[0] for i in get())
>>> r
[0, 0, 0]
but i don't like i[0]..
some advice?
(i'm on python3)
A:
Yo... | python list confusion | hi i have a situation like this:
>>> def get():
... for i in range(3):
... yield [0]
...
and i want to get this: [0,0,0]
my code now works in this way:
>>> r = []
>>> r.extend(i[0] for i in get())
>>> r
[0, 0, 0]
but i don't like i[0]..
some advice?
(i'm on python3)
| [
"Your code looks very strange, but I assume it's very simplified. If it's just about getting rid of the i[0], do this:\n>>> def get():\n... for i in range(3):\n... yield 0\n... \n>>> r = []\n>>> r.extend(get())\n>>> r\n[0, 0, 0]\n\n",
"To me, this looks like get can only ever return a list of leng... | [
2,
1,
1,
1,
0,
0,
0
] | [] | [] | [
"coding_style",
"list",
"python"
] | stackoverflow_0005193501_coding_style_list_python.txt |
Q:
Python library release best practices
I've written Python bindings using ctypes for the units library. The bindings themselves are only ~100 lines of Python. The library has an unnecessary (for the purposes of the Python bindings) dependency on tcl, and the configure script fails if tcl is absent. However, the lib... | Python library release best practices | I've written Python bindings using ctypes for the units library. The bindings themselves are only ~100 lines of Python. The library has an unnecessary (for the purposes of the Python bindings) dependency on tcl, and the configure script fails if tcl is absent. However, the library builds fine with gcc -Wl,-soname,units... | [
"It appears that the units library hasn't been modified in over 5 years, so option 2 may be the best one. It's also unlikely that one of the major distributions will package it (I can't find it in Ubuntu Lucid or Macports for example).\nFor example, copy units.c and units.h into your project and create a setup.py ... | [
2
] | [] | [] | [
"python",
"release"
] | stackoverflow_0005237915_python_release.txt |
Q:
Django not creating apps in the correct directory
I'm new to Django, so I may just not fully understand how it works yet. I want to use Django with MongoDB, so I'm using this library to connect the two. So I created a new project, all went well.. then I ran the setup install script for "Mango", the MongoDB libra... | Django not creating apps in the correct directory | I'm new to Django, so I may just not fully understand how it works yet. I want to use Django with MongoDB, so I'm using this library to connect the two. So I created a new project, all went well.. then I ran the setup install script for "Mango", the MongoDB library that I added.
So now I'm at the point where I need t... | [
"From your project directory, run: python manage.py shell\nIf you can then run the following from the interpreter, you should have everything installed correctly:\n>>> from mango.auth import User\n\n"
] | [
0
] | [] | [] | [
"django",
"frameworks",
"mongodb",
"python"
] | stackoverflow_0005238464_django_frameworks_mongodb_python.txt |
Q:
Boost python linking
I'm adding boost.python for my Game. I write wrappers for my classes to use them in scripts. The problem is linking that library to my app. I'm using cmake build system.
Now I have a simple app with 1 file and makefile for it:
PYTHON = /usr/include/python2.7
BOOST_INC = /usr/include
BOOST_LIB... | Boost python linking | I'm adding boost.python for my Game. I write wrappers for my classes to use them in scripts. The problem is linking that library to my app. I'm using cmake build system.
Now I have a simple app with 1 file and makefile for it:
PYTHON = /usr/include/python2.7
BOOST_INC = /usr/include
BOOST_LIB = /usr/lib
TARGET = main... | [
"You are missing your include directory and libs for python in your CMakeList.txt. Use the PythonFindLibs macro or the same find_package strategy you used for Boost\nfind_package(Boost COMPONENTS filesystem system date_time python REQUIRED)\nmessage(\"Include dirs of boost: \" ${Boost_INCLUDE_DIRS} )\nmessage(\"Lib... | [
18
] | [] | [] | [
"boost",
"c++",
"cmake",
"hyperlink",
"python"
] | stackoverflow_0005238160_boost_c++_cmake_hyperlink_python.txt |
Q:
Reading website XML using Google App Engine & Python
I'm trying to read some xml from the world of warcraft armory (yea I'm one of those) - The url such as this returns the xml in Firefox (you need to view source to see it) but not in other browsers such as Chrome (which I don't fully understand why - though that'... | Reading website XML using Google App Engine & Python | I'm trying to read some xml from the world of warcraft armory (yea I'm one of those) - The url such as this returns the xml in Firefox (you need to view source to see it) but not in other browsers such as Chrome (which I don't fully understand why - though that's an aside).
Anyway I have this code which works fine when... | [
"Ok, I've played aroun with http://shell.appspot.com/ ( FYI you can download the source and integrate it with your project for further experiments), this seems to do the trick:\nheaders = { 'User-Agent' : \"\"Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4\" }\nresp = urlf... | [
1,
0,
0
] | [] | [] | [
"beautifulsoup",
"google_app_engine",
"python",
"xml"
] | stackoverflow_0005237338_beautifulsoup_google_app_engine_python_xml.txt |
Q:
Macport installed py26 - Problem installing independent modules
I've installed py26 using macports. I want to install a separate module that isn't on Macports. It gets installed in to my default OSX installation. How do I point my install to my macport installation.
A:
Put py26 on your path. In your .bash_profil... | Macport installed py26 - Problem installing independent modules | I've installed py26 using macports. I want to install a separate module that isn't on Macports. It gets installed in to my default OSX installation. How do I point my install to my macport installation.
| [
"Put py26 on your path. In your .bash_profile for instance this should work\nexport PATH=/opt/local/bin:/opt/local/sbin:$PATH\n\ndon't forget to source at the end from the commandline\n. ~/.bash_profile\n\n",
"First make sure your PATH is set up properly for MacPorts Python. You need to ensure that the Python fr... | [
0,
0,
0
] | [] | [] | [
"macos",
"macports",
"module",
"python"
] | stackoverflow_0004783335_macos_macports_module_python.txt |
Q:
transformation matrices
I've been reviewing some material on affine and projective (or is it perspective?) transformations. I've reviewed the contents of PIL and wikipedia. (http://en.wikipedia.org/wiki/Transformation_matrix)
Unfortunately, I can't seem to find details that specify how to form the matrices for an ... | transformation matrices | I've been reviewing some material on affine and projective (or is it perspective?) transformations. I've reviewed the contents of PIL and wikipedia. (http://en.wikipedia.org/wiki/Transformation_matrix)
Unfortunately, I can't seem to find details that specify how to form the matrices for an affine or projective transfor... | [
"A good resource on affine transforms and creating the matrix is here: http://www.coranac.com/tonc/text/affine.htm\n"
] | [
4
] | [] | [] | [
"computer_vision",
"image_processing",
"matlab",
"python"
] | stackoverflow_0005238991_computer_vision_image_processing_matlab_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.