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:
Exploiting hash function in python
I made a topic about the built-in python hash function: Old python hashing done left to right - why is it bad?
The previous topic was about why it was bad for encryption, because we have an application called Gruyere which is filled with security holes, and it uses the hash() to ... | Exploiting hash function in python | I made a topic about the built-in python hash function: Old python hashing done left to right - why is it bad?
The previous topic was about why it was bad for encryption, because we have an application called Gruyere which is filled with security holes, and it uses the hash() to encrypt cookies.
# global cookie_secret;... | [
"Zack described the answer already in your last question: It's easy to find a collision.\nLet's say you save hash(\"pwd\") in the database (that you actually do something different doesn't matter. Now, if you enter \"pwd\" in the site, you can enter. But how is this checked? Again, the hash of \"pwd\" is token, and... | [
0
] | [] | [] | [
"cookies",
"encryption",
"hash",
"python",
"string"
] | stackoverflow_0005133811_cookies_encryption_hash_python_string.txt |
Q:
python display unicode in html
I'm writing script to export my links and their titles from chrome to html.
Chrome bookmarks stored as json, in utf encoding
Some titles are on Russian therefore they stored like that:
"name": "\u0425\u0430\u0431\u0440\ ..."
import codecs
f = codecs.open("chrome.json","r", "utf-8")
d... | python display unicode in html | I'm writing script to export my links and their titles from chrome to html.
Chrome bookmarks stored as json, in utf encoding
Some titles are on Russian therefore they stored like that:
"name": "\u0425\u0430\u0431\u0440\ ..."
import codecs
f = codecs.open("chrome.json","r", "utf-8")
data = f.readlines()
urls = [] # for... | [
"By the way, it's not just Russian; non-ASCII characters are quite common in page names. Example:\nname=u'Python Programming Language \\u2013 Official Website'\nurl=u'http://www.python.org/'\n\nAs an alternative to fragile code like\nurls.append(i.split('\"')[3])\nnames.append(data[ind-2].split('\"')[3])\n# (1) rel... | [
1,
1,
0,
0
] | [] | [] | [
"json",
"python",
"unicode"
] | stackoverflow_0005127855_json_python_unicode.txt |
Q:
how to plot a pie of color list
hi i have a dict with 3-int-tuple representing color (as key) and an int representing the numbers of occurences of that color in an image (as value)
for exemple, this is a 4x4 pixels image with 3 colors:
{(87, 82, 44): 1, (255, 245, 241): 11, (24, 13, 9): 4}
i want to plot a pie cha... | how to plot a pie of color list | hi i have a dict with 3-int-tuple representing color (as key) and an int representing the numbers of occurences of that color in an image (as value)
for exemple, this is a 4x4 pixels image with 3 colors:
{(87, 82, 44): 1, (255, 245, 241): 11, (24, 13, 9): 4}
i want to plot a pie chart of list [1,11,4] in which each sli... | [
"Update: the other answer from Paul is much better but there's not really any point in me just editing my original answer until it's essentially the same :) (I can't delete this answer because it's accepted.)\nDoes this do what you want? I just took an example from the matplotlib documentation and turned your dat... | [
4,
3
] | [] | [] | [
"colors",
"matplotlib",
"pie_chart",
"python"
] | stackoverflow_0005133871_colors_matplotlib_pie_chart_python.txt |
Q:
Python pull parsers
I'm looking for a fast Python pull parser (maybe some equivalent of PHP's XMLReader?) - is there something like this in Python? It's really a key feature that it would be a pull parser, because I'm gonna process really big xml files...
A:
PHP's XMLReader is nothing but a SAX parser ( http://e... | Python pull parsers | I'm looking for a fast Python pull parser (maybe some equivalent of PHP's XMLReader?) - is there something like this in Python? It's really a key feature that it would be a pull parser, because I'm gonna process really big xml files...
| [
"PHP's XMLReader is nothing but a SAX parser ( http://en.wikipedia.org/wiki/Simple_API_for_XML ).\nPython supports SAX parsing. There are many tutorials available, like this one: \nhttp://www.devarticles.com/c/a/XML/Parsing-XML-with-SAX-and-Python/\n",
"How about the built-in ones python has?\nhttp://docs.python.... | [
3,
1
] | [] | [] | [
"php",
"python",
"xml"
] | stackoverflow_0005134003_php_python_xml.txt |
Q:
Bug in substitution decryption in python
import random
orig=list(range(1,65))
temp_orig= [[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, 30, 31],
[32, 33, 34, 35, 36, 37, 38, 39],
[40, 41, 42, 43, 44, 45, 46, 47],
[48, 49... | Bug in substitution decryption in python |
import random
orig=list(range(1,65))
temp_orig= [[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, 30, 31],
[32, 33, 34, 35, 36, 37, 38, 39],
[40, 41, 42, 43, 44, 45, 46, 47],
[48, 49, 50, 51, 52, 53, 54, 55],
[56, 57, 58, 5... | [
"You do ip1=temp_orig a few times. That tells me that you probably think this copies the temp_orig list - it does not. You have to explicitly copy the list here:\nip1=[list(row) for row in temp_orig]\n\nand so on. Your code just gives new names to temp_orig but still modifies the temp_orig list.\nI think this is th... | [
2
] | [] | [] | [
"encryption",
"python",
"substitution"
] | stackoverflow_0005133953_encryption_python_substitution.txt |
Q:
How to install and use python packages on Kodingen?
I use Kodingen.com to test python scripts. I would like to install new python packages on Kodingen. I know I can use the 1-Click installation of the App-Store to install new packages from ohloh.net. When I install a package, it create a new directory in httpdo... | How to install and use python packages on Kodingen? | I use Kodingen.com to test python scripts. I would like to install new python packages on Kodingen. I know I can use the 1-Click installation of the App-Store to install new packages from ohloh.net. When I install a package, it create a new directory in httpdocs folder. And then? How to setup the python package to... | [
"hey thammas, we are working on kodingen v1.0 with which you will be able to use your own server connected to your account. then you can install anything and use it freely.\nbut now, kodingen provides shared hosting account that doesn't enable anyone to install anything. same applies to ruby gems. but we will make ... | [
2
] | [] | [] | [
"installation",
"package",
"python"
] | stackoverflow_0005134064_installation_package_python.txt |
Q:
CGI, python, and setgid
I'm running a compiled python cgi script (using cxfreeze) in Apache.
The script, among other things, calls
os.setuid(some_uid)
os.setgid(some_gid)
Obviously some_uid/gid are legal and I set the sticky bit for both user and group, and verified it is indeed set.
However on every call i get a... | CGI, python, and setgid | I'm running a compiled python cgi script (using cxfreeze) in Apache.
The script, among other things, calls
os.setuid(some_uid)
os.setgid(some_gid)
Obviously some_uid/gid are legal and I set the sticky bit for both user and group, and verified it is indeed set.
However on every call i get an error
os.setgid(int(self.gi... | [
"The setuid call drops the privileges you need to call setgid, so your calls occur in the wrong order. But why not use a library that is designed for dropping privileges?\n"
] | [
3
] | [] | [] | [
"cgi",
"python"
] | stackoverflow_0005133988_cgi_python.txt |
Q:
Parent process can't access shared memory in PyQt
I'm currently experimenting with QSharedMemory and QProcess in PyQt. So I wrote a small application to launch a process, which creates a shared memory segment and writes data to it. The application reads the data back when the process writes on the output.
Unfortu... | Parent process can't access shared memory in PyQt | I'm currently experimenting with QSharedMemory and QProcess in PyQt. So I wrote a small application to launch a process, which creates a shared memory segment and writes data to it. The application reads the data back when the process writes on the output.
Unfortunately, I get this error when the application attempts ... | [
"From the QSharedMemory docs (emphasis mine):\n\nWarning: QSharedMemory changes the key\n in a Qt-specific way. It is therefore\n currently not possible to use the\n shared memory of non-Qt applications\n with QSharedMemory.\n\nNot sure you can do what you want (portably anyway).\n"
] | [
1
] | [] | [] | [
"pyqt",
"python",
"qprocess",
"shared_memory"
] | stackoverflow_0005134412_pyqt_python_qprocess_shared_memory.txt |
Q:
Python call function from user input
Can you call functions from user input? Something like this:
def testfunction(function):
function()
a = raw_input("fill in function name: "
testfunction(a)
So if you fill in an existing function it will execute it.
A:
What you are doing is bad bad bad :P However, it's p... | Python call function from user input | Can you call functions from user input? Something like this:
def testfunction(function):
function()
a = raw_input("fill in function name: "
testfunction(a)
So if you fill in an existing function it will execute it.
| [
"What you are doing is bad bad bad :P However, it's perfectly possible.\na = raw_input(\"Fill in function name:\")\nif a in locals().keys() and callable(locals()['a']):\n locals()['a']()\nelse:\n print 'Function not found'\n\nlocals() returns a dictionary of all the objects currently avalible, and their names... | [
3,
3,
2
] | [] | [] | [
"python"
] | stackoverflow_0005134482_python.txt |
Q:
Template system or language for Python (primarily HTML)
I'm looking for a mature, easy-to-use, powerful, stand-alone, "beautiful" template system/language for Python. I'm primarily interested in generating (static) HTML from HTML sources (so Markdown/RST/Textile aren't relevant).
There seems to be an array of choi... | Template system or language for Python (primarily HTML) | I'm looking for a mature, easy-to-use, powerful, stand-alone, "beautiful" template system/language for Python. I'm primarily interested in generating (static) HTML from HTML sources (so Markdown/RST/Textile aren't relevant).
There seems to be an array of choices (the Python wiki has a very long list), which makes selec... | [
"Sorry, don't have the rep yet to leave comments, so I'll leave this as an answer.\nI've only used django and mako. Seems like the primary difference between these two template languages is that Django is designed as if you can't really trust the template designers. You can see this in how they limit the code you... | [
4
] | [] | [] | [
"html",
"html_generation",
"python",
"template_engine",
"templates"
] | stackoverflow_0005010159_html_html_generation_python_template_engine_templates.txt |
Q:
Django + GoogleAppEngine Error: DJANGO_SETTINGS_MODULE is undefined
So I am learning how to use Django and I am using Google App Engine. I have the latest Django directory in the same directory as my main.
When I run it from my local it works fine. But when I deploy it and run it from the webpage, I get a Server E... | Django + GoogleAppEngine Error: DJANGO_SETTINGS_MODULE is undefined | So I am learning how to use Django and I am using Google App Engine. I have the latest Django directory in the same directory as my main.
When I run it from my local it works fine. But when I deploy it and run it from the webpage, I get a Server Error.
Here is the code for my main.py and settings.py
main.py:
import os
... | [
"If you are having trouble with the environment variable then try configuring the settings directly (see http://docs.djangoproject.com/en/dev/topics/settings/#using-settings-without-setting-django-settings-module)\nimport settings\nimport django.conf\n\n# Filter out all the non-setting attributes of the settings mo... | [
2
] | [] | [] | [
"django",
"google_app_engine",
"python"
] | stackoverflow_0005122414_django_google_app_engine_python.txt |
Q:
Is it just me or something is seriously wrong with new Python futures module on windows
I am on windows XP and I have problems with new Python 3.2 futures module.
It seems I am unable to get ProcessPoolExecutor to work.
Session example:
Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on w... | Is it just me or something is seriously wrong with new Python futures module on windows | I am on windows XP and I have problems with new Python 3.2 futures module.
It seems I am unable to get ProcessPoolExecutor to work.
Session example:
Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
>>> from concu... | [
"You have to be aware that the concurrent.future module uses the multiprocessing module (especially when you used the ProcessPoolExecutor), so some functionality will not work in the interactive interpreter, read more about this here.\n"
] | [
9
] | [] | [] | [
"concurrent.futures",
"executor",
"future",
"python"
] | stackoverflow_0005134668_concurrent.futures_executor_future_python.txt |
Q:
Tags with : in name in lxml
I'm trying to use lxml.etree to parse a Wordpress export document (it's XML, somewhat RSS like). I'm only interested in published posts, so I'm using the following to loop through published posts:
for item in data.findall("item"):
if item.find("wp:post_type").text != "post":
... | Tags with : in name in lxml | I'm trying to use lxml.etree to parse a Wordpress export document (it's XML, somewhat RSS like). I'm only interested in published posts, so I'm using the following to loop through published posts:
for item in data.findall("item"):
if item.find("wp:post_type").text != "post":
continue
if item.find("wp:st... | [
"The : is an XML namespace separator. To escape the colon in lxml, you need to replace it with the namespace URL within curly braces, as in item.find(\"{http://example.org/}status\").text.\n"
] | [
9
] | [] | [] | [
"elementtree",
"lxml",
"python",
"wordpress",
"xml"
] | stackoverflow_0005134658_elementtree_lxml_python_wordpress_xml.txt |
Q:
Google App Engine - Hello World Tutorial - Segmentation Fault
I am just starting to use google app engine and have just started running the tutorial. When I do this:
$ python2.5 google_appengine/dev_appserver.py helloworld/
it says 'Segmentation Fault'.
I am running Ubuntu 10.10. I installed Python 2.5 from th... | Google App Engine - Hello World Tutorial - Segmentation Fault | I am just starting to use google app engine and have just started running the tutorial. When I do this:
$ python2.5 google_appengine/dev_appserver.py helloworld/
it says 'Segmentation Fault'.
I am running Ubuntu 10.10. I installed Python 2.5 from the site with help from this site.
The reason I have python2.5 at th... | [
"Sorry, don't have the rep to leave comments, so I'll have to leave this as an answer.\nAssuming that you've verified that your google app engine install isn't corrupted, my first instinct is that the python2.5 install is using some files from python2.7, causing it to segfault. Try running strace -o \"log.txt\" py... | [
0
] | [] | [] | [
"google_app_engine",
"python",
"segmentation_fault"
] | stackoverflow_0005044532_google_app_engine_python_segmentation_fault.txt |
Q:
Decode Cookie variable extracted from a HTTP Stream - Python
I am using python to send a request to a server. I get a cookie from the server. I am trying to decode the encoding scheme used by the server - I suspect it's either utf-8 or base64.
So I create my header and connection objects.
resp, content = httpobj.r... | Decode Cookie variable extracted from a HTTP Stream - Python | I am using python to send a request to a server. I get a cookie from the server. I am trying to decode the encoding scheme used by the server - I suspect it's either utf-8 or base64.
So I create my header and connection objects.
resp, content = httpobj.request(server, 'POST', headers=HTTPheader, body=HTTPbody)
And the... | [
"Try like this:\nimport urllib\nimport base64\n\ncookie_val = \"\"\"MjAyMTNiZWE4ZmYxYTMwOVPJ7Jh0B%2BMUcE4si5oDcH7nKo4kAI8CMYgKqn6yXpgtXOSGs8J9gm20bgSlYMUJC5rmiQ1Ch5nUUlQEQNmrsy5LDgAuuidQaZJE5z%2BFqAJPnlJaAqG2Fvvk5ishG%2FsH%2FA%3D%3D\"\"\"\n\nres = base64.b64decode(urllib.unquote(cookie_val))\n\nprint repr(res)\n\n... | [
3
] | [] | [] | [
"base64",
"cookies",
"http",
"python",
"utf_8"
] | stackoverflow_0005134764_base64_cookies_http_python_utf_8.txt |
Q:
ds python import math module
I'm trying to get some python code I've written earlier on Windows to work on my DS. I'm using (DSPython), and when I tried to import math, it failed with "ImportError: No module named math". I've gotten most all other modules I need that don't rely on math working. But math is normall... | ds python import math module | I'm trying to get some python code I've written earlier on Windows to work on my DS. I'm using (DSPython), and when I tried to import math, it failed with "ImportError: No module named math". I've gotten most all other modules I need that don't rely on math working. But math is normally a builtin module, so I can't jus... | [
"Last month dspython has been given an overall project cleanup, and several issues, including the one you mention, were addressed in the process.\nIf you're still interested in running that Python code in your DS, this is a good time to try again. A contributor has also written some small example programs, that ar... | [
1,
0
] | [] | [] | [
"math",
"module",
"nintendo_ds",
"python"
] | stackoverflow_0002076606_math_module_nintendo_ds_python.txt |
Q:
Computing MD5 checksums for files in a list
I'm working on a bit of a project in Python. I have a list of files that I want to get the md5checksums for. Then it stores the checksums in another list. Then it checks again and checks to see if they're different. I have the function for getting the checksums working b... | Computing MD5 checksums for files in a list | I'm working on a bit of a project in Python. I have a list of files that I want to get the md5checksums for. Then it stores the checksums in another list. Then it checks again and checks to see if they're different. I have the function for getting the checksums working but now I can't figure out how I'd add them to a l... | [
"def getmd5(filename, ....):\n\n return m.hexdigest()\n\n\nmd5s = dict()\n\nfor fname in filenames:\n md5s[fname] = getmd5(fname)\n\nprint md5s\n\n",
"You don't have 4 lists. You're printing the contents of the md5s each time after you call getmd5 which adds one md5 hash to the list. You just happen to be doin... | [
2,
1
] | [] | [] | [
"checksum",
"hash",
"list",
"md5",
"python"
] | stackoverflow_0005134860_checksum_hash_list_md5_python.txt |
Q:
What Can I do for sorting algorithm with my number language?
What Can I do for sorting algorithm for my number language?
khmer_number = [០, ១, ២, ៣, ៤, ៥, ៦, ៧, ៨, ៩] # unicode utf-8 for khmer language number
internatonal_number = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
And I have a function sorting by using Nai... | What Can I do for sorting algorithm with my number language? | What Can I do for sorting algorithm for my number language?
khmer_number = [០, ១, ២, ៣, ៤, ៥, ៦, ៧, ៨, ៩] # unicode utf-8 for khmer language number
internatonal_number = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
And I have a function sorting by using Naive sort,Quick sort,Bubble sort,
Now for example with:
# -*- codin... | [
"Looks like you're holding your number values in a string. In that case I would suggest that you think about converting those strings to numbers, sorting, and then converting back to string representation.\nnumberList = map(khmer_to_int, myList)\nnumberList.sort()\nmyList = map(int_to_khmer, numberList)\n\nwhere y... | [
3,
3,
1,
1
] | [] | [] | [
"algorithm",
"python"
] | stackoverflow_0005134863_algorithm_python.txt |
Q:
CSS Classes in django-pagination package
I'm tring to use django-pagination package(http://pypi.python.org/pypi/django-pagination) and I found out that in pagination template they use the following CSS classes:
<span class="current page">
<span class="disabled next">
etc
Why do they use classnames with space sy... | CSS Classes in django-pagination package | I'm tring to use django-pagination package(http://pypi.python.org/pypi/django-pagination) and I found out that in pagination template they use the following CSS classes:
<span class="current page">
<span class="disabled next">
etc
Why do they use classnames with space symbol? Is it normal? And how can I define class... | [
"The class names do not have a space in them, it is the space that separates classnames; class names cannot have a space (though they can have a hypen, which is typically used in place of spaces in a class name).\nThe HTML <span class=\"current page\"> means that the styles for both the current and page classes app... | [
1
] | [] | [] | [
"css",
"django_pagination",
"python",
"templates"
] | stackoverflow_0005134957_css_django_pagination_python_templates.txt |
Q:
Login with python - megaupload
I'm trying to fix a program which can login to my MU account and retrieve some data....
I don't know what am I doing wrong....That's the code:
#!/usr/bin/env python
import urllib, urllib2, cookielib
username = 'username'
password = 'password'
cj = cookielib.CookieJar()
opener = url... | Login with python - megaupload | I'm trying to fix a program which can login to my MU account and retrieve some data....
I don't know what am I doing wrong....That's the code:
#!/usr/bin/env python
import urllib, urllib2, cookielib
username = 'username'
password = 'password'
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookie... | [
"You can simulate the filling of the form. \nFor that you can use mechanize lib base on perl module WWW::Mechanize.\n#!/usr/bin/env python\nimport urllib, urllib2, cookielib, mechanize\n\nusername = 'username'\npassword = 'password'\n\nbr = mechanize.Browser()\ncj = cookielib.CookieJar()\n\nbr.set_cookiejar(cj)\nbr... | [
2,
2,
1,
0
] | [] | [] | [
"authentication",
"python"
] | stackoverflow_0005134250_authentication_python.txt |
Q:
numpy - pretty printing
I have a numpy array of strings. When a value in the array is undefined, None is printed as you would expect. Is it possible to provide a default value for None values?
e.g. in the following I want "_" instead of None
[[None B C]
[M None O]
[X Y None]]
would become
[[_ B C]
[M _ O]
[X ... | numpy - pretty printing | I have a numpy array of strings. When a value in the array is undefined, None is printed as you would expect. Is it possible to provide a default value for None values?
e.g. in the following I want "_" instead of None
[[None B C]
[M None O]
[X Y None]]
would become
[[_ B C]
[M _ O]
[X Y _]]
| [
"You might also consider using a masked array:\nimport numpy as np\n\nx=np.array([[None, 'B', 'C'],\n ['M', None, 'O'],\n ['X', 'Y', None]])\nprint(x)\n# [[None B C]\n# [M None O]\n# [X Y None]]\n\nx=np.ma.masked_equal(x,None)\nprint(x)\n# [[-- B C]\n# [M -- O]\n# [X Y --]]\n\n",
"Numpy has ... | [
7,
3,
1
] | [] | [] | [
"numpy",
"python"
] | stackoverflow_0005134932_numpy_python.txt |
Q:
Returns values from a for loop in python
I'm trying to figure out the syntax for passing arguments from one list or dict to another in the for loop syntax.
The desired result I'm looking for is this:
for bean in beans:
if bean.type == 'coffee':
print bean
Only, instead of printing to stdout, I'd like to col... | Returns values from a for loop in python | I'm trying to figure out the syntax for passing arguments from one list or dict to another in the for loop syntax.
The desired result I'm looking for is this:
for bean in beans:
if bean.type == 'coffee':
print bean
Only, instead of printing to stdout, I'd like to collect that string data and append it to another... | [
"[bean for bean in beans if bean.type == 'coffee']\n\nList comprehensions are neat. Even neater, often you don't need to produce a whole list - you just need an iterator that gives you the values the list would consist of. That's a generator, and they can be expressed just as succinctly via generator expressions. T... | [
12,
8,
1
] | [] | [] | [
"loops",
"python",
"return"
] | stackoverflow_0005135211_loops_python_return.txt |
Q:
Escaping Bash wildcards when executing python script from bash script?
I've got a bash script that defines an array of file globs containing * wildcards.
The script executes a python script passing each of these globs as a parameter.
On the command line I can quote the entire glob, and python is happy with it.
In ... | Escaping Bash wildcards when executing python script from bash script? | I've got a bash script that defines an array of file globs containing * wildcards.
The script executes a python script passing each of these globs as a parameter.
On the command line I can quote the entire glob, and python is happy with it.
In the bash script, if I quote the globs, python's os.path.realpath seems to ge... | [
"Instead of \\'$path\\', use \"$path\". The double-quotes allow the contents of the variable $path to be substituted, but prevent wildcard expansion and ensure the path is passed as a single argument.\n"
] | [
2
] | [] | [] | [
"bash",
"python"
] | stackoverflow_0005134933_bash_python.txt |
Q:
Python - Is there any way to get pip without setuptools?
Seems kinda weird that they'd require a package manager to install a package manager. I'm on Windows BTW.
A:
Pip does require setuptools. Pip is really just a wrapper around setuptools to provide a better installer than easy_install and some nicer install... | Python - Is there any way to get pip without setuptools? | Seems kinda weird that they'd require a package manager to install a package manager. I'm on Windows BTW.
| [
"Pip does require setuptools. Pip is really just a wrapper around setuptools to provide a better installer than easy_install and some nicer installation behaviors, plus uninstall, requirements files, etc. Even if you somehow got pip installed without setuptools it still won't run without it.\n",
"You can use Dist... | [
6,
2,
1,
0
] | [
"Sure, just grab the source from http://pypi.python.org/pypi/pip/0.8.2#downloads\nunpack it, cd into it, and run python setup.py install\n"
] | [
-1
] | [
"easy_install",
"pip",
"python",
"setuptools"
] | stackoverflow_0005097795_easy_install_pip_python_setuptools.txt |
Q:
Represent unicode utf-8 or print the list that elements as input from keyboard?
# -*- coding: utf-8 -*-
def present_unicode(list):
for a in list:
print u"%s" % a
TRY:
list1 = ['១','៤','០']#this list is what I input with the khmer keyboard.
print list1
>>> ['\xe1\x9f\xa1', '\xe1\x9f\xa4', '\xe1\x9f\xa... | Represent unicode utf-8 or print the list that elements as input from keyboard? | # -*- coding: utf-8 -*-
def present_unicode(list):
for a in list:
print u"%s" % a
TRY:
list1 = ['១','៤','០']#this list is what I input with the khmer keyboard.
print list1
>>> ['\xe1\x9f\xa1', '\xe1\x9f\xa4', '\xe1\x9f\xa0']
list2 = [u'\u17E2', u'\u17E4', u'\u17E0'] # <=>['\xe1\x9f\xa1', '\xe1\x9f\xa4',... | [
"Use unicode literals.\n\"Unicode in Python, Completely Demystified\"\n"
] | [
3
] | [] | [] | [
"character_encoding",
"python"
] | stackoverflow_0005135970_character_encoding_python.txt |
Q:
Python + Soap + XMLHTTPRequest
Hello I am trying to do a SOAP request here is my code:
# Create an OpenerDirector with support for Basic HTTP Authentication...
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password(realm='webservices.autotask.net',
uri='https://webservice... | Python + Soap + XMLHTTPRequest | Hello I am trying to do a SOAP request here is my code:
# Create an OpenerDirector with support for Basic HTTP Authentication...
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password(realm='webservices.autotask.net',
uri='https://webservices.autotask.net/atservices/1.5/atws.a... | [
"HTTPSConnection takes a host name, not a URL, so it should be\nwebservice = httplib.HTTPSConnection(\"webservices.autotask.net\", 443)\n\nand i believe that the host header is added for you, so you can skip that, but if its not, that should also be the host name, and not a URL.\n"
] | [
3
] | [] | [] | [
"python",
"soap"
] | stackoverflow_0005136033_python_soap.txt |
Q:
How can I reuse raw user's password in django?
As user logged in, he had provided his name and raw password which was hashed and compared with db's value.
def login(request):
username = request.POST['username']
password = request.POST['password']
user = auth.authenticate(username=username, password=pa... | How can I reuse raw user's password in django? | As user logged in, he had provided his name and raw password which was hashed and compared with db's value.
def login(request):
username = request.POST['username']
password = request.POST['password']
user = auth.authenticate(username=username, password=password)
if user is not None and user.is_active:
... | [
"You could store it in the session data from the login view function. At least then it would die with the session. The other option, stashing it in a database field, would be horrendous if some hacker got DB access. At least if a hacker gets DB access with passwords in sessions they'd only get the plain text passwo... | [
2,
1,
0
] | [] | [] | [
"django",
"passwords",
"python"
] | stackoverflow_0005132817_django_passwords_python.txt |
Q:
Get dimensions from a flash file (.swf) in pure-Python
How would I extract the dimensions (width and height) from a flash file?
I intend on using this code inside a webapp hosted on Google App Engine, so libs that are no pure-python will not work.
A:
I've never actually used it, but I suspect that the hexagonit.... | Get dimensions from a flash file (.swf) in pure-Python | How would I extract the dimensions (width and height) from a flash file?
I intend on using this code inside a webapp hosted on Google App Engine, so libs that are no pure-python will not work.
| [
"I've never actually used it, but I suspect that the hexagonit.swfheader module would work for your purposes. It is pure python, and tiny (full source including a test-case is a 4KB tarball.) I was created for more or less exactly what you are doing.\nI should mention that it claims to be licensed under the GPL, so... | [
5
] | [] | [] | [
"flash",
"python"
] | stackoverflow_0005136317_flash_python.txt |
Q:
Compensating for "variance" in a survey
The title for this one was quite tricky.
I'm trying to solve a scenario,
Imagine a survey was sent out to XXXXX amount of people, asking them what their favourite football club was.
From the response back, it's obvious that while many are favourites of the same club, they... | Compensating for "variance" in a survey | The title for this one was quite tricky.
I'm trying to solve a scenario,
Imagine a survey was sent out to XXXXX amount of people, asking them what their favourite football club was.
From the response back, it's obvious that while many are favourites of the same club, they all "expressed" it in different ways.
For e... | [
"Google Refine does just this, but I'll assume you want to roll your own.\nNote, difflib is built into Python, and has lots of features (including eliminating junk elements). I'd start with that.\nYou probably don't want to do it in a completely automated fashion. I'd do something like this:\n# load corrections fil... | [
1,
0,
0
] | [] | [] | [
"fuzzy_comparison",
"nlp",
"python"
] | stackoverflow_0005134142_fuzzy_comparison_nlp_python.txt |
Q:
Can you iterate a number backwards without using a list?
How would you iterate a number backwards without using a list in Python 3?
Using lists, I would probably do something like:
li = list(range(100))
for i in li[::-1]:
print(i)
This is a fine solution, but it does not work with huge numbers.
Right now, I'm... | Can you iterate a number backwards without using a list? | How would you iterate a number backwards without using a list in Python 3?
Using lists, I would probably do something like:
li = list(range(100))
for i in li[::-1]:
print(i)
This is a fine solution, but it does not work with huge numbers.
Right now, I'm trying to iterate a number backwards with large numbers, but ... | [
"Iterators that provide the __reversed__() special method also support reversed iteration. In Python 3.x, range() iterators have this method, so you can also use\nfor i in reversed(range(100)):\n print(i)\n\nIn Python 2.x, xarnge() allows reversed iteration:\nfor i in reversed(xrange(100)):\n print i\n\nBoth... | [
11,
2,
1,
1
] | [] | [] | [
"iteration",
"list",
"python"
] | stackoverflow_0005136344_iteration_list_python.txt |
Q:
Changing whitespace color in Stani Python Editor
I figured out how to edit the looks of SPE colors. Everything works except when I try change the whitespace color: whitespace remains white. Below is a code snippet showing value input for the whitespace background. How can I change the whitespace color?
# Global de... | Changing whitespace color in Stani Python Editor | I figured out how to edit the looks of SPE colors. Everything works except when I try change the whitespace color: whitespace remains white. Below is a code snippet showing value input for the whitespace background. How can I change the whitespace color?
# Global default styles for all languages
self.StyleS... | [
"Comment: It might be easier to read the configuration if you separate the data and the code:\nsettings = [\n \"STYLE_DEFAULT\", \"face:%(mono)s,size:%(size)d\",\n \"STYLE_LINENUMBER\", \"back:#C0C0C0,face:%(mono)s,size:%(size)d\",\n ...\n \"P_COMMENTBLOCK\", \"face:%(mono)s,fore:#003300,back:#C0C0C0,italic,size:%... | [
0
] | [] | [] | [
"ide",
"python"
] | stackoverflow_0005136268_ide_python.txt |
Q:
Python Google Checkout Notification API
I am attempting to work with Google Checkout on Google App Engine. Currently, I am writing everything in Python and have the checkout process working. I am having some difficulty getting the notifications of processed orders functioning. I've been searching for Python exampl... | Python Google Checkout Notification API | I am attempting to work with Google Checkout on Google App Engine. Currently, I am writing everything in Python and have the checkout process working. I am having some difficulty getting the notifications of processed orders functioning. I've been searching for Python examples, but thus far have been unsuccessful. Prog... | [
"The chippyshop source has a nice example of a python Google Checkout implementation that should get you moving in the right direction.\nUPDATE: I actually ended up needing to do this myself so I extended the example linked above and turned it into a reusable RequestHandler for use on GAE. \nYou can find the source... | [
1
] | [] | [] | [
"google_app_engine",
"google_checkout",
"python"
] | stackoverflow_0004687405_google_app_engine_google_checkout_python.txt |
Q:
Python 2.6: proper usage of unittest.TestSuite
Using Python 2.6, I have a very simple test in a python file in a directory:
#mytest.py
import unittest
class BasicTests(unittest.TestCase):
def test_ok(self):
self.assertTrue(True)
suite = unittest.TestLoader().loadTestsFromTestCase(BasicTests)
I chang... | Python 2.6: proper usage of unittest.TestSuite | Using Python 2.6, I have a very simple test in a python file in a directory:
#mytest.py
import unittest
class BasicTests(unittest.TestCase):
def test_ok(self):
self.assertTrue(True)
suite = unittest.TestLoader().loadTestsFromTestCase(BasicTests)
I change into the directory and run python -m unittest myte... | [
"I don't usually work with unittest on the command line, but have my own test running scripts.\nYou need to add a function suite to the module\ndef suite():\n return unittest.TestLoader().loadTestsFromTestCase(BasicTests)\n\nand then call it like python -m unittest mytest.suite. But then I run into the following... | [
5,
1,
0
] | [] | [] | [
"python",
"unit_testing"
] | stackoverflow_0005136159_python_unit_testing.txt |
Q:
How draw on gtk window without generating expose event
I am doing a project in PyGtk for monitoring a performance of system.
I have developed almost of the code for purpose.But now i have a problem in it.
My problem is that i am repainting all my stuff on expose-event and i want to draw on window without generatin... | How draw on gtk window without generating expose event | I am doing a project in PyGtk for monitoring a performance of system.
I have developed almost of the code for purpose.But now i have a problem in it.
My problem is that i am repainting all my stuff on expose-event and i want to draw on window without generating expose event.Reason for that is, i am plotting a graph on ... | [
"You might try .hide'ing the window before drawing on it, and thus generating the expose when you .show it.\nThe FAQ answer can be found here.\n",
"You could use the freeze_updates and thaw_updates methods of GTK:\n# GTK Imports\nimport gtk\n\ngdkwindow=mywindow.window\nif gdkwindow:\n gdkwindow.freeze_updates... | [
0,
0
] | [] | [] | [
"pygtk",
"python"
] | stackoverflow_0005133140_pygtk_python.txt |
Q:
Schema migration on GAE datastore
First off, this is my first post on Stack Overflow, so please forgive any newbish mis-steps. If I can be clearer in terms of how I frame my question, please let me know.
I'm running a large application on Google App Engine, and have been adding new features that are forcing me to ... | Schema migration on GAE datastore | First off, this is my first post on Stack Overflow, so please forgive any newbish mis-steps. If I can be clearer in terms of how I frame my question, please let me know.
I'm running a large application on Google App Engine, and have been adding new features that are forcing me to modify old data classes and add new one... | [
"you are hitting the second DeadlineExceededError by the sound of it. AppEngine requests can only run for 30 seconds each. When DeadLineExceedError is raised it's your job to stop processing and tidy up as you are running out of time, the next time it is raised you cannot catch it.\nYou should look at using the Map... | [
5,
2
] | [] | [] | [
"google_app_engine",
"google_cloud_datastore",
"migration",
"python",
"schema"
] | stackoverflow_0005137070_google_app_engine_google_cloud_datastore_migration_python_schema.txt |
Q:
Comparing user's facebook/twitter friends to site's users in Python/Django
I'm wondering if someone could help guide the approach to this fairly common problem:
I'm building a simple site which a user connects their twitter account to sign up. I'd like to create an interface which shows them which of their twitter... | Comparing user's facebook/twitter friends to site's users in Python/Django | I'm wondering if someone could help guide the approach to this fairly common problem:
I'm building a simple site which a user connects their twitter account to sign up. I'd like to create an interface which shows them which of their twitter friends are already using the site.
So I can get a list the user's twitter frie... | [
"Create Sets out of them, and use the intersection method:\nintersection_set = set(list_a).intersection(list_b)\n\n",
"You should store the twitter user's ID because the username can change at any time, but the id will always be the same. You should be comparing the id's, not the usernames in the intersection_se... | [
3,
1
] | [] | [] | [
"django",
"python",
"twitter"
] | stackoverflow_0005137126_django_python_twitter.txt |
Q:
Why ActivePython freezes after I use the turtle module?
I've installed ActivePython 3.1 and ran IDLE with -n parameter as required by the turtle module in documentation. However when I try to use it with call such as turtle.postion(), new windows is opened (with Tk icon), which freezes and shows nothing.
What coul... | Why ActivePython freezes after I use the turtle module? | I've installed ActivePython 3.1 and ran IDLE with -n parameter as required by the turtle module in documentation. However when I try to use it with call such as turtle.postion(), new windows is opened (with Tk icon), which freezes and shows nothing.
What could be wrong?
| [
"The immediate cause of the freeze is that the Tk event loop is not being serviced. Without that, Tk windows do not display or update correctly (all GUI toolkits are event based, but Tk is particularly so). Unfortunately, I don't know Python's Tk binding or IDLE nearly well enough to be able to say what that is cau... | [
2,
0
] | [] | [] | [
"activepython",
"python",
"tk_toolkit",
"turtle_graphics",
"windows"
] | stackoverflow_0005081499_activepython_python_tk_toolkit_turtle_graphics_windows.txt |
Q:
how to create and interactive isometric frame for diagraming in a python GUI (preferable wxpython)
Am designing a piping software, right now it works on 2D. I implemented a very simple frame with wx.paintDC() it basically goes like this:
def OnDrawing(self, evt):
dc = wx.PaintDC(self.leftWindow)
self.leftW... | how to create and interactive isometric frame for diagraming in a python GUI (preferable wxpython) | Am designing a piping software, right now it works on 2D. I implemented a very simple frame with wx.paintDC() it basically goes like this:
def OnDrawing(self, evt):
dc = wx.PaintDC(self.leftWindow)
self.leftWindow.PrepareDC(dc)
dc.Clear()
for image in self.images[1:]:
x = image[1][0]
y =... | [
"You might want to investigate Python-Ogre. Ogre is an open source 3D engine, and Python-Ogre allows you to manipulate the scene through Python. This could allow you to focus on the user interface, instead of learning how to draw textured triangles with pyopengl. \nhttp://python-ogre.org/\n"
] | [
1
] | [] | [] | [
"isometric",
"python",
"wxpython"
] | stackoverflow_0005137205_isometric_python_wxpython.txt |
Q:
Does Ruby on Rails play nicely with the Google Code APIs?
I'm interested in investing more time in Ruby on Rails and noticed how there isn't any specialized documenation for using Rails with the Google Code API:
http://code.google.com/apis/picasaweb/docs/2.0/developers_guide.html
Has anyone used Ruby on Rails with... | Does Ruby on Rails play nicely with the Google Code APIs? | I'm interested in investing more time in Ruby on Rails and noticed how there isn't any specialized documenation for using Rails with the Google Code API:
http://code.google.com/apis/picasaweb/docs/2.0/developers_guide.html
Has anyone used Ruby on Rails with the Google Code API, and if so, were there any issues that mig... | [
"The API client libraries are written for languages (Java, Python, Ruby, etc.) not frameworks (Ruby on Rails, Django, CakePHP, etc.).\nGoogle doesn't offer a Ruby API for Picasa Web Albums, so you'd either have to find an unofficial library or write your own.\n"
] | [
2
] | [] | [] | [
"django",
"google_code",
"python",
"ruby",
"ruby_on_rails"
] | stackoverflow_0005137399_django_google_code_python_ruby_ruby_on_rails.txt |
Q:
Python Error: Argument 1 must be buffer or bytes not str
The program is simple, it is meant to connect to an IRC room. The problem is that when I try to connect my bot to it, it gives me the error in the title. I am not sure what they want instead of a string. I am not sure what buffer or bytes refers to. Others h... | Python Error: Argument 1 must be buffer or bytes not str | The program is simple, it is meant to connect to an IRC room. The problem is that when I try to connect my bot to it, it gives me the error in the title. I am not sure what they want instead of a string. I am not sure what buffer or bytes refers to. Others have gotten this script to work, but its not working for me. No... | [
"You're using Python 3, while the script was written for Python 2. The quick fix is to make the string literals bytes literals by adding a b before them:\nirc.sendall(b\"NICK PyBot\\r\\n\")\nirc.sendall(b\"USER Pybot Pybot Pybot : Python IRC\\r\\n\")\nirc.sendall(b\"JOIN #pychat\\r\\n\")\nirc.sendall(b\"PART #pych... | [
2,
1
] | [] | [] | [
"bots",
"irc",
"networking",
"python"
] | stackoverflow_0005137433_bots_irc_networking_python.txt |
Q:
How to find size of db.Model instances in GAE Python before calling db.put()?
I'm writing an optimizer for my application, so db.put() invoked as rarely as possible. I stuck with following problem:
I have a number of classes derived from db.Model. The instances of those classes stored in list:
class DBPutter:
... | How to find size of db.Model instances in GAE Python before calling db.put()? | I'm writing an optimizer for my application, so db.put() invoked as rarely as possible. I stuck with following problem:
I have a number of classes derived from db.Model. The instances of those classes stored in list:
class DBPutter:
data = [] # list of instances
def add(self, model):
# HERE I WANT TO CH... | [
"Pympler has a asizeof method, and should run in python 2.5: http://code.google.com/p/pympler/\nI think you're over-optimizing though. If an instance is shut down before 1000 objects are in your putter you could lose data. Also, I think using the deferred library with a large amount of data would result in at leas... | [
4,
3,
1
] | [] | [] | [
"google_app_engine",
"google_cloud_datastore",
"python"
] | stackoverflow_0005133451_google_app_engine_google_cloud_datastore_python.txt |
Q:
Python pickle loses data
I have 4 nested classes, see example:
class GameInfo:
id = ""
round = ""
# ... etc
class Opponent:
game_info = GameInfo()
name = ""
# ...
class Tournament:
opponent_list = [] # list of Opponent objects
# ...
class Journal(db.Model):
picked_tournament ... | Python pickle loses data | I have 4 nested classes, see example:
class GameInfo:
id = ""
round = ""
# ... etc
class Opponent:
game_info = GameInfo()
name = ""
# ...
class Tournament:
opponent_list = [] # list of Opponent objects
# ...
class Journal(db.Model):
picked_tournament = db.BlobProperty() # here I ... | [
"In the constructor for your Opponent class, you instantiate a single copy of GameInfo, which is used by all the instances of that class. For example:\n>>> o1 = Opponent()\n>>> o1.game_info.id = 5\n>>> o2 = Opponent()\n>>> o2.game_info.id\n5\n\nInstead, you need to create one for each Opponent instance. Do this by ... | [
3,
1
] | [] | [] | [
"google_app_engine",
"pickle",
"python"
] | stackoverflow_0005129680_google_app_engine_pickle_python.txt |
Q:
Installing ocropus-0.4.4
I have installed ocropus-0.4.4 from installTranscirpt.When i run ocropus.py from ocroswig I get the following statments
Traceback (most recent call last):
File "iulib.py", line 25, in <module>
_iulib = swig_import_helper()
File "iulib.py", line 17, in swig_import_helper
import ... | Installing ocropus-0.4.4 | I have installed ocropus-0.4.4 from installTranscirpt.When i run ocropus.py from ocroswig I get the following statments
Traceback (most recent call last):
File "iulib.py", line 25, in <module>
_iulib = swig_import_helper()
File "iulib.py", line 17, in swig_import_helper
import _iulib
ImportError: /usr/local... | [
"Probably due to missing - or incorrectly versioned - binary system libraries. Try to build the package yourself, instead of grabbing a pre-built binary. The building process will give errors and say which libraries are missing, or in the incorrect version on your system. (You might have to install the aproppriate ... | [
0
] | [] | [] | [
"python"
] | stackoverflow_0005134118_python.txt |
Q:
boost.python code on module import
I need to call InitGoogleLogging() when my C++ library is imported in Python. My C++ library uses Boost.Python.
How do I call functions when the library is imported?
A:
There are no real "definitions" in python. Any code you put in a .py module is executed when you import it.... | boost.python code on module import | I need to call InitGoogleLogging() when my C++ library is imported in Python. My C++ library uses Boost.Python.
How do I call functions when the library is imported?
| [
"There are no real \"definitions\" in python. Any code you put in a .py module is executed when you import it. It just happens to be that most of the time the code put in the package files is the \"definiton\" code like class or def. In practice, that code still gets executed, it just creates your class and func... | [
6
] | [] | [] | [
"boost_python",
"python"
] | stackoverflow_0005138043_boost_python_python.txt |
Q:
java vs python for GAE
from these links:-
http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=python3&lang2=java
http://shootout.alioth.debian.org/u32q/benchmark.php?test=all&lang=python3&lang2=java
http://shootout.alioth.debian.org/u64/benchmark.php?test=all&lang=python3&lang2=java
http://shoo... | java vs python for GAE | from these links:-
http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=python3&lang2=java
http://shootout.alioth.debian.org/u32q/benchmark.php?test=all&lang=python3&lang2=java
http://shootout.alioth.debian.org/u64/benchmark.php?test=all&lang=python3&lang2=java
http://shootout.alioth.debian.org/u32/b... | [
"Just a quick note - don't take this as a definitive/comprehensive comparison:\nBoth Django and Spring have a long startup time, which can lead to requests being dropped. I'd go with a framework that was speciffically made for GAE: tipify, slim3, etc..\n",
"I'm used both Python and Java on GAE, one project done u... | [
3,
3,
2
] | [] | [] | [
"google_app_engine",
"java",
"performance",
"python",
"web_frameworks"
] | stackoverflow_0005136072_google_app_engine_java_performance_python_web_frameworks.txt |
Q:
Boost::python Exposing C++ functions using and returning templates
I need to build python bindings for a C++ codebase. I use boost::python and I ran into problems trying to expose classes containing functions using and returning templates. Here is a typical example
class Foo
{
public:
Foo();
... | Boost::python Exposing C++ functions using and returning templates | I need to build python bindings for a C++ codebase. I use boost::python and I ran into problems trying to expose classes containing functions using and returning templates. Here is a typical example
class Foo
{
public:
Foo();
template<typename T> Foo& setValue(
const string& property... | [
"This may not be related to your problem directly but I would not trust function signature casting with templates like that. I would have wrapped it like this: \nclass_<Foo>(\"Foo\") \n .def(\"setValue\", &Foo::setValue<double>, \n return_value_policy<reference_existing_object>()) \n .def(\"getValue\",... | [
3,
0,
0
] | [] | [] | [
"boost",
"boost_python",
"c++",
"python"
] | stackoverflow_0004844651_boost_boost_python_c++_python.txt |
Q:
Method for comparing twitter users to site users in Django / Python
This is a follow up to an earlier question. I'm using the below code to get a user's friends and then compare them to the users of my site to show a "Friends already using this site" list.
It's working perfectly, but is this an efficient way to do... | Method for comparing twitter users to site users in Django / Python | This is a follow up to an earlier question. I'm using the below code to get a user's friends and then compare them to the users of my site to show a "Friends already using this site" list.
It's working perfectly, but is this an efficient way to do it? Any recommendations?
in views.py
# Get Twitter Friends
api = twitte... | [
"You're doing the right thing. What's your concern? Is the page loading slowly? If so, consider loading a page without this information, then using an ajax call to fetch the list of friends who are using the site. That way, at least you can have your user looking at a page with a loading graphic that says \"fet... | [
0
] | [] | [] | [
"django",
"python",
"twitter"
] | stackoverflow_0005137410_django_python_twitter.txt |
Q:
Pass through the file system from a given directory and print all subfolders and file names (Python)
I need to write a program that passes through the file system from a given directory and prints all subfolders and files names.
A:
os.walk() is your friend.
A:
This works:
#!/usr/bin/env python
import os
def ... | Pass through the file system from a given directory and print all subfolders and file names (Python) | I need to write a program that passes through the file system from a given directory and prints all subfolders and files names.
| [
"os.walk() is your friend.\n",
"This works:\n#!/usr/bin/env python\n\nimport os\n\ndef walklevel(some_dir, level):\n some_dir = some_dir.rstrip(os.path.sep)\n num_sep = some_dir.count(os.path.sep)\n for root, dirs, files in os.walk(some_dir):\n yield root, dirs, files\n num_sep_this = root.... | [
5,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0005133820_python.txt |
Q:
In Python, how can I send a Queue to a multiprocessing.Process after it has already been started?
Typically I do something like:
q = Queue()
p = Process(target=f, args=(q,))
p.start()
Is there some way to pass p another Queue? Er... now that I think about it - can this be done through q?
A:
Yes, it can be done... | In Python, how can I send a Queue to a multiprocessing.Process after it has already been started? | Typically I do something like:
q = Queue()
p = Process(target=f, args=(q,))
p.start()
Is there some way to pass p another Queue? Er... now that I think about it - can this be done through q?
| [
"\nYes, it can be done via q. You can pass any object there, another Queue included\nI wouldn't recommend this practice, however. Describe why you originally need this, maybe there's a better design.\n\n",
"No, once a process has been created (the process is forked), queues can no longer be sent to it. They can o... | [
2,
1
] | [] | [] | [
"multiprocessing",
"python",
"queue"
] | stackoverflow_0004331781_multiprocessing_python_queue.txt |
Q:
How to hide console window on Windows when using scons-qt4 plugin?
When I'm building on Windows with scons-qt4 plugin, my application always opens a console window, even though it has its own windows. With QMake, you could force application to do the same by adding CONFIG += console or something similar, but the d... | How to hide console window on Windows when using scons-qt4 plugin? | When I'm building on Windows with scons-qt4 plugin, my application always opens a console window, even though it has its own windows. With QMake, you could force application to do the same by adding CONFIG += console or something similar, but the default behaviour is to suppress it. QMake can handle it - I'm sure scons... | [
"So, it seems, my question was almost already answered here. Now, applied to scons, these two lines did it for me:\nif (env ['PLATFORM'] == 'win32'):\n env.Append (LINKFLAGS = ['-Wl,-subsystem,windows'])\n\nAlso, kind thanks to the folks on the [scons-users] mailing list. In particular, David Van Maren pointed o... | [
0
] | [] | [] | [
"python",
"qt",
"scons"
] | stackoverflow_0005102922_python_qt_scons.txt |
Q:
setlabel in Qlabel will assign a variable in pyqt?
I'm still starting out with PyQt with QtDesigner using eric4 (and still studying python as a whole).
Anyway, as I've designed in a GUI using QtDesigner I've just made a Qlabel as a placeholder which is intended to update with the latest ID that has access to a SQ... | setlabel in Qlabel will assign a variable in pyqt? | I'm still starting out with PyQt with QtDesigner using eric4 (and still studying python as a whole).
Anyway, as I've designed in a GUI using QtDesigner I've just made a Qlabel as a placeholder which is intended to update with the latest ID that has access to a SQLite database which I'm building. I want it to setlabel ... | [
"The translate function call is used for multi-language support. You can remove it in this case and simplify the code to the following.\nself.ID_Number.setText(somePythonStringVariable)\n\n"
] | [
1
] | [] | [] | [
"pyqt",
"python",
"qt_designer"
] | stackoverflow_0005138976_pyqt_python_qt_designer.txt |
Q:
Django, Python Modules, and Git Submodules
I am working on a django project that has uses multiple applications (python modules). Most of those python modules are maintained by other people in their own git repositories. I use the git-submodules command to import them into my project under the 'apps' directory l... | Django, Python Modules, and Git Submodules | I am working on a django project that has uses multiple applications (python modules). Most of those python modules are maintained by other people in their own git repositories. I use the git-submodules command to import them into my project under the 'apps' directory like so:
mysite/
mysite/apps
mysite/apps/django-e... | [
"This is the wrong way to do it. Don't install other people's third-party code in your own project file. Instead, create a virtualenv, and install the code directly using pip.\n",
"After coming up blank on the internet, I hacked this solution together. It's straight forward and works well enough:\n#At the top of... | [
9,
5,
1,
0
] | [] | [] | [
"django",
"git",
"git_submodules",
"module",
"python"
] | stackoverflow_0005137082_django_git_git_submodules_module_python.txt |
Q:
Custom WSGI server connection failure
I am new to python WSGI & I am attempting to set up my own server to test my login.html page (that uses AJAX).
But when I go to run my WSGI.py (my server I made through following a tutorial) I get this error:
Traceback (most recent call last):
File "C:\Users\Print\Desktop... | Custom WSGI server connection failure | I am new to python WSGI & I am attempting to set up my own server to test my login.html page (that uses AJAX).
But when I go to run my WSGI.py (my server I made through following a tutorial) I get this error:
Traceback (most recent call last):
File "C:\Users\Print\Desktop\Website\KazCare\wsgi.py", line 63, in
... | [
"I don't think you are doing anything wrong. Its sounds like you don't have permissions to bind to that port. I know this can be an issue in *nix, and you have to run as sudo if you want to bind to port 80 for instance. I don't pretend to know how it works in windows though. Try changing to a port not generally... | [
1,
1
] | [] | [] | [
"cgi",
"python",
"wsgi"
] | stackoverflow_0005138248_cgi_python_wsgi.txt |
Q:
Passing a python dictionary to a psycopg2 cursor
I need to call a PostgreSQL 8.4 function which requires 17 input paramters from Python. The values are stored in a dictionary. So I can write:
cur.execute("SELECT add_user(%s, %s, %s, %s, %s, %s, %s, .......)", user["nr"], user['email']...)
Is it possible to automa... | Passing a python dictionary to a psycopg2 cursor | I need to call a PostgreSQL 8.4 function which requires 17 input paramters from Python. The values are stored in a dictionary. So I can write:
cur.execute("SELECT add_user(%s, %s, %s, %s, %s, %s, %s, .......)", user["nr"], user['email']...)
Is it possible to automatically map the values in the dictionary to the functi... | [
"The following syntax should do it:\ncur.execute(\"SELECT add_user(%(nr)s, %(email)s, ...) ...\", user)\n\nThanks to Thiefmaster for providing a correction to what I had here originally: The %(keyname)s format for parameters is just one of those defined in the Python Database API 2.0 - see the documentation for par... | [
10
] | [] | [] | [
"postgresql",
"psycopg2",
"python"
] | stackoverflow_0005139700_postgresql_psycopg2_python.txt |
Q:
python twisted - Timeouting on a sent message that did not get a response
I am creating a sort of a client-server implementation, and I'd like to make sure that every sent message gets a response. So I want to create a timeout mechanism, which doesn't check if the message itself is delivered, but rather checks if ... | python twisted - Timeouting on a sent message that did not get a response | I am creating a sort of a client-server implementation, and I'd like to make sure that every sent message gets a response. So I want to create a timeout mechanism, which doesn't check if the message itself is delivered, but rather checks if the delivered message gets a response.
IE, for two computers 1 and 2:
1: send s... | [
"There is a better way, which funnily enough I myself just implemented here. It uses the TimeoutMixin to achieve the timeout behaviour you need, and a DeferredLock to match up the correct replies with what was sent.\nfrom twisted.internet import defer\nfrom twisted.protocols.policies import TimeoutMixin\nfrom twist... | [
5
] | [] | [] | [
"client",
"python",
"timeout",
"twisted"
] | stackoverflow_0005139612_client_python_timeout_twisted.txt |
Q:
Inequality Filters on a date and a number
Am trying to query my Google App Engine datastore [Python], which has a item_name, manufacturing_date and number_of_items_shipped. There are ~1.0 million records in the datastore and ever increasing.
The scenario:
Get all the item_names which have been shipped more than x_... | Inequality Filters on a date and a number | Am trying to query my Google App Engine datastore [Python], which has a item_name, manufacturing_date and number_of_items_shipped. There are ~1.0 million records in the datastore and ever increasing.
The scenario:
Get all the item_names which have been shipped more than x_items [user input] and manufactured after some_... | [
"Building on Sudhir's answer, I'd probably assign each record to a manufacture date \"bucket\", based on the granularity you care about. If your range of manufacturing dates is over a couple of years, use monthly buckets for example. If your range is just in the last year, weekly.\nNow when you want to find recor... | [
1,
0
] | [] | [] | [
"date",
"google_app_engine",
"inventory",
"python"
] | stackoverflow_0004862558_date_google_app_engine_inventory_python.txt |
Q:
Counting records from datastore
I am using python with Django to develop application on google app engine.
Now my entity in data store contain millions or billions of record and I want to count those records in real time.
By using count() it takes more time then what I can afford
I want to count those record with ... | Counting records from datastore | I am using python with Django to develop application on google app engine.
Now my entity in data store contain millions or billions of record and I want to count those records in real time.
By using count() it takes more time then what I can afford
I want to count those record with in 2 or 3 second..
So can any one tel... | [
"Store the count in another entity (named Statistics for example), and modify your application so that the stored count is updated each time a new entity is inserted or deleted.\n"
] | [
4
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0005139767_google_app_engine_python.txt |
Q:
scrambled output from a child process run from subprocess
I'm using the following code to run another python script. The problem I'm facing is that the output of that script is coming out in an unorderly manner.
While running it from the command line, I get the correct output i.e. :
some output here
Editing xml... | scrambled output from a child process run from subprocess | I'm using the following code to run another python script. The problem I'm facing is that the output of that script is coming out in an unorderly manner.
While running it from the command line, I get the correct output i.e. :
some output here
Editing xml file and saving changes
Uploading xml file back..
While run... | [
"There are a few problems with the part of the script you've quoted, I'm afraid:\n\nAs mentioned in detly's comment, what are fo and fe? Presumably those are objects to which you're writing the output of the child process? (Update: you indicate that these are both for writing output logs.)\nThere's an indentation... | [
4,
2
] | [] | [] | [
"python",
"subprocess"
] | stackoverflow_0005139795_python_subprocess.txt |
Q:
Setting fixed length with python
I have str that are like '60' or '100'.
I need the str to be '00060' and '00100',
How can i do this?
code is something like this:
I was using '0'+'0'+'0' as plug. now need to fix
d==0006000100
a4 ='60'
a5 ='100'
d=('0'+'0'+'0'+a4+'0'+'0'+a5)
A:
Since you are manipula... | Setting fixed length with python | I have str that are like '60' or '100'.
I need the str to be '00060' and '00100',
How can i do this?
code is something like this:
I was using '0'+'0'+'0' as plug. now need to fix
d==0006000100
a4 ='60'
a5 ='100'
d=('0'+'0'+'0'+a4+'0'+'0'+a5)
| [
"Since you are manipulating strings, str.zfill() does exactly what you want.\n>>> s1, s2 = '60', '100'\n>>> print s1.zfill(5), s2.zfill(5)\n00060 00100\n\n",
"Like this:\nnum = 60 \nformatted_num = u'%05d' % num\n\nSee the docs for more information about formatting numbers as strings.\nIf your number is already a... | [
25,
10,
2,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0005138062_python.txt |
Q:
Building C Extensions of Python(3.2) but get error "cannot find -lmsvcr90"
I am trying to Building C Extensions of Python(3.2) on Windows use distutils.
below is the code:(From Demo/embed/demo.c in the Python(3.1.3) source distribution)
/* Example of embedding Python in another program */
#include "Python.h"
PyO... | Building C Extensions of Python(3.2) but get error "cannot find -lmsvcr90" | I am trying to Building C Extensions of Python(3.2) on Windows use distutils.
below is the code:(From Demo/embed/demo.c in the Python(3.1.3) source distribution)
/* Example of embedding Python in another program */
#include "Python.h"
PyObject* PyInit_xyzzy(void); /* Forward */
main(int argc, char **argv)
{
/* I... | [
"msvcr90 is the Microsoft Visual C Runtime. The instructions for building on Windows only describe using Visual Studio; I don't know if it will work with dev C++. You can download free \"Visual Studio Express\" here.\n"
] | [
0
] | [] | [] | [
"c",
"python"
] | stackoverflow_0005138724_c_python.txt |
Q:
Adding sibling element in ElementTree with Python
With XML such as
<a>
<b>
</b>
</a>
I need to add a sibling of something like
<a>
<b>
</b>
<b'>
</b'>
</a>
Does ElementTree has a function to add a sibling node?
If not, I guess I need a function to get a parent node and add a child node, how can I do... | Adding sibling element in ElementTree with Python | With XML such as
<a>
<b>
</b>
</a>
I need to add a sibling of something like
<a>
<b>
</b>
<b'>
</b'>
</a>
Does ElementTree has a function to add a sibling node?
If not, I guess I need a function to get a parent node and add a child node, how can I do that?
| [
"In the standard lib's version, you cannot directly access the parent, you'll have to work down from the parent, or keep track of parent-child relations yourself, read these tips (from the author of the library).\nIf you use lxml however, there is the getparent() method (you have getnext() and getprevious() as well... | [
7,
1
] | [
"With what is at hand:\nimport re\n\ndef sibling(bal,text):\n print 'bal ==' + bal + '\\n' # + '\\n\\n' + s\n\n def aux(match):\n # match.group(4) is '/' or None \n return (\"%s%s<%s'/>%s\" % match.group(1,2,3,6) if match.group(4)\n else \"%s%s<%s'>%s'>%s\" % match.group(1,2,3,... | [
-4
] | [
"elementtree",
"python",
"xml"
] | stackoverflow_0005099535_elementtree_python_xml.txt |
Q:
python random number
I was wondering if someone can clarify this line for me.
Create a function die(x) which rolls a
die x times keeping track of how many
times each face comes up and returns a
1X6 array containing these numbers.
I am not sure what this means when it says 1X6 array ? I am using the randint... | python random number | I was wondering if someone can clarify this line for me.
Create a function die(x) which rolls a
die x times keeping track of how many
times each face comes up and returns a
1X6 array containing these numbers.
I am not sure what this means when it says 1X6 array ? I am using the randint function from numpy so th... | [
"Since a dice has 6 possible outcomes, if you get a 2 three times, this would be :\n0 3 0 0 0 0\n",
"def die(x):\n return np.bincount(np.random.random_integers(0, 5, size=x))\n\nnp.random.random_integers(0,5,size=x) rolls the die x times (faces are represented by numbers from 0 to 5 including).\nnp.bincount() ... | [
3,
3,
1,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0005136533_python.txt |
Q:
Changes to multiple entities within a single transaction
I am trying to make changes to multiple entities within a single transaction in app engine platform. As I understand in order to succeed doing so, App Engine needs to know in advance which entities will be updated together, so it knows to store them in a way... | Changes to multiple entities within a single transaction | I am trying to make changes to multiple entities within a single transaction in app engine platform. As I understand in order to succeed doing so, App Engine needs to know in advance which entities will be updated together, so it knows to store them in a way that supports transactions. And therefore, user must declare ... | [
"Using parent argument to model constructor\n",
"Just take obj of first class as a parent parameter in second class constructor...\nlike\nclass GroupA(db.Model):\n counterA = db.IntegerProperty()\n\nclass ExampleA(db.Model):\n exampleA = db.IntegerProperty()\n\ndef increment_counterA():\n\n obj = GroupA(... | [
2,
0
] | [] | [] | [
"python"
] | stackoverflow_0002538194_python.txt |
Q:
Django: String object prints out None
Hello I have a view that deletes order numbers. Once a string has been deleted, the web page redirects to the clients page letting the user know that the order number was deleted. There is a problem. I am getting this.
Previous order None deleted
It says None but I want it to ... | Django: String object prints out None | Hello I have a view that deletes order numbers. Once a string has been deleted, the web page redirects to the clients page letting the user know that the order number was deleted. There is a problem. I am getting this.
Previous order None deleted
It says None but I want it to state the order number that I have deleted.... | [
"One of the things that delete() does on a model instance is set its pk to None, so that if you try and save it, it will create a new instance rather than trying to update the old (no-longer-existing) one.\nSo, easy solution: grab the PK before you delete. In fact, you could just get rid of the first call to delete... | [
0,
0
] | [] | [] | [
"django",
"python",
"string",
"views"
] | stackoverflow_0005140615_django_python_string_views.txt |
Q:
Autodocumenting Python using Sphinx
This is a generalized version of a previous question regarding Sphinx.
Is there a way to recursively autodocument modules or packages which contain classes and functions within them?
I think it is silly to add the autofunction or automodule directive for each function; There mus... | Autodocumenting Python using Sphinx | This is a generalized version of a previous question regarding Sphinx.
Is there a way to recursively autodocument modules or packages which contain classes and functions within them?
I think it is silly to add the autofunction or automodule directive for each function; There must be a way to automate the process, other... | [
"We use \n.. automodule:: module\n :members:\n\n",
"To make things easier you can use this script (look at the bottom of the page for the last version):\nhttp://bitbucket.org/birkenfeld/sphinx/issue/98/add-the-autogenerate-script-to-sphinx\nThis script will parse your packages/modules and generate all the rest ... | [
38,
26,
16,
0
] | [
"You want it more simpler than just specifing automodule? Even for a large library, it's 5min amount of work to type all the module names.\nThe reason of doing so is because Sphinx hardly guesses what needs to be documented.\nYou could also write autopackage, that would search for modules and use automodule directi... | [
-9
] | [
"documentation_generation",
"python",
"python_sphinx"
] | stackoverflow_0001328041_documentation_generation_python_python_sphinx.txt |
Q:
Javascript: Modify code to add elements to an array/list
Hey Guys,
Javascript newbie here. I'm trying to modify some existing to code to instead of returning the count of elements, to actually add each of the specified elements to an array/list
here is the original code from Selenium CSS counter
private int getCSS... | Javascript: Modify code to add elements to an array/list | Hey Guys,
Javascript newbie here. I'm trying to modify some existing to code to instead of returning the count of elements, to actually add each of the specified elements to an array/list
here is the original code from Selenium CSS counter
private int getCSSCount(String aCSSLocator){
String jsScript = "var cssMatches =... | [
"I'm not sure how eval_css works, but if returns an array of strings into cssMatches, as you can get an string, and not a list, using get_eval, then you should JSONify the list in the JS scope, getting it as an string into python, and using simplejson, converting it to an python's native list.\nSomething like this,... | [
1,
0
] | [] | [] | [
"css",
"javascript",
"python",
"selenium"
] | stackoverflow_0005135246_css_javascript_python_selenium.txt |
Q:
md5 output in python different to command line (even in binary mode)
I'm writing a script that needs to check the md5 sum of a file on OSX and Windows, and as a sanity check I compared the results with that of the command line md5 tool, but I get different results. Here's the code
def MD5File(self, f, block_size=... | md5 output in python different to command line (even in binary mode) | I'm writing a script that needs to check the md5 sum of a file on OSX and Windows, and as a sanity check I compared the results with that of the command line md5 tool, but I get different results. Here's the code
def MD5File(self, f, block_size=2**20):
md5 = hashlib.md5()
while True:
data = f.read(block_size)
... | [
"The following works correctly for me:\nIn [1]: with file(\"play.py\") as f:\n ...: data = f.read()\n ...: from hashlib import md5\n ...: print(md5(data).hexdigest())\n ...: \n07030b37de71f3ad9ef2398b4f0c3a3e\n\nIn [2]: \nbensonk@angua ~ $ md5 play.py\nMD5 (play.py) = 07030b37de71f3ad9ef2398b4f0... | [
4,
0
] | [] | [] | [
"macos",
"md5",
"python"
] | stackoverflow_0005141275_macos_md5_python.txt |
Q:
Using Cookies for authenticated users
Can anyone tell me of good tutorials that will explain how to generate a cookie for when a user logs into my system through Foursquare, so I can keep track of their information? Or is there any other methods which I should look at?
A:
To store semi-sensitive data, you should... | Using Cookies for authenticated users | Can anyone tell me of good tutorials that will explain how to generate a cookie for when a user logs into my system through Foursquare, so I can keep track of their information? Or is there any other methods which I should look at?
| [
"To store semi-sensitive data, you should use a session variables. Sessions are stored on the server, with a unique cookie sent to each unique client. This way, you have control over what's in the session variable, but the user can still be uniquely identified. For info on sessions in app engine, see this post.\... | [
3
] | [] | [] | [
"cookies",
"foursquare",
"google_app_engine",
"oauth",
"python"
] | stackoverflow_0005141191_cookies_foursquare_google_app_engine_oauth_python.txt |
Q:
What method should I employ to extract keywords from a URL?
I am working on extraction of keywords. The system takes a URL as input and the output is supposed to be keywords describing the contents of the URL. We are considering only textual parts now. I would like to know what methods I can employ for extracting ... | What method should I employ to extract keywords from a URL? | I am working on extraction of keywords. The system takes a URL as input and the output is supposed to be keywords describing the contents of the URL. We are considering only textual parts now. I would like to know what methods I can employ for extracting keywords from URLs and how they compare with each other. Suggesti... | [
"i think you can use this method\nread the site with urllib ( http://docs.python.org/library/urllib2.html?highlight=urllib2#module-urllib2 ) and then remove tags and create plane text of site\nthen check which word are used more. then create top tens ( or count )\n"
] | [
1
] | [] | [] | [
"c",
"lisp",
"python",
"seo"
] | stackoverflow_0005045743_c_lisp_python_seo.txt |
Q:
BeautifulSoup to scrape details from remote site for display on local site
new to Python and BeautifulSoup, I am trying to scrape the race details from a website to display on my local club website.
Here is my code so far :
import urllib2
import sys
import os
sys.path.insert(0, os.path.abspath(os.path.dirname(__f... | BeautifulSoup to scrape details from remote site for display on local site | new to Python and BeautifulSoup, I am trying to scrape the race details from a website to display on my local club website.
Here is my code so far :
import urllib2
import sys
import os
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
from BeautifulSoup import BeautifulSoup
# Road
#cyclelab_url='http://w... | [
"If you look at the structure of the page, you'll see that the event name that you find in the first loop is enclosed by a table that has all the other useful details as pairs of cells in rows of the table. So, what I'd do is to just have one loop, and each time you find an event name, look for the enclosing table... | [
4,
0
] | [] | [] | [
"beautifulsoup",
"python"
] | stackoverflow_0005141522_beautifulsoup_python.txt |
Q:
Is there a function in Python which generates all the strings of length n over a given alphabet?
I need a function generateAllStrings(n, alphabet) to do something like this:
generateAllStrings(4, ['a','b'])
>>> ["aaaa", "aaab", "aaba", "aabb", "abaa", .... , "bbba", "bbbb"]
In other words, generateAllStrings(n, a... | Is there a function in Python which generates all the strings of length n over a given alphabet? | I need a function generateAllStrings(n, alphabet) to do something like this:
generateAllStrings(4, ['a','b'])
>>> ["aaaa", "aaab", "aaba", "aabb", "abaa", .... , "bbba", "bbbb"]
In other words, generateAllStrings(n, alphabet) should return all the possible strings of length n over the chars in the list alphabet.
Is t... | [
">>> [''.join(i) for i in itertools.product(\"ab\",repeat=4)]\n['aaaa', 'aaab', 'aaba', 'aabb', 'abaa', 'abab', 'abba', 'abbb', 'baaa', 'baab', 'baba', 'babb', 'bbaa', 'bbab', 'bbba', 'bbbb']\n\n"
] | [
38
] | [] | [] | [
"algorithm",
"python",
"string"
] | stackoverflow_0005141794_algorithm_python_string.txt |
Q:
Django want to display help_text
Hello I would like to display this help text in my model forms called alternate_id. However I seem to be having trouble with this. It might be what I have written in my response context.
forms.py
alternate_id = forms.CharField(label = 'Client no', max_length = 400, required = False... | Django want to display help_text | Hello I would like to display this help text in my model forms called alternate_id. However I seem to be having trouble with this. It might be what I have written in my response context.
forms.py
alternate_id = forms.CharField(label = 'Client no', max_length = 400, required = False, help_text = 'Valid wildcard search i... | [
"Maybe you should try removing form.alternate_id':form.alternate_id from your context dict. The form itself should contain the alternate_id field and its help text.\n"
] | [
0
] | [] | [] | [
"django",
"forms",
"html",
"python",
"tags"
] | stackoverflow_0005141586_django_forms_html_python_tags.txt |
Q:
Tricky module import with late init
I have such a simple module's structure:
mod1/
__init__.py
clsOne.py
clsN.py
Where code looks like this:
__init__.py:
# module init
from clsOne import MyFirstCLass
from clsN import NThCLass
clshnd = MyFirstClass()
...
nhnd = NThClass()... | Tricky module import with late init | I have such a simple module's structure:
mod1/
__init__.py
clsOne.py
clsN.py
Where code looks like this:
__init__.py:
# module init
from clsOne import MyFirstCLass
from clsN import NThCLass
clshnd = MyFirstClass()
...
nhnd = NThClass()
clsOne.py:
class MyFirstClass( obj... | [
"You just put the relevant code into a separate module.\nmod1/\n __init__.py\n clsOne.py\n clsN.py\n foo.py\n\nAnd then in foo.py:\nfrom clsOne import MyFirstCLass\nfrom clsN import NThCLass\n\nclshnd = MyFirstClass()\n...\nnhnd = NThClass()\n\n"
] | [
0
] | [] | [] | [
"import",
"module",
"python"
] | stackoverflow_0005141925_import_module_python.txt |
Q:
How can I post photo to facebook with python sdk
I am using the python SDK on google app engine, and I'm runnig the "newsfeed" example. I tried to change the example code in order to upload local image file to facebook.
And follow is my change, but i don't know how to finish it. I'm wondering that how to change f... | How can I post photo to facebook with python sdk | I am using the python SDK on google app engine, and I'm runnig the "newsfeed" example. I tried to change the example code in order to upload local image file to facebook.
And follow is my change, but i don't know how to finish it. I'm wondering that how to change facebookclient.py or facebook.py to upload image.
Thank... | [
"Using the facebook API is a bit more complicated: a single request won't do the trick, there's authentication involved.\nFortunately, the documentation is quite good. See here, and look under the Publishing section for your specific needs.\n"
] | [
0
] | [] | [] | [
"facebook",
"google_app_engine",
"multipartform_data",
"python"
] | stackoverflow_0005141834_facebook_google_app_engine_multipartform_data_python.txt |
Q:
How to express conditional execution inside Python lambdas?
What I found out:
In Dive in to Python I read about the peculiar nature of and and or operators
and how shortcircuit evaluation of boolean operators may be used to express conditionals more succinctly via the and-or trick that works very much like the ter... | How to express conditional execution inside Python lambdas? | What I found out:
In Dive in to Python I read about the peculiar nature of and and or operators
and how shortcircuit evaluation of boolean operators may be used to express conditionals more succinctly via the and-or trick that works very much like the ternary operator in C.
C:
result = condition ? a : b
Python:
resul... | [
"Since there is is a special language construct with the inline if-else that does what you want and which was introduced to replace ugly workarounds like those you mention, it is a good idea to use it. Especially since hacks like the and-or trick usually have unexpected corner cases/bugs.\nThe and-or trick for exam... | [
2,
2,
0,
0
] | [] | [] | [
"conditional",
"inline_if",
"lambda",
"python",
"short_circuiting"
] | stackoverflow_0005142423_conditional_inline_if_lambda_python_short_circuiting.txt |
Q:
Python programming
Possible Duplicate:
Best online resource to learn Python?
i am a newbee in programming languages...and want to learn python(knows c,java),,,can anybody suggest me a good e-book or links to learn the basics of the same....
A:
Python doc is the first place you go. Thereafter, follow the variou... | Python programming |
Possible Duplicate:
Best online resource to learn Python?
i am a newbee in programming languages...and want to learn python(knows c,java),,,can anybody suggest me a good e-book or links to learn the basics of the same....
| [
"Python doc is the first place you go. Thereafter, follow the various links there to learn more\n",
"The Python tutorial is your friend.\n"
] | [
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0005142578_python.txt |
Q:
How to correlate two time series with gaps and different time bases?
I have two time series of 3D accelerometer data that have different time bases (clocks started at different times, with some very slight creep during the sampling time), as well as containing many gaps of different size (due to delays associated ... | How to correlate two time series with gaps and different time bases? | I have two time series of 3D accelerometer data that have different time bases (clocks started at different times, with some very slight creep during the sampling time), as well as containing many gaps of different size (due to delays associated with writing to separate flash devices).
The accelerometers I'm using are ... | [
"My interpretation of your question: Given two very long, noisy time series, find a shift of one that matches large 'bumps' in one signal to large bumps in the other signal.\nMy suggestion: interpolate the data so it's uniformly spaced, rectify and smooth the data (assuming the phase of the fast oscillations is uni... | [
4,
1,
1,
0,
0
] | [] | [] | [
"accelerometer",
"numpy",
"python",
"r",
"signal_processing"
] | stackoverflow_0005130808_accelerometer_numpy_python_r_signal_processing.txt |
Q:
Segfault when trying to call a Python function from C
So, I want to call a Python callback function from C.
At some point, the function is sent to C and packed into a tuple like this
PyObject *userData = Py_BuildValue("Oi",py_callback,some_number);
Somewhere in that area, I do Py_INCREF(py_callback), too.
At some... | Segfault when trying to call a Python function from C | So, I want to call a Python callback function from C.
At some point, the function is sent to C and packed into a tuple like this
PyObject *userData = Py_BuildValue("Oi",py_callback,some_number);
Somewhere in that area, I do Py_INCREF(py_callback), too.
At some later time in the program, I want to call that function
Py... | [
"When getting weird behaviour from the Python C API, it is always worth double checking that you are managing the state of the Global Interpreter Lock (aka \"the GIL\") correctly: http://docs.python.org/c-api/init.html#thread-state-and-the-global-interpreter-lock\n",
"I'm not sure why everyone is talking about th... | [
5,
1
] | [] | [] | [
"c",
"call",
"callback",
"function",
"python"
] | stackoverflow_0005090585_c_call_callback_function_python.txt |
Q:
Exporting data as an XML file in google appengine
I'm trying to export data to an XML file in the Google appengine, I'm using Python/Django. The file is expected to contain upto 100K records converted to XML. Is there an equivalent in App Engine of:
f = file('blah', 'w+')
f.write('whatever')
f.close()
?
Thanks
Ed... | Exporting data as an XML file in google appengine | I'm trying to export data to an XML file in the Google appengine, I'm using Python/Django. The file is expected to contain upto 100K records converted to XML. Is there an equivalent in App Engine of:
f = file('blah', 'w+')
f.write('whatever')
f.close()
?
Thanks
Edit
What I'm trying to achieve is exporting some informa... | [
"You could also generate XML with Django templates. There's no special reason that a template has to contain HMTL. I use this approach for generating the Atom feed for my blog. The template looks like this. I pass it the collection of posts that go into the feed, and each Post entity has a to_atom method that gener... | [
1,
0,
0
] | [] | [] | [
"django",
"google_app_engine",
"python"
] | stackoverflow_0005104117_django_google_app_engine_python.txt |
Q:
How do I test beginner student Python programs that use input() (maybe with unittest?)?
I'm a grader for a beginning programming class using Python. My python-fu is not so strong myself, but I would like to try to automate some of the grading.
Looking online, I like the PyUnit testing suite, though it probably is... | How do I test beginner student Python programs that use input() (maybe with unittest?)? | I'm a grader for a beginning programming class using Python. My python-fu is not so strong myself, but I would like to try to automate some of the grading.
Looking online, I like the PyUnit testing suite, though it probably is a bit overpowered for what I want.
My problem is that I'm not sure how to pass the test inpu... | [
"Edit: Only proposing this since the example isn't unittest-able (and I'm assuming the beginner students will just be confused by the constraint)\nIf you are just concerned with the output matching what you are looking for, why not just use some \"silly\" bash? Something like:\necho -e \"2\\n3\" | python test.py |... | [
8,
4,
2,
2,
2,
2,
0,
0
] | [] | [] | [
"python",
"python_unittest",
"testing",
"unit_testing"
] | stackoverflow_0004865195_python_python_unittest_testing_unit_testing.txt |
Q:
Keeps getting "error binding parameter 0 - probably unsupported type"
I'm using eric4 (qtdesigner, pyqt, python, etc) with sqlite and I keep getting "error binding parameter 0 - probably unsupported type" when I'm running the program I've coded.
I've made some GUIs using eric4 + qtdesigner and generated dialog co... | Keeps getting "error binding parameter 0 - probably unsupported type" | I'm using eric4 (qtdesigner, pyqt, python, etc) with sqlite and I keep getting "error binding parameter 0 - probably unsupported type" when I'm running the program I've coded.
I've made some GUIs using eric4 + qtdesigner and generated dialog codes. When one of the buttons of the windows I've made in qtdesigner are pre... | [
"QlineEdit.text() returns a QString. Pass it to the unicode constructor to get something usable.\n",
"I was sort of able to reproduce this.\nIf you pass a string or a number or even a date as Nik, everything works. The error you describe happens only if you pass something strange as Nik, e.g. a class or a functio... | [
3,
1
] | [] | [] | [
"pyqt",
"python",
"sqlite"
] | stackoverflow_0005142975_pyqt_python_sqlite.txt |
Q:
What module to use in Python to do the same as cURL in Php?
I'm a PHP programmer. What module can I use in Python to do the same that cURL does?
Best Regards,
A:
Take a look at python's "urllib2"
A:
you can do the same stuff with urllib2, pycurl hasn't been updated in a while, so I wouldn't recommend it. Espec... | What module to use in Python to do the same as cURL in Php? | I'm a PHP programmer. What module can I use in Python to do the same that cURL does?
Best Regards,
| [
"Take a look at python's \"urllib2\"\n",
"you can do the same stuff with urllib2, pycurl hasn't been updated in a while, so I wouldn't recommend it. Especially on Windows. Always better to use a native module rather than a 3rd party plugin\n"
] | [
2,
1
] | [] | [] | [
"curl",
"python"
] | stackoverflow_0005143325_curl_python.txt |
Q:
Using python help to get help on MatchObject
I am trying to use the help() function in the Python interactive shell to get help on MatchObject. I have already imported re, and whether I try help(MatchObject), help(re.MatchObject), help(matchobject), or any other variation on these above choices I get a NameError.
... | Using python help to get help on MatchObject | I am trying to use the help() function in the Python interactive shell to get help on MatchObject. I have already imported re, and whether I try help(MatchObject), help(re.MatchObject), help(matchobject), or any other variation on these above choices I get a NameError.
I realize that I can look up help about MatchObjec... | [
"I just tried \nhelp(re.match) #help on method\n\nor \n help(re.match(r\"(\\w+) (\\w+)\", \"Isaac Newton, physicist\")) #help on result\n\nAnd official docs do look confusing. It does not seem that MatchObject class explicitly exists in Python. \n"
] | [
0
] | [] | [] | [
"python"
] | stackoverflow_0005143309_python.txt |
Q:
Python encoding - Nothing works
I've been looking the answers here in this web site, but nothing have worked so far. The problem is:
In the database, strings are saved like that one: at √s = 7 TeV with.
And the reason is that the "escape" JavaScript function was used.
I was not able to "unescape" these strin... | Python encoding - Nothing works | I've been looking the answers here in this web site, but nothing have worked so far. The problem is:
In the database, strings are saved like that one: at √s = 7 TeV with.
And the reason is that the "escape" JavaScript function was used.
I was not able to "unescape" these strings in Python yet. I tried to use "eva... | [
"The string in question looks like it's encoded with HTML entities, in which case a routine like this one would be appropriate for unescaping. Here's how it looks for your string:\n>>> print unescape('at √s = 7 TeV with')\nat √s = 7 TeV with\n\n",
"urllib.unquote should undo most if not all of the Javascrip... | [
3,
0
] | [] | [] | [
"encode",
"javascript",
"python"
] | stackoverflow_0005143421_encode_javascript_python.txt |
Q:
python subprocess: raising an error when a process prompts
I have a python script that runs on a server after hours and invokes many shell subprocesses. None of the programs that are called should be prompting, but sometimes it happens and the script hangs, waiting for input until the user (me) notices and gets an... | python subprocess: raising an error when a process prompts | I have a python script that runs on a server after hours and invokes many shell subprocesses. None of the programs that are called should be prompting, but sometimes it happens and the script hangs, waiting for input until the user (me) notices and gets angry. :)
Tried: Using p.communicate() with stdin=PIPE, as written... | [
"As a catch-all solution to any problems in subprocesses I'd recommend using timeouts for all shell calls. There's no built-in timeout support in subprocess module calls, so you need to use signals. See details here: Using module 'subprocess' with timeout\n",
"You need a time-out while waiting for your tasks to... | [
1,
0,
0
] | [] | [] | [
"python",
"subprocess"
] | stackoverflow_0005142908_python_subprocess.txt |
Q:
Python pickling returning a string when I've pickled a dict?
I'm currently learning about pickling in Python and I'm confused with an error I'm getting complaing that the unpickled variable I'm initalizing does not have a particular attribute I'm wanting to use.
I'm pickling a dictionary of the script's data and t... | Python pickling returning a string when I've pickled a dict? | I'm currently learning about pickling in Python and I'm confused with an error I'm getting complaing that the unpickled variable I'm initalizing does not have a particular attribute I'm wanting to use.
I'm pickling a dictionary of the script's data and then trying to unpickle.load it back using the following code:
def ... | [
"That should work. The code you posted is fine. How are you dumping it? You're using pickle.dump, not pickle.dumps for a string? Your problem is almost certainly in the dumping code.\n>>> import cPickle\n>>> foo = {4:2}\n>>> cPickle.dump(foo, open('foo.pickle', 'wb'))\n>>> data_to_load = cPickle.load(open('foo.pick... | [
3
] | [] | [] | [
"dictionary",
"pickle",
"python"
] | stackoverflow_0005143593_dictionary_pickle_python.txt |
Q:
How do I check if a given Python string is a substring of another one?
I have two strings and I would like to check whether the first is a substring of the other. Does Python have such a built-in functionality?
A:
Try using in like this:
>>> x = 'hello'
>>> y = 'll'
>>> y in x
True
A:
Try
isSubstring = first i... | How do I check if a given Python string is a substring of another one? | I have two strings and I would like to check whether the first is a substring of the other. Does Python have such a built-in functionality?
| [
"Try using in like this:\n>>> x = 'hello'\n>>> y = 'll'\n>>> y in x\nTrue\n\n",
"Try\nisSubstring = first in theOther\n\n",
"string.find(\"substring\") will help you. This function returns -1 when there is no substring.\n"
] | [
509,
55,
42
] | [] | [] | [
"python",
"string",
"substring"
] | stackoverflow_0005143769_python_string_substring.txt |
Q:
How to dynamically add members to class
My question can be simply illustrated by this code:
def proceed(self, *args):
myname = ???
func = getattr(otherobj, myname)
result = func(*args)
# result = ... process result ..
return result
class dispatch(object):
def __init__(self, cond=1):
for index in... | How to dynamically add members to class | My question can be simply illustrated by this code:
def proceed(self, *args):
myname = ???
func = getattr(otherobj, myname)
result = func(*args)
# result = ... process result ..
return result
class dispatch(object):
def __init__(self, cond=1):
for index in range(1, cond):
setattr(self, 'step%u... | [
"Not sure if this works, but you could try to exploit closures:\ndef make_proceed(name):\n def proceed(self, *args):\n func = getattr(otherobj, name)\n result = func(*args)\n # result = ... process result ..\n return result\n return proceed\n\n\nclass dispatch(object):\n def __in... | [
2,
2
] | [] | [] | [
"class",
"dynamic",
"members",
"python"
] | stackoverflow_0005143645_class_dynamic_members_python.txt |
Q:
How can I use a raw_input with twisted?
I am aware that raw_input cannot be used in twisted. However here is my desired application.
I have an piece of hardware that provides an interactive terminal serial port. I am trying to connect to this port and send commands in an async manner. I need it this way because... | How can I use a raw_input with twisted? | I am aware that raw_input cannot be used in twisted. However here is my desired application.
I have an piece of hardware that provides an interactive terminal serial port. I am trying to connect to this port and send commands in an async manner. I need it this way because this is a motor controller that once I issue... | [
"You have a couple of options here that you can use. One would be to use a child process to handle communicating with the serial port and a pipe to communicate between the parent and child (which is simplified by Twisted's Process Protocol). Another is to spin off a separate Python thread and use raw_input from the... | [
7,
3
] | [] | [] | [
"python",
"serial_port",
"twisted"
] | stackoverflow_0005143311_python_serial_port_twisted.txt |
Q:
Google AppEngine BlobInfo() features
Hi!
The official GAE documentation instists on existing such heplful BlobInfo instance properties as:
content_type;
creation;
filename;
size
I have try to using them in my app, but I'm can't imagine how to do it correctly and I'm can't find a some practical examples how to ut... | Google AppEngine BlobInfo() features | Hi!
The official GAE documentation instists on existing such heplful BlobInfo instance properties as:
content_type;
creation;
filename;
size
I have try to using them in my app, but I'm can't imagine how to do it correctly and I'm can't find a some practical examples how to utilize this GAE features nowhere. Can you h... | [
"Assuming that you have the key to your blob in a variable named blob_key. You could write code like this:\nblob_info = blobstore.BlobInfo.get(blob_key)\nprint('filename: %s' % blob_info.filename)\n\nblob key is usually returned by the BlobstoreUploadHandler that you use to upload your file.\n"
] | [
4
] | [] | [] | [
"blobstorage",
"google_app_engine",
"python"
] | stackoverflow_0004888440_blobstorage_google_app_engine_python.txt |
Q:
Extracting nouns from Noun Phase in NLP
Could anyone please tell me how to extract only the nouns from the following output:
I have tokenized and parsed the string "Give me the review of movie" based on a given grammar using following procedure:-
sent=nltk.word_tokenize(msg)
parser=nltk.ChartParser(grammar)
trees=... | Extracting nouns from Noun Phase in NLP | Could anyone please tell me how to extract only the nouns from the following output:
I have tokenized and parsed the string "Give me the review of movie" based on a given grammar using following procedure:-
sent=nltk.word_tokenize(msg)
parser=nltk.ChartParser(grammar)
trees=parser.nbest_parse(sent)
for tree in trees:
... | [
"You don't need to use a full parser to get nouns. You can simply use a tagger. One function you can use is nltk.tag.pos_tag(). This will return a list of tuples with the word and part of speech. You'll be able to iterate over the tuples and find words tagged with 'NN' or 'NNS' for noun or plural noun.\nNLTK ha... | [
6
] | [] | [] | [
"django",
"nlp",
"python"
] | stackoverflow_0005143788_django_nlp_python.txt |
Q:
list not working in a query
Can anyone tell me why this query will only process if I hard code phone_type
#model.py
class ClientPhone(models.Model):
client = models.ForeignKey(Client, editable=False)
...
phone_type = models.CharField(max_length=5, choices=PHONE_CHOICES)
number = models.CharField(m... | list not working in a query | Can anyone tell me why this query will only process if I hard code phone_type
#model.py
class ClientPhone(models.Model):
client = models.ForeignKey(Client, editable=False)
...
phone_type = models.CharField(max_length=5, choices=PHONE_CHOICES)
number = models.CharField(max_length=24)
# models.py
PHONE... | [
"latest() raises an exception if no matches are found, so unless each client has every single phone_type, you will get an exception when a client doesn't have one of the home, home2, mobi, etc choices.\nIn the second example, you are only ever looking for home, which apparently has a valid result for latest(). \nOn... | [
3,
0
] | [] | [] | [
"django",
"django_queryset",
"django_views",
"python"
] | stackoverflow_0005144003_django_django_queryset_django_views_python.txt |
Q:
Filter out HTML tags and resolve entities in python
Because regular expressions scare me, I'm trying to find a way to remove all HTML tags and resolve HTML entities from a string in Python.
A:
Use lxml which is the best xml/html library for python.
import lxml.html
t = lxml.html.fromstring("...")
t.text_content(... | Filter out HTML tags and resolve entities in python | Because regular expressions scare me, I'm trying to find a way to remove all HTML tags and resolve HTML entities from a string in Python.
| [
"Use lxml which is the best xml/html library for python.\nimport lxml.html\nt = lxml.html.fromstring(\"...\")\nt.text_content()\n\nAnd if you just want to sanitize the html look at the lxml.html.clean module\n",
"Use BeautifulSoup! It's perfect for this, where you have incoming markup of dubious virtue and need t... | [
39,
16,
6,
4,
2,
1,
0,
0
] | [] | [] | [
"html",
"python"
] | stackoverflow_0000037486_html_python.txt |
Q:
python - returning values for which if statement is true
I am starting out in Python and have a question about the following piece of code:
def prime2(n):
n = eval(input("What is your number? "))
for i in range(2, int(math.sqrt(n)) + 1):
if n % i == 0:
return False
else:
... | python - returning values for which if statement is true | I am starting out in Python and have a question about the following piece of code:
def prime2(n):
n = eval(input("What is your number? "))
for i in range(2, int(math.sqrt(n)) + 1):
if n % i == 0:
return False
else:
return True
So when True is returned, n is prime. Now ... | [
"Since there is an infinite amount of prime numbers, no. However, you can list all primes in a certain interval:\nfoo = [x for x in range(1000) if prime2(x)]\n\nThis gives you a list of all primes in the interval 0 to 1000.\nEdit: Why do you have n as parameter to your function, and then read it as input from the u... | [
4,
0
] | [] | [] | [
"python"
] | stackoverflow_0005144305_python.txt |
Q:
Querying on multiple tables using google apps engine (Python)
I have three tables, 1-Users, 2-Softwares, 3-UserSoftwares.
if suppose, Users table having 6 user records(say U1,U2,...,U6) and Softwares table having 4 different softwares(say S1,S2,S3,S4) and UserSoftwares stores the references if a user requested for... | Querying on multiple tables using google apps engine (Python) | I have three tables, 1-Users, 2-Softwares, 3-UserSoftwares.
if suppose, Users table having 6 user records(say U1,U2,...,U6) and Softwares table having 4 different softwares(say S1,S2,S3,S4) and UserSoftwares stores the references if a user requested for given software only.
For example: UserSoftwares(5 records) have on... | [
"since GAE's datastore is not relational you have to model your many-to-many relationship without using joins. Here are two methods you can adapt easily to your needs.\nWorking example using link model method (UPDATE #1)\nfrom google.appengine.ext import db\n\n# Defining models\n\nclass User(db.Model):\n name = ... | [
3,
0,
0
] | [] | [] | [
"google_app_engine",
"model",
"python"
] | stackoverflow_0005142192_google_app_engine_model_python.txt |
Q:
Is there any python xmpp library that supports adding/removing users?
Right now I have a python class that creates user/deletes users by executing "ejabberdctl register/unregister" commands. Is there a python xmpp library that supports adding/removing users?
A:
You need to have an implementation of XEP-0077: In-... | Is there any python xmpp library that supports adding/removing users? | Right now I have a python class that creates user/deletes users by executing "ejabberdctl register/unregister" commands. Is there a python xmpp library that supports adding/removing users?
| [
"You need to have an implementation of XEP-0077: In-Band Registration. xmpppy does appear to support this:\nimport sys\nimport os\nimport xmpp\n\nif len(sys.argv) < 3:\n print \"Syntax: register.py [JID] [Password]\"\n sys.exita(64)\n\njid=xmpp.protocol.JID(sys.argv[1])\ncli=xmpp.Client(jid.getDomain(), debu... | [
6,
1
] | [] | [] | [
"ejabberd",
"python",
"xmpp"
] | stackoverflow_0005131982_ejabberd_python_xmpp.txt |
Q:
Asp in python in IIS 7 is giving HTTP/1.1 500 Server Error
I am using Windows 7 and IIS 7 not as administrator but as a user. I have installed asp module and cgi module in IIS 7 in application development feature. My simple classic asp page is working which is :
<%response.write("Hello World")%>
My cgi in python ... | Asp in python in IIS 7 is giving HTTP/1.1 500 Server Error | I am using Windows 7 and IIS 7 not as administrator but as a user. I have installed asp module and cgi module in IIS 7 in application development feature. My simple classic asp page is working which is :
<%response.write("Hello World")%>
My cgi in python is working which is :
print "Content-Type: text/plain;charset=ut... | [
"Finally I found the solution to it.\nThe steps to be performed are\n\nRegister Python with ASP:\n\nOpen Command Prompt\nGo to {python_installation_dir}\\Lib\\site-packages\\win32comext\\axscript\\client\nRun python pyscript.py\n\nEnable 32-bit application for IIS7\n\nGo to IIS7\nRight click on your site's applicat... | [
0
] | [] | [] | [
"asp_classic",
"iis_7",
"python"
] | stackoverflow_0004815033_asp_classic_iis_7_python.txt |
Q:
parent->child relationships in appengine python (bigtable)
I'm still learning my lessons about data modeling in bigtable/nosql and would appreciate some feedback. Would it be fair to say that I should avoid parent->child relationships in my data modeling if I frequently need to deal with the children in aggregate ... | parent->child relationships in appengine python (bigtable) | I'm still learning my lessons about data modeling in bigtable/nosql and would appreciate some feedback. Would it be fair to say that I should avoid parent->child relationships in my data modeling if I frequently need to deal with the children in aggregate across parents?
As an example, let's say I'm building a blog th... | [
"Something like the first or second approach are well suited for App Engine. Consider the following setup:\nclass Author(db.Model): \n owner = db.UserProperty()\n\nclass Post(db.Model): \n author = db.ReferenceProperty(Author, \n collection_name='posts') \n tags = db.StringListProperty()\n\nclass Tag(db.Mode... | [
5,
2
] | [] | [] | [
"bigtable",
"database_design",
"google_app_engine",
"nosql",
"python"
] | stackoverflow_0005139014_bigtable_database_design_google_app_engine_nosql_python.txt |
Q:
Problem getting terminal output from ImageMagick's compare.exe ( Either by pipe or Python )
I'm fairly new to python, but have a fair amount of experience with other languages. I wonder if anyone can help.
The Problem
I'm trying to incorporate the comparison of two images (using ImageMagicks compare.exe) and then ... | Problem getting terminal output from ImageMagick's compare.exe ( Either by pipe or Python ) | I'm fairly new to python, but have a fair amount of experience with other languages. I wonder if anyone can help.
The Problem
I'm trying to incorporate the comparison of two images (using ImageMagicks compare.exe) and then make a decision based on the output.
I'm hitting problems, because I can't seem to pull the outpu... | [
"The compare tool outputs the result on stderr. Of course that totally does not make sense, but to work around it you need to forward stderr to a file (instead of stdout)\ncompare -metric AE -fuzz 2000 1.png 2.png diff.png 2> tmp.txt\n\nYou would really be better off using the Python ImageMagick module. The EXE fil... | [
4,
0
] | [] | [] | [
"imagemagick",
"python"
] | stackoverflow_0005145508_imagemagick_python.txt |
Q:
Dynamic module import of class list from module given its full path
First, it seems proper to me to state that I've read over the following questions:
Python imports by folder module
Dynamic module import in Python
And, I don't feel like they address my use case. That said, here's my question:
How can I dyna... | Dynamic module import of class list from module given its full path | First, it seems proper to me to state that I've read over the following questions:
Python imports by folder module
Dynamic module import in Python
And, I don't feel like they address my use case. That said, here's my question:
How can I dynamically import from a configuration file like this:
[imports]
/var/import... | [
"Look at the 2nd link again. It already mentions imp.load_source:\nimport imp\n\n# some sort of shared dict for everything imported\nloaded = {}\n\ndef load(path, from_list):\n # load the path\n module = imp.load_source( \"dummy\", path)\n for name in from_list:\n # add the names\n loaded[nam... | [
2,
1
] | [] | [] | [
"dynamic_import",
"python"
] | stackoverflow_0005145378_dynamic_import_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.