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:
How do I send key/value pairs to a web service with Python/SUDS?
I'm trying to access a really simple SOAP web service via Python script using the SUDS library.
Here's the WSDL body:
The python code I'm using to submit these two key/value pairs is as follows:
url = "http://somewhereontheweb.com/WS.asmx?wsdl"
clie... | How do I send key/value pairs to a web service with Python/SUDS? | I'm trying to access a really simple SOAP web service via Python script using the SUDS library.
Here's the WSDL body:
The python code I'm using to submit these two key/value pairs is as follows:
url = "http://somewhereontheweb.com/WS.asmx?wsdl"
client = suds.client.Client(url)
try:
result = client.service.SendKDI... | [
"firstly you can use the logging methods of :\nclient.last_received()\nclient.last_sent()\n\nthese will output the xml suds is sending.\nalso if you print the client\nprint client\n\nyou will see if there are any complex types associated with the service, my guess is that KeyValue will be a type you will have to cr... | [
2
] | [] | [] | [
"python",
"soap",
"suds"
] | stackoverflow_0008010462_python_soap_suds.txt |
Q:
Efficiently showing an OpenCV IplImage in Tkinter
I've got an application that converts OpenCV's IplImages to Tkinter images in a display loop. Naturally, I want to do this is the most efficient way possible to increase the app's responsiveness.
Here's how I'm currently doing it (frame is the IplImage):
pil_i... | Efficiently showing an OpenCV IplImage in Tkinter | I've got an application that converts OpenCV's IplImages to Tkinter images in a display loop. Naturally, I want to do this is the most efficient way possible to increase the app's responsiveness.
Here's how I'm currently doing it (frame is the IplImage):
pil_image = PIL.Image.fromstring(
'RGB',
... | [
"I couldn't find a better way to do it, so I refactored my application to use highgui to display the OpenCV images. It forces me to use an extra window and an extra thread (one for Tkinter GUI for the application widgets, and one for highgui), but at least this way the application is more responsive.\n"
] | [
1
] | [] | [] | [
"opencv",
"python",
"tkinter"
] | stackoverflow_0007930839_opencv_python_tkinter.txt |
Q:
Comparing User Input To Data Generated Randomly
I've written a python cgi script to generate random numbers and add them together
than ask the user to give the answer.
But even user answer was correct, it gives him wrong. The answer will not be correct.
The problem is in the flow :
#!/usr/bin/python2.7
import cgi... | Comparing User Input To Data Generated Randomly | I've written a python cgi script to generate random numbers and add them together
than ask the user to give the answer.
But even user answer was correct, it gives him wrong. The answer will not be correct.
The problem is in the flow :
#!/usr/bin/python2.7
import cgi,sys,random
sys.stderr = sys.stdout
input_field = c... | [
"if input_field[\"input\"].value == answer:\n\ntry this instead:\nif input_field[\"input\"].value.strip() == str(answer):\n\nYour script generates new numbers each time you call it:\n\nFirst call, random numbers generated and shown\nSecond call, new random numbers generated and compared to what the user enters (his... | [
0,
0,
0
] | [] | [] | [
"compare",
"python",
"random"
] | stackoverflow_0005646322_compare_python_random.txt |
Q:
Storing images in google datastore using Flask (Python)
I am using flask on google app engine and am desperately looking for help to solve this.
The GAE documentation talks of storing images in the datastore using the BlobProperty , which should be done something like this:-
class MyPics(db.Model):
name=db.S... | Storing images in google datastore using Flask (Python) | I am using flask on google app engine and am desperately looking for help to solve this.
The GAE documentation talks of storing images in the datastore using the BlobProperty , which should be done something like this:-
class MyPics(db.Model):
name=db.StringProperty()
pic=db.BlobProperty()
Now the image sh... | [
"Ok so this is how I finally solved it:-\n@userreg.route('/mypics',methods=['GET','POST'])\ndef mypics(): \n if request.method=='POST':\n mydata=MyPics()\n mydata.name=request.form['myname']\n file=request.files['file']\n filedata=file.read()\n if file:\n mydata.pic=db.Blob(fil... | [
6,
1,
0
] | [] | [] | [
"flask",
"google_app_engine",
"image",
"python"
] | stackoverflow_0004022974_flask_google_app_engine_image_python.txt |
Q:
Jython random module produces different results to cpython
I'm generating some test data using a known random seed. I want to use this data from cpython and from jython. I've found that the data is different if I use jython (2.5.2) vs cpython.
Boiling it down to a simple test, I can see that the PRNG is giving dif... | Jython random module produces different results to cpython | I'm generating some test data using a known random seed. I want to use this data from cpython and from jython. I've found that the data is different if I use jython (2.5.2) vs cpython.
Boiling it down to a simple test, I can see that the PRNG is giving different results in the two implementations:
In Jython:
Jython 2.5... | [
"There is a way around this. Both implementations include the pure-python \"WichmannHill\" PRNG. \nIt's slower but it gives the same results in both Jython and CPython. \nIn my code I replaced\nrandom.seed(1)\nuuid += random.choice(hexdigits)\n\nwith\nrand = random.WichmannHill(1)\nuuid += rand.choice(hexdigits)\n\... | [
6,
3
] | [] | [] | [
"jython",
"python",
"random"
] | stackoverflow_0008003460_jython_python_random.txt |
Q:
Why does the Python ITK PyBuffer not accept my numpy array?
I am using python 2.6 with ITK wrappers (from PythonXY 2.6.6.2). I am trying to send a 3D image from numpy/scipy to itk for processing.
import itk
imageType = itk.Image.F3
buf = scipy.zeros( (100,100,100), dtype = float)
itkImage = itk.PyBuffer[imageTyp... | Why does the Python ITK PyBuffer not accept my numpy array? | I am using python 2.6 with ITK wrappers (from PythonXY 2.6.6.2). I am trying to send a 3D image from numpy/scipy to itk for processing.
import itk
imageType = itk.Image.F3
buf = scipy.zeros( (100,100,100), dtype = float)
itkImage = itk.PyBuffer[imageType].GetImageFromArray(buf)
GetImageFromArray() fails with the fol... | [
"The answer was easy:\n\nIn python a \"float\" might be 64-Bit (double in c).\nIn itk F3 is a 32-bit float.\n\nSpecifying the right type for the ndarray makes it work:\nimport itk\nimageType = itk.Image.F3\nbuf = scipy.zeros( (100,100,100), dtype = numpy.float32)\nitkImage = itk.PyBuffer[imageType].GetImageFromArr... | [
6
] | [] | [] | [
"itk",
"numpy",
"python",
"scipy"
] | stackoverflow_0008010772_itk_numpy_python_scipy.txt |
Q:
How to find the ascii values of the characters in string?
I'm trying to convert characters in string into ascii value in Python
Like ord('a[i]') but ord expects only character not string!!
Is there any other method to solve this problem in python .
A:
>>> s = "string"
>>> map(ord, s)
[115, 116, 114, 105, 110, 1... | How to find the ascii values of the characters in string? | I'm trying to convert characters in string into ascii value in Python
Like ord('a[i]') but ord expects only character not string!!
Is there any other method to solve this problem in python .
| [
">>> s = \"string\"\n>>> map(ord, s)\n[115, 116, 114, 105, 110, 103]\n\n",
"An alternative to Sven's answer:\n[ord(c) for c in s]\n\n... or the corresponding generator expression:\n(ord(c) for c in s)\n\n"
] | [
9,
3
] | [] | [] | [
"python"
] | stackoverflow_0008011298_python.txt |
Q:
Combinations of weighted elements in a set where weighted sum equal to fixed integer (in python)
I would like to find all the possible combinations of weighted elements in a set where the sum of their weights is exactly equal to a given weight W
Say I want to select k elements from the set { 'A', 'B', 'C', 'D', 'E... | Combinations of weighted elements in a set where weighted sum equal to fixed integer (in python) | I would like to find all the possible combinations of weighted elements in a set where the sum of their weights is exactly equal to a given weight W
Say I want to select k elements from the set { 'A', 'B', 'C', 'D', 'E' } where weights = {'A':2, 'B':1, 'C':3, 'D':2, 'E':1} and W = 4.
Then this would yield :
('A','B','E... | [
"Looping through all n! permutations is much too expensive. Instead, generate all 2^n subsets.\nfrom itertools import chain, combinations\n\ndef weight(A):\n return sum(weights[x] for x in A)\n\n# Copied from example at http://docs.python.org/library/itertools.html\ndef powerset(iterable):\n \"powerset([1,2,3... | [
3,
1,
0
] | [] | [] | [
"combinations",
"knapsack_problem",
"python"
] | stackoverflow_0008010352_combinations_knapsack_problem_python.txt |
Q:
dynamic_cast failure while calling C++ API from Python
I am attempting to call a C++ API from python. Following is the code in the pseudo form.
class Engine { // Singleton Class which does a heavy duty work
public:
static Engine* getEngine();
bool init();
private:
static Engine* m_instance;
Engine(... | dynamic_cast failure while calling C++ API from Python | I am attempting to call a C++ API from python. Following is the code in the pseudo form.
class Engine { // Singleton Class which does a heavy duty work
public:
static Engine* getEngine();
bool init();
private:
static Engine* m_instance;
Engine();
};
// Following the code to wrap the call to engine to c... | [
"The question is how and when the dynamic library are loaded. The code\nyou show in engine_module.c references Engine, so the library with\nEngine will be automatically loaded before any of the initialization\ncode in engine_module.c is executed. Similarly, any libraries used by\nEngine will be loaded before the ... | [
1,
0
] | [] | [] | [
"c++",
"python"
] | stackoverflow_0008010763_c++_python.txt |
Q:
Adding dollar symbol in Python - xlwt & GAE
I'm trying to add dollar symbol ($) in Excel file using Python. I have coded the number format as '"$"#,##0.00' (see code below).
I run the code and download the Excel file. But when I open the Excel file it shows pound symbol.
Please note: My default accounting format ... | Adding dollar symbol in Python - xlwt & GAE | I'm trying to add dollar symbol ($) in Excel file using Python. I have coded the number format as '"$"#,##0.00' (see code below).
I run the code and download the Excel file. But when I open the Excel file it shows pound symbol.
Please note: My default accounting format symbol is "£ English UK". I need to show the curr... | [
"This code works fine. The problem is with your default accounting format symbol. If it is set to the pound symbol, your worksheet will replace the dollar symbol with the pound when you open the file. You will need to change this setting for it to show the dollar symbol.\n",
"You need to figure out how Excel hand... | [
1,
0
] | [] | [] | [
"google_app_engine",
"python",
"xlwt"
] | stackoverflow_0007977378_google_app_engine_python_xlwt.txt |
Q:
Blender: export to minilight?
MiniLight is a minimal global illumination renderer, written as an exercise
in simplicity. Is there a plugin to export Blender scenes to MiniLight? Or is there another plugin that could be modified to do it?
The MiniLight format is pretty simple:
#MiniLight
iterations
imagewidth im... | Blender: export to minilight? | MiniLight is a minimal global illumination renderer, written as an exercise
in simplicity. Is there a plugin to export Blender scenes to MiniLight? Or is there another plugin that could be modified to do it?
The MiniLight format is pretty simple:
#MiniLight
iterations
imagewidth imageheight
viewposition viewdirecti... | [
"I implemented a Python script (based on the 'Raw faces' one by Anthony D'Agostino) to export triangle meshes from Blender to the MiniLight format. If anyone else needs it, I made it available on GitHub.\n"
] | [
0
] | [] | [] | [
"3d",
"blender",
"python"
] | stackoverflow_0007979520_3d_blender_python.txt |
Q:
ValueError in decoding json
import json
import urllib
import re
import binascii
def asciirepl(match):
s = match.group()
return binascii.unhexlify(s[2:])
query = 'google'
p = urllib.urlopen('http://www.google.com/dictionary/json?callback=a&q='+query+'&sl=en&tl=en&restrict=pr,de&client=te')
page = p.read(... | ValueError in decoding json | import json
import urllib
import re
import binascii
def asciirepl(match):
s = match.group()
return binascii.unhexlify(s[2:])
query = 'google'
p = urllib.urlopen('http://www.google.com/dictionary/json?callback=a&q='+query+'&sl=en&tl=en&restrict=pr,de&client=te')
page = p.read()[2:-10] #As its returned as a fu... | [
"Decoding the \\x escapes may produce \" marks, which need to be re-escaped as they appear within \"strings\" encoded within the JSON data.\ndef asciirepl(match):\n chr = binascii.unhexlify(match.group()[2:])\n return '\\\\' + chr if chr in ('\\\\\"') else chr\n\nThat still won't handle control characters; so you... | [
3,
2
] | [] | [] | [
"json",
"python",
"regex"
] | stackoverflow_0008011692_json_python_regex.txt |
Q:
DrawingArea Cannot Get XID
I have the following Python 2.7/PyGObject 3.0/PyGST 0.10 module:
from gi.repository import Gtk, Gdk, GdkPixbuf
import pango
import pygst
pygst.require('0.10')
import gst
import Trailcrest
import os, sys
import cairo
from math import pi
class Video:
def __init__(self):
def ... | DrawingArea Cannot Get XID | I have the following Python 2.7/PyGObject 3.0/PyGST 0.10 module:
from gi.repository import Gtk, Gdk, GdkPixbuf
import pango
import pygst
pygst.require('0.10')
import gst
import Trailcrest
import os, sys
import cairo
from math import pi
class Video:
def __init__(self):
def on_message(bus, message):
... | [
"(Reprinted from GNOME PyGObject 3 Bug Report 663360. Answer credit goes to Timo Vanwynsberghe). \nThere are a couple of things to note:\n - the drawingarea has to be realised before you can get its GdkWindow\n - apparently, you can't get the window property directly\n - you need to import GdkX11 for the xid method... | [
8
] | [] | [] | [
"gstreamer",
"pygobject",
"python",
"python_gstreamer"
] | stackoverflow_0007975899_gstreamer_pygobject_python_python_gstreamer.txt |
Q:
error on installing pywin32 for python 2.6 on winXP
I get the following error at the end of installing pywin32-216.win32-py2.6.exe for python-2.6.msi for WinXP.
Traceback (most recent call last):
File "<string>", line 604, in <module>
File "<string>", line 314, in install
File "<string>", line 152, in LoadSyste... | error on installing pywin32 for python 2.6 on winXP | I get the following error at the end of installing pywin32-216.win32-py2.6.exe for python-2.6.msi for WinXP.
Traceback (most recent call last):
File "<string>", line 604, in <module>
File "<string>", line 314, in install
File "<string>", line 152, in LoadSystemModule
ImportError: DLL load failed: The specified modul... | [
"As Ignacio suggested \nhere you should run \nDependency Walker to understand what's amiss.\n"
] | [
0
] | [] | [] | [
"python",
"pywin32"
] | stackoverflow_0008003958_python_pywin32.txt |
Q:
marshalling from py to c and from c to py
In cython the marshalling of the types like int or char is done automatically,
but if I use a
cdef struct MyClass_Tag:
pass
ctypedef MyClass_Tag* MyClass_ptr
....
cdef class MyClass:
cdef MyClass_ptr obj
....
Now... | marshalling from py to c and from c to py | In cython the marshalling of the types like int or char is done automatically,
but if I use a
cdef struct MyClass_Tag:
pass
ctypedef MyClass_Tag* MyClass_ptr
....
cdef class MyClass:
cdef MyClass_ptr obj
....
Now for wrapping any function like for example in ... | [
"I didn't completly understood your question, but you might want to use the command:\ncython -a <yourfile.pyx>\n\nThen, open the generated with your webbrowser. You'll see how cython have translated your code into C, and then, found your answers :)\n",
"As the parameter name self suggests the C foo() function mi... | [
0,
0
] | [] | [] | [
"cython",
"python"
] | stackoverflow_0007850124_cython_python.txt |
Q:
HttpRequests in python not picked up by django
I am currently trying to create a REST web service for my django site from scratch and I do not want to use external libraries as this is supposed to be a learning experience. One of my applications act as the web application while the other will act as the web servic... | HttpRequests in python not picked up by django | I am currently trying to create a REST web service for my django site from scratch and I do not want to use external libraries as this is supposed to be a learning experience. One of my applications act as the web application while the other will act as the web service. I have plenty of examples on how to implement the... | [
"This is just because the development server is single-threaded. It can't both be responding to the original request from the client and the request that's generated internally, so it will hang.\n"
] | [
2
] | [] | [] | [
"django",
"http",
"python"
] | stackoverflow_0008012276_django_http_python.txt |
Q:
Python regex re.compile() match string
I am trying to grab the version number from a string via python regex...
Given filename: facter-1.6.2.tar.gz
When, inside the loop:
import re
version = re.split('(.*\d\.\d\.\d)',sfile)
print version
How do I get the 1.6.2 bit into version
A:
match = re.search(r'\d\.\d\.\d... | Python regex re.compile() match string | I am trying to grab the version number from a string via python regex...
Given filename: facter-1.6.2.tar.gz
When, inside the loop:
import re
version = re.split('(.*\d\.\d\.\d)',sfile)
print version
How do I get the 1.6.2 bit into version
| [
"match = re.search(r'\\d\\.\\d\\.\\d', sfile)\nif match:\n version = match.group()\n\n",
"Two logical problems:\n1) Since you want only the 1.6.2 portion, you don't want to capture the .* part before the first \\d, so it goes outside the parentheses.\n2) Since you only want to match the pattern in question and... | [
2,
2,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0008012320_python_regex.txt |
Q:
3x3 matrix conversion without loop (RGB color conversion)
I have an RGB image loaded into a numpy array via PIL. I get a rows x cols x 3 array. After tinkering, I arrived at the following code. I'd like to learn how to do such an array/matrix manipulation without the loop.
# Note using matrix not array.
rgb_to_yc... | 3x3 matrix conversion without loop (RGB color conversion) | I have an RGB image loaded into a numpy array via PIL. I get a rows x cols x 3 array. After tinkering, I arrived at the following code. I'd like to learn how to do such an array/matrix manipulation without the loop.
# Note using matrix not array.
rgb_to_ycc = np.matrix(
(0.2990, 0.5870, 0.1140,
-0.1687, -0.... | [
"I'm not sure about the formula you are using to convert RGB to YCC, so I don't want to claim this is the complete calculation, but to simplify the function you posted, yes, use np.dot with numpy arrays instead of numpy matrices.\nnp.dot is more general than * with numpy matrices. When using * with numpy matrices, ... | [
4,
3
] | [] | [] | [
"image_processing",
"numpy",
"python"
] | stackoverflow_0008010933_image_processing_numpy_python.txt |
Q:
can a python dictionary replace only what it finds?
The following works fine:
line = "Hello %(firstname)s %(lastname)s, how are you?"
print line % dict (firstname = "Mike", lastname="Kane")
and prints:
Hello Mike Kane, how are you?
But if I don't have a value for lastname, I still want this to work:
line = "He... | can a python dictionary replace only what it finds? | The following works fine:
line = "Hello %(firstname)s %(lastname)s, how are you?"
print line % dict (firstname = "Mike", lastname="Kane")
and prints:
Hello Mike Kane, how are you?
But if I don't have a value for lastname, I still want this to work:
line = "Hello %(firstname)s %(lastname)s, how are you?"
print line ... | [
"You can use a defaultdict\nfrom collections import defaultdict\n\nline = \"Hello %(firstname)s %(lastname)s, how are you?\"\nprint line % defaultdict(str, firstname = \"Mike\")\n\nExplanation: the first argument to the defaultdict initializer must be a callable that returns the default value. str is callable that ... | [
6,
2,
1
] | [] | [] | [
"dictionary",
"python"
] | stackoverflow_0008012578_dictionary_python.txt |
Q:
What does '*' signify in python function declarations ?
Possible Duplicate:
What does ** and * do for python parameters?
I saw this in a function definition, this was located in heapq.py, the python implementation of a heap queue
def merge(*iterables):
A:
You can read this part of the Python tutorial and this ... | What does '*' signify in python function declarations ? |
Possible Duplicate:
What does ** and * do for python parameters?
I saw this in a function definition, this was located in heapq.py, the python implementation of a heap queue
def merge(*iterables):
| [
"You can read this part of the Python tutorial and this post.\n"
] | [
1
] | [] | [] | [
"python"
] | stackoverflow_0008012720_python.txt |
Q:
Is it possible to interrupt parsing large xml file in the middle with lxml target parsing interface?
I am getting information from a large xml file and I am using python with lxml target parsing interface to do it. I would like the possibility to set a limit after which parsing stops. Here is some code:
Parser tar... | Is it possible to interrupt parsing large xml file in the middle with lxml target parsing interface? | I am getting information from a large xml file and I am using python with lxml target parsing interface to do it. I would like the possibility to set a limit after which parsing stops. Here is some code:
Parser target code:
class TitleTarget(object):
def __init__(self, limit=None):
self.limit = limit
... | [
"Instead of using etree.parse(file, parser), you can loop over the lines in file and call parser.feed on each line. This gives you control over when to break out of the loop.\nNow you can just set a self.done=True in the target, and test for target.done in the feed loop:\n\nimport lxml.etree as ET\nclass HaltingTar... | [
1
] | [] | [] | [
"lxml",
"python",
"xml"
] | stackoverflow_0008010683_lxml_python_xml.txt |
Q:
Is there a way to check if two lists contain any of the same values in Python?
For example if I had:
a = [20,30,56,78,99]
b = [10,20,40,56,99]
What could I use so that I could search the 2 lists get the values 20,56 and 99?
Note: I can't use the set function on this.
A:
Python sets are a clean, simple way to do... | Is there a way to check if two lists contain any of the same values in Python? | For example if I had:
a = [20,30,56,78,99]
b = [10,20,40,56,99]
What could I use so that I could search the 2 lists get the values 20,56 and 99?
Note: I can't use the set function on this.
| [
"Python sets are a clean, simple way to do it:\n>>> a = [20,30,56,78,99]\n>>> b = [10,20,40,56,99]\n>>> set(a) & set(b)\nset([56, 99, 20])\n\nIf you can't use those, the same can be done using dictionaries:\n>>> d = dict.fromkeys(b)\n>>> for k in a:\n if k in d:\n print k\n\n20\n56\n99\n\nIf the e... | [
2,
2,
1
] | [] | [] | [
"python",
"variables"
] | stackoverflow_0008012747_python_variables.txt |
Q:
__rsub__ and __rtruediv__ with fractions
I'm attempting to use the __rsub__ function in a class I've made called Fraction.
Here's the Fraction class code:
def __init__(self, num, denom):
''' Creates a new Fraction object num/denom'''
self.num = num
self.denom = denom
self.reduce()
def __repr__(s... | __rsub__ and __rtruediv__ with fractions | I'm attempting to use the __rsub__ function in a class I've made called Fraction.
Here's the Fraction class code:
def __init__(self, num, denom):
''' Creates a new Fraction object num/denom'''
self.num = num
self.denom = denom
self.reduce()
def __repr__(self):
''' returns string representation of... | [
"You first need to convert other to a Fraction to make this work:\ndef __rsub__(self, other):\n return Fraction(other, 1) - self\n\nSince __rsub__() only gets called if other is not of type Fraction, we don't need any type checking -- we simply assume it is an integer.\nYour current implementation of __sub__() a... | [
3,
1,
0
] | [] | [] | [
"fractions",
"magic_methods",
"math",
"python"
] | stackoverflow_0008012772_fractions_magic_methods_math_python.txt |
Q:
calling init for multiple parent classes with super?
Possible Duplicate:
Can Super deal with multiple inheritance?
Python inheritance? I have a class structure (below), and want the child class to call the __init__ of both parents. Is this possible to do in a 'super' way or is it just a terrible idea?
class Pare... | calling init for multiple parent classes with super? |
Possible Duplicate:
Can Super deal with multiple inheritance?
Python inheritance? I have a class structure (below), and want the child class to call the __init__ of both parents. Is this possible to do in a 'super' way or is it just a terrible idea?
class Parent1(object):
def __init__(self):
self.var1 = ... | [
"The idea of super() is that you don't have to bother calling both superclasses' __init__() methods separately -- super() will take care of it, provided you use it correctly -- see Raymond Hettinger's \"Python’s super() considered super!\" for an explanation.\nThat said, I often find the disadvantages of super() fo... | [
42,
26,
13
] | [] | [] | [
"init",
"multiple_inheritance",
"new_style_class",
"python",
"super"
] | stackoverflow_0008013076_init_multiple_inheritance_new_style_class_python_super.txt |
Q:
Retrieve indices of matching points in another array
Total blank on how to do this.
I have an array "points" and an array "a" containing some of those points:
points = numpy.array([[1,2],[4,0],[3,0],[2,4]])
a = numpy.array([[1,2], [3,0]])
How can I get the indices in "points" of points in a ([0,2]), preferably wi... | Retrieve indices of matching points in another array | Total blank on how to do this.
I have an array "points" and an array "a" containing some of those points:
points = numpy.array([[1,2],[4,0],[3,0],[2,4]])
a = numpy.array([[1,2], [3,0]])
How can I get the indices in "points" of points in a ([0,2]), preferably without loops?
| [
"This is an O(n²) operation and is not meant to have a direct method without a loop.\nThe following solution works for any size of 2D variables of points and a.\nimport numpy as np\npoints = np.array([[1,2],[4,0],[3,0],[2,4]])\na = np.array([[1,2], [3,0]])\n\n\nnp.array([np.argwhere((points==a[i]).all(axis=1))[0][0... | [
0,
0
] | [] | [] | [
"indices",
"numpy",
"python"
] | stackoverflow_0008010161_indices_numpy_python.txt |
Q:
Replace multiple texts with their corresponding texts in XML using Python - Part 2 -
I would like to replace a text of aliasname element with a text from name if there is no corresponding key in the dictionary.
here is the xml that I am working on now.
- <esri:Workspace xmlns:esri="http://www.esri.com/schemas/Ar... | Replace multiple texts with their corresponding texts in XML using Python - Part 2 - | I would like to replace a text of aliasname element with a text from name if there is no corresponding key in the dictionary.
here is the xml that I am working on now.
- <esri:Workspace xmlns:esri="http://www.esri.com/schemas/ArcGIS/10.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.or... | [
"I guess (seeing that the current behaviour is not what you want) you'd like to replace a text of <AliasName> element with a text from <Name> if there is no corresponding key in the dictionary. Change this line (which doesn't change <AliasName> if there is no key):\n alias.text = jp2en.get(name.text.strip(), alias.... | [
1
] | [] | [] | [
"elementtree",
"python",
"python_3.x",
"xml"
] | stackoverflow_0008011775_elementtree_python_python_3.x_xml.txt |
Q:
Can't OAuth with Facebook; what are my next debugging steps?
I've got a Django template that initiates the Facebook OAuth process by doing:
window.location='https://www.facebook.com/dialog/oauth?client_id=MY_CLIENT_ID&redirect_uri=http%3A//localhost%3A8000/fbpanel/explore-python'
Then, in my Django view, I get th... | Can't OAuth with Facebook; what are my next debugging steps? | I've got a Django template that initiates the Facebook OAuth process by doing:
window.location='https://www.facebook.com/dialog/oauth?client_id=MY_CLIENT_ID&redirect_uri=http%3A//localhost%3A8000/fbpanel/explore-python'
Then, in my Django view, I get the resulting code as follows:
import cgi
import urllib
# [...]
co... | [
"The value used for redirect_uri must be exactly the same when you request the token as it was when you requested the code. Since no actual redirect occurs when requesting the token, it can be easy to miss small differences. The error message is not particularly descriptive in this case; what it really means is \"T... | [
3
] | [] | [] | [
"django",
"facebook",
"oauth_2.0",
"python"
] | stackoverflow_0008001628_django_facebook_oauth_2.0_python.txt |
Q:
How do you make an access a hash in python?
I know this question sounds very basic. But I can't find it using Google. I know that there are dictionaries that look like
o = {
'a': 'b'
}
and they're accessed with o['a']. But what are the ones that are accessed as o.a called? I know they exist because I'm using op... | How do you make an access a hash in python? | I know this question sounds very basic. But I can't find it using Google. I know that there are dictionaries that look like
o = {
'a': 'b'
}
and they're accessed with o['a']. But what are the ones that are accessed as o.a called? I know they exist because I'm using optparse library and it returns an object accessibl... | [
"You can not access dicts using the '.' unless you implement your own dict type by deriving from dict and providing access through the '.' notation by implementing the __getattribute__() API which is in charge for performing attribute style access.\nSee http://docs.python.org/reference/datamodel.html#object.__getat... | [
2,
2,
1,
0,
0
] | [] | [] | [
"hash",
"python"
] | stackoverflow_0005527834_hash_python.txt |
Q:
Python: Stop Auto Exiting Cmd Prompt
So I just started learning Python and just now set up my Notepad++ to run it via cmd prompt. Is there a simple way to stop my cmd prompt from auto-exiting when I run a simple program? Do I need to ask for input every time or something or is there an easier way?
I tried raw_inpu... | Python: Stop Auto Exiting Cmd Prompt | So I just started learning Python and just now set up my Notepad++ to run it via cmd prompt. Is there a simple way to stop my cmd prompt from auto-exiting when I run a simple program? Do I need to ask for input every time or something or is there an easier way?
I tried raw_input('Press Enter to exit') but no luck.
Here... | [
"What I personally like to do is have the Python script just run to completion without asking for input, then write a batch file (Windows) or shell script (Linux/UNIX) to do the \"press any key\" thing. That way when I run the script from the command line it doesn't needlessly prompt me for input. \nYou could write... | [
3,
2
] | [] | [] | [
"cmd",
"command_prompt",
"notepad++",
"python"
] | stackoverflow_0008013799_cmd_command_prompt_notepad++_python.txt |
Q:
Python - set somehow getting duplicate data
I have an class definition with a __hash__ function that uses the object properties to create a unique key for comparison in python sets.
The hash method looks like this:
def __hash__(self):
return int('%d%s'%(self.id,self.create_key))
In a module responsible for implem... | Python - set somehow getting duplicate data | I have an class definition with a __hash__ function that uses the object properties to create a unique key for comparison in python sets.
The hash method looks like this:
def __hash__(self):
return int('%d%s'%(self.id,self.create_key))
In a module responsible for implementing this class, several queries are run that c... | [
"\nIf a class does not define a __cmp__() or __eq__() method it should not define a __hash__() operation either\n\nsource\nDefine __eq__().\n",
"You also need to implement __eq__() to match your __hash__() implementation.\n"
] | [
4,
1
] | [] | [] | [
"iterator",
"python",
"set"
] | stackoverflow_0008014310_iterator_python_set.txt |
Q:
Django template dictionary displays in a wrong order
I have a following dictionary. Variable name is division_total_display
{87L: {'name': ,
'total': 660L,
'total_percentage': 39,
'total_right': 256L},
88L: {'name': ,
'total': 660L,
'total_percentage': 42,
'total_right':... | Django template dictionary displays in a wrong order | I have a following dictionary. Variable name is division_total_display
{87L: {'name': ,
'total': 660L,
'total_percentage': 39,
'total_right': 256L},
88L: {'name': ,
'total': 660L,
'total_percentage': 42,
'total_right': 274L},
89L: {'name': ,
'total': 435L,
'tot... | [
"Dictionaries are unordered. Use a nested list instead.\n",
"Try using an OrderedDict instead. Regular python dictionaries are unordered -- they are implemented using hash tables which will scramble the key order.\nPer the docs for dictionaries: \"it is best to think of a dictionary as an unordered set of key: v... | [
4,
1
] | [] | [] | [
"django",
"python",
"templates"
] | stackoverflow_0008014036_django_python_templates.txt |
Q:
django base template date rendering
I am very new to django and I have a simple problem. Hope that you will help me solve this. I have a base template like this;
<!doctype html>
<html>
<head>
<title>{% block title %} {% endblock %}</title>
<link type="text/css" rel ="stylesheet" href="style.css" />
<script type="t... | django base template date rendering | I am very new to django and I have a simple problem. Hope that you will help me solve this. I have a base template like this;
<!doctype html>
<html>
<head>
<title>{% block title %} {% endblock %}</title>
<link type="text/css" rel ="stylesheet" href="style.css" />
<script type="text/javascript" src="jquery.js"> </script... | [
"This is what context processors are for.\n",
"Does this help ...\nhttps://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#now\n",
"Let me see if I get this straight: The year should always be the current year? Not just a static text, because then you would have written it instead, am I right... | [
2,
2,
1,
1
] | [] | [] | [
"django",
"django_templates",
"python"
] | stackoverflow_0008014097_django_django_templates_python.txt |
Q:
Python: Best approach to storing object state in database?
I need to store instances (or at least their state) in a database. The idea is that I should be able to re-create the instance on demand. Since I define the classes, I can choose how I would like to store the data.
Consider the following diagram, inheritan... | Python: Best approach to storing object state in database? | I need to store instances (or at least their state) in a database. The idea is that I should be able to re-create the instance on demand. Since I define the classes, I can choose how I would like to store the data.
Consider the following diagram, inheritance diagram:
A
/ \
... | [
"There are several approaches. I don't really think we can tell you from the information you've provided what the best approach for you is.\n\nYou can use an ORM, like SQLAlchemy.\nYou can use an object database. \nYou could pickle your objects and store them in any relational database or datastore including shelve... | [
4,
2,
0
] | [] | [] | [
"database",
"oop",
"python"
] | stackoverflow_0008014489_database_oop_python.txt |
Q:
clicking a link cause running a view
I have a view for logout,now I wanna when user click on an anchor link the logout view run,how can I do this?
in views.py:
def logout(request):
auth.logout(request)
return render_to_response("airAgency/index.html")
A:
I'm new in django,I can submit a form and run a vi... | clicking a link cause running a view | I have a view for logout,now I wanna when user click on an anchor link the logout view run,how can I do this?
in views.py:
def logout(request):
auth.logout(request)
return render_to_response("airAgency/index.html")
| [
"\nI'm new in django,I can submit a form and run a view for that, but I\n don't now what should I do to run s.th like logout view when clicking\n an anchor link.\n\nLogging out via a link instead of a form is easy. \nhttps://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.logout\nfrom django.contri... | [
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0008013042_django_python.txt |
Q:
Crypting file with python
Possible Duplicate:
python: how to encrypt a file?
I'm trying to make application that need write secret data in file and allow read data from this file with only user password. do you know any methods for encode/decode file with pass phrase?
A:
You can try PyCrypto module.
However, d... | Crypting file with python |
Possible Duplicate:
python: how to encrypt a file?
I'm trying to make application that need write secret data in file and allow read data from this file with only user password. do you know any methods for encode/decode file with pass phrase?
| [
"You can try PyCrypto module.\nHowever, due to the poor documentation and no official tutorials, you may wish also to see how to encrypt files with AES.\n",
"You never considered using Google before asking?\nThe official documentation has a bunch of tutorials regarding hashing and encryption.\n",
"The best-know... | [
2,
1,
0
] | [] | [] | [
"encryption",
"file",
"python"
] | stackoverflow_0008014703_encryption_file_python.txt |
Q:
django: how many queries does this cause?
Say I have the following models:
class Baz(models.Model):
winning = models.CharField(max_length=100)
class Bar(models.Model):
baz = models.ForeignKey(Baz)
class Foo(models.Model):
bar = models.ForeignKey(Bar)
Now I have an instance of Foo, foo. How many quer... | django: how many queries does this cause? | Say I have the following models:
class Baz(models.Model):
winning = models.CharField(max_length=100)
class Bar(models.Model):
baz = models.ForeignKey(Baz)
class Foo(models.Model):
bar = models.ForeignKey(Bar)
Now I have an instance of Foo, foo. How many queries does the following line execute?
winning = ... | [
"That will require 3 queries. \nOne to get foo, bar, and baz.\nUse select_related() to get them at once.\nFoo.objects.get(id=1).select_related('bar__baz__winning')\n\n",
"There is a quick way to tell. Install Django Toolbar. Then check out the queries tab. It will give you all sorts of profiling info.\nThough I b... | [
4,
2,
1
] | [] | [] | [
"django",
"performance",
"python",
"sql"
] | stackoverflow_0008014492_django_performance_python_sql.txt |
Q:
Best way/pattern to build request based on different service
I have a about 20 different services which I have to send requests to which require a slightly different set of headers.
The bad legacy code is something like this,
row = db.query_for_service()
if row.type == 'foo1'
// add common headers to request... | Best way/pattern to build request based on different service | I have a about 20 different services which I have to send requests to which require a slightly different set of headers.
The bad legacy code is something like this,
row = db.query_for_service()
if row.type == 'foo1'
// add common headers to request
// add foo1 specific headers 1
// add foo1 specific header ... | [
"Personally, what I would do is something along these lines. \n#Put this in the initialisation \nMap foos<row.type,String> = new Map<row.type, String>()\n#Populate the map \nmap.set('a') = 'headerA specific params x=1'\nmap.set('b') = 'headerB specific params x=2'\nmap.set('c') = 'headerC specific params y=3'\nmap.... | [
2,
1
] | [] | [] | [
"design_patterns",
"java",
"oop",
"python",
"refactoring"
] | stackoverflow_0008013112_design_patterns_java_oop_python_refactoring.txt |
Q:
How to import a module from a folder next to the current folder?
I have checked as many SO pages as I could and tried everything I found, but none have been successful. I also checked the PEP page regarding importing and tried every example, none of which worked.
I have a tests folder with unit tests in them, and... | How to import a module from a folder next to the current folder? | I have checked as many SO pages as I could and tried everything I found, but none have been successful. I also checked the PEP page regarding importing and tried every example, none of which worked.
I have a tests folder with unit tests in them, and I need to import the module I want to test. The modules are in a fold... | [
"If scripts are executed from inside a package, then various hacks need to be employed to get the imports to work properly. Probably the most common of these is to manipulate sys.path:\nimport sys, os\n\nsys.path.insert(0,\n os.path.dirname(os.path.dirname(os.path.abspath(__file__))))\n\nfrom src import stringbu... | [
12,
1
] | [
"Add that folder to your PATH.\n"
] | [
-9
] | [
"import",
"module",
"python"
] | stackoverflow_0008013170_import_module_python.txt |
Q:
Regular expression to match everything to the end of a string, excluding the last character if it's a slash (/)
Currently, I have the following Python regex:
r'^https?://(www.)?domain.com/?(?P<path>.*)/?$'
That I'm replacing with:
r'/\g<path>/'
This works fine except in the scenario where the last character of t... | Regular expression to match everything to the end of a string, excluding the last character if it's a slash (/) | Currently, I have the following Python regex:
r'^https?://(www.)?domain.com/?(?P<path>.*)/?$'
That I'm replacing with:
r'/\g<path>/'
This works fine except in the scenario where the last character of the string is a slash (/). In that case, the .* greedily consumes the last /, so the subbed string ends up as /path//
... | [
"Don't use regular expressions for this, use the urlparse module instead.\nExample from the docs:\n>>> from urlparse import urlparse\n>>> o = urlparse('http://www.cwi.nl:80/%7Eguido/Python.html')\n>>> o\nParseResult(scheme='http', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html',\n params='', query='... | [
4,
3
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0008015214_python_regex.txt |
Q:
Plone+Python - How to automatically set content item to be default view of the folder?
I use xmlrpclib, wsapi4plone to upload stuff to plone.
Say I'm going to create a folder:
client = xmlrpclib.ServerProxy('http://user:password@blah.com/plone')
f = {'blah.com/plone/folder':
[
{'title': fol... | Plone+Python - How to automatically set content item to be default view of the folder? | I use xmlrpclib, wsapi4plone to upload stuff to plone.
Say I'm going to create a folder:
client = xmlrpclib.ServerProxy('http://user:password@blah.com/plone')
f = {'blah.com/plone/folder':
[
{'title': folder},
'Folder', None,
]
}
print 'Creating...', client.post_object(f)
then ... | [
"The method you are looking for is setDefaultPage on the folder. If you have the right to set the default page through the web with your user, you have the same right via XML-RPC, access control is method agnostic. setDefaultPage takes the id of the page object as an argument.\nsetDefaultPage is part of the ISelect... | [
2
] | [] | [] | [
"plone",
"python"
] | stackoverflow_0008014343_plone_python.txt |
Q:
Read only the first page of an HTTP served PDF file
Scenario:
We are interested in fetching the very first page of a PDF available from a remote HTTP server and the application lives in a bandwidth constricted environment.
What are the options to fulfill the task?
A:
The pyPdf module may help.
| Read only the first page of an HTTP served PDF file | Scenario:
We are interested in fetching the very first page of a PDF available from a remote HTTP server and the application lives in a bandwidth constricted environment.
What are the options to fulfill the task?
| [
"The pyPdf module may help.\n"
] | [
0
] | [] | [] | [
"pdf",
"python"
] | stackoverflow_0008012946_pdf_python.txt |
Q:
Python: What's the fastest way to zip right to left, and is there no builtin for this?
Given 2 sequences of different lengths:
In [931]: a = [1,2,3]
In [932]: b = [4,5,6,7]
This is what i want
In [933]: c = zip(reversed(a),reversed(b))
In [934]: [x for x in reversed(c)]
Out[934]: [(1, 5), (2, 6), (3, 7)]
But I d... | Python: What's the fastest way to zip right to left, and is there no builtin for this? | Given 2 sequences of different lengths:
In [931]: a = [1,2,3]
In [932]: b = [4,5,6,7]
This is what i want
In [933]: c = zip(reversed(a),reversed(b))
In [934]: [x for x in reversed(c)]
Out[934]: [(1, 5), (2, 6), (3, 7)]
But I don't like the idea of using reversed on all my input parameters, and I also don't want to re... | [
"The following is faster and clearer than the other posted solutions:\ns = zip(reversed(a), reversed(b))\ns.reverse() # in-place\n\nThe reversed built-in creates an iterator those loops backwards at the same speed as forward iteration. No additional memory (full copies of the input) are produ... | [
9,
5,
3,
2,
0,
0
] | [] | [] | [
"built_in",
"python"
] | stackoverflow_0008013071_built_in_python.txt |
Q:
ffmpeg - help understanding + correcting error message
I have a python script that takes a movie file name and it does it job of splitting and converting videos. However, there are red error messages that constantly pop up on the console saying:
[buffer @ 0xa124320] Buffering several frames is not supported. Pleas... | ffmpeg - help understanding + correcting error message | I have a python script that takes a movie file name and it does it job of splitting and converting videos. However, there are red error messages that constantly pop up on the console saying:
[buffer @ 0xa124320] Buffering several frames is not supported. Please consume all available frames before adding a new one.
How... | [
"It sounds like there's a problem with how your python script is interfacing with ffmpeg, or your ffmpeg settings.\nIf you're just interested in suppressing the console output, you could simply redirect the stderr of the python/ffmpeg process to /dev/null. Of course, that will prevent you seeing any errors from ff... | [
0
] | [] | [] | [
"ffmpeg",
"python"
] | stackoverflow_0005919777_ffmpeg_python.txt |
Q:
Finding an approximation of the constant Pi within error [ PYTHON ]
I just started learning Python and I am having a problem writing the function.
The following is an infinite series that calculates an approximation of π :
π = 4/1 − 4/3 + 4/5 - 4/7 + 4/9 - 4/11 ...
I am trying to write a function that takes as a p... | Finding an approximation of the constant Pi within error [ PYTHON ] | I just started learning Python and I am having a problem writing the function.
The following is an infinite series that calculates an approximation of π :
π = 4/1 − 4/3 + 4/5 - 4/7 + 4/9 - 4/11 ...
I am trying to write a function that takes as a parameter a floating point value error and approximates the constant π wit... | [
"You can do something like this:\nmypie = 0\ndenominator = 1\nsign = 1\n\nwhile denominator < 100:\n mypie = mypie + (4.0 / denominator) * sign\n sign = -sign\n denominator = denominator + 2\n\n"
] | [
1
] | [] | [] | [
"python"
] | stackoverflow_0008015549_python.txt |
Q:
python append weird behavior
I have created an object type.. and after initilializing I am pushing that into a list.
but for some reason the behavior is not as expected.
let me put in the sample code.. and then the output.
def allignDatesToWhenWasItemSold(pilotInstance):
unitsSoldPerDay = pilotInstance._units_... | python append weird behavior | I have created an object type.. and after initilializing I am pushing that into a list.
but for some reason the behavior is not as expected.
let me put in the sample code.. and then the output.
def allignDatesToWhenWasItemSold(pilotInstance):
unitsSoldPerDay = pilotInstance._units_sold_per_day
productPart = pil... | [
"You are using the same productpart instance, and just mutating it:\nproductPart._date = modDate\n\nSince all the PilotTest objects have a reference to the same productPart instance, all of them see the mutation.\nYou need to create a new instance of your class on each iteration through the loop and assign this new... | [
2
] | [] | [] | [
"list",
"python"
] | stackoverflow_0008015603_list_python.txt |
Q:
Browscap For Python
I was looking around, and couldn't find the Python equivalent of browscap (that I've used in PHP to detect what browser a given user-agent string is.
I'm hoping I'm not going to have to write my own.. :P
A:
Check this out, it should do what you want: browscap.ini-parser.
Please note that even... | Browscap For Python | I was looking around, and couldn't find the Python equivalent of browscap (that I've used in PHP to detect what browser a given user-agent string is.
I'm hoping I'm not going to have to write my own.. :P
| [
"Check this out, it should do what you want: browscap.ini-parser.\nPlease note that even though it is on the Django Snippets website it is standalone and you can use it with whatever setup you have.\n",
"Checkout the pybrowscap library, it is equivalent for php get_browser : http://pypi.python.org/pypi/pybrowscap... | [
2,
1
] | [] | [] | [
"browscap",
"python"
] | stackoverflow_0000784418_browscap_python.txt |
Q:
Updating a listbox in wxpython?
I am having some trouble, updating a listbox, Ive tried Refresh and Update but those returned errors.
The listbox uses a list to get its information. It will show the initial items in the list.
However when i update the list (while the program is running), it will not show the chang... | Updating a listbox in wxpython? | I am having some trouble, updating a listbox, Ive tried Refresh and Update but those returned errors.
The listbox uses a list to get its information. It will show the initial items in the list.
However when i update the list (while the program is running), it will not show the changes live.
If you have difficulty under... | [
"Use the method Set():\nself.mylistbox.Set(listofchoices)\n\n\nResets the list box to the list given in choices—that is, the current\n elements are removed from the list and replaced by the new list.\n\n"
] | [
5
] | [] | [] | [
"python",
"wxpython"
] | stackoverflow_0008015867_python_wxpython.txt |
Q:
Is there a way to know the variable name that URL Dispatcher pass to view?
i dont know if this is possible, but i will explain what i want try !
I made a Context Processor that will load some user information.
I need know, in this context processor, if there is a variable named "group" in the vars list that will b... | Is there a way to know the variable name that URL Dispatcher pass to view? | i dont know if this is possible, but i will explain what i want try !
I made a Context Processor that will load some user information.
I need know, in this context processor, if there is a variable named "group" in the vars list that will be passed to my view, and if is, i will load up more things.
The processor only r... | [
"see: resolve() It does exactly what are you trying to do. Be aware that this function throws an 404 exception if it doesn't find a match, so be ready to catch it.\n",
"Could you just add this in selectively on a per-view basis? Then you could do something like this:\ndef group_processor(request):\n # ...\n\nd... | [
2,
0
] | [] | [] | [
"dispatcher",
"django",
"python",
"url"
] | stackoverflow_0008015916_dispatcher_django_python_url.txt |
Q:
Splitting models into different classes?
I have a ton of models. I mean a ton. Would it be possible to reorganize these models into a nicer format using a new Python package?
IE: Current -
myproject/
web/
models.py
IE: New -
myproject/
web/
models/
__init__.py
ev... | Splitting models into different classes? | I have a ton of models. I mean a ton. Would it be possible to reorganize these models into a nicer format using a new Python package?
IE: Current -
myproject/
web/
models.py
IE: New -
myproject/
web/
models/
__init__.py
events.py
registrations.py
... | [
"Yes. It's a bit tedious: you will want to revise which imports to keep in each file, etc., but it's definitely possible.\nYou can also do it piecemeal, by renaming models.py to models/__init__.py (which shouldn't have any effect at all), and then moving stuff out one module at a time.\n"
] | [
2
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0008016136_django_django_models_python.txt |
Q:
How do I deal with list of lists correctly in python? Specifically with a list of functions
I am trying to grep some results pages for work, and then eventually print them out to an html website so someone does not have to manually look through each section.
How I would eventually use: I feed this function a resul... | How do I deal with list of lists correctly in python? Specifically with a list of functions | I am trying to grep some results pages for work, and then eventually print them out to an html website so someone does not have to manually look through each section.
How I would eventually use: I feed this function a result page, it greps through the 5 different sections, then I can do a html output (thats what that p... | [
"Generally, you don't declare the shape of the list first, and then fill in the values. Instead, you build the list as you discover the values.\nYour variables has a lot of structure. You've got inner lists of 3 elements, always in the order of 'total', 'pass', 'fail'. Perhaps these 3-tuples should be made namedtup... | [
3,
0,
0
] | [] | [] | [
"list",
"python",
"variables"
] | stackoverflow_0008015905_list_python_variables.txt |
Q:
How will Lion's New Security Model Affect things like Python?
I'm curious to know how the new security model in OS X Lion will affect the future. Specifically, I'm questioning Entitlements and Sandboxing.
This isn't a question of whether or not these are good ideas. Rather, this is a question of best guess of what... | How will Lion's New Security Model Affect things like Python? | I'm curious to know how the new security model in OS X Lion will affect the future. Specifically, I'm questioning Entitlements and Sandboxing.
This isn't a question of whether or not these are good ideas. Rather, this is a question of best guess of what will happen in the future.
I'm curious about things like Python. M... | [
"If you could embed Python along with your script and package it into a .app using something like py2app, I would imagine you could add/edit the Info.plist to satisfy Apple's requirements for signing. Similarly for entitlements, I would imagine you could edit the .app's entitlements.plist. I think the sandbox enfor... | [
6
] | [] | [] | [
"appstore_sandbox",
"entitlements",
"macos",
"osx_lion",
"python"
] | stackoverflow_0007419912_appstore_sandbox_entitlements_macos_osx_lion_python.txt |
Q:
What is the most simple / lightest-weight WSGI framework?
Which of the WSGI frameworks are super lightweight and minimal? If you are familar with ruby, then I'm looking for something similar to Rails Metal.
WSGI == Rack
Rails == Django
Sinatra == Flask
Rails Metal == ???????
A:
I believe Werkzeug is what you're... | What is the most simple / lightest-weight WSGI framework? | Which of the WSGI frameworks are super lightweight and minimal? If you are familar with ruby, then I'm looking for something similar to Rails Metal.
WSGI == Rack
Rails == Django
Sinatra == Flask
Rails Metal == ???????
| [
"I believe Werkzeug is what you're looking for.\n"
] | [
5
] | [] | [] | [
"flask",
"frameworks",
"python",
"rack",
"wsgi"
] | stackoverflow_0008016390_flask_frameworks_python_rack_wsgi.txt |
Q:
Trouble with zip when running for loop monte carlo sim; python
Working in python 2.7.
I'm sure the code is a little unwieldy, but I'll try to explain it as simply as I can.
I have two lists:
T = [[1,0], [1,0], [0,5]]
S = [[1], [3], [2]]
I need to add the corresponding value from B to the end of the corresponding ... | Trouble with zip when running for loop monte carlo sim; python | Working in python 2.7.
I'm sure the code is a little unwieldy, but I'll try to explain it as simply as I can.
I have two lists:
T = [[1,0], [1,0], [0,5]]
S = [[1], [3], [2]]
I need to add the corresponding value from B to the end of the corresponding list in T, so using zip, I put them together.
I then calculate the r... | [
"I think you just need to change this:\ndef MonteCarlo(T, S, x):\n for i in range(0, x):\n starterTrans(T, S)\n\nto this:\ndef MonteCarlo(T, S, x):\n for i in range(0, x):\n starterTrans(T[:], S)\n\nThis will pass a copy of T to starterTrans(..) instead of the original list. If you're editing th... | [
1,
0
] | [] | [] | [
"for_loop",
"montecarlo",
"python",
"zip"
] | stackoverflow_0008016200_for_loop_montecarlo_python_zip.txt |
Q:
Python: Getting ints from a string
Ok so I made a method in python that does exactly what I want it to but its really ugly and repetitive, all it needs to do is get the first 4 integers in a string of input and return them in the form ((int1, int2), (int3, int4)). There has got to be a better way of doing this (ma... | Python: Getting ints from a string | Ok so I made a method in python that does exactly what I want it to but its really ugly and repetitive, all it needs to do is get the first 4 integers in a string of input and return them in the form ((int1, int2), (int3, int4)). There has got to be a better way of doing this (maybe even in one line) using list compreh... | [
"Here is what you want, using a regular expression and a simple list comprehension.\nThis is pretty robust to nasty input. It complies with your request for \"the first 4 integers in a string of input\" by finding the first 4 integers in the input separated by ANY non-numerical characters.\nimport re\n\ndef getMove... | [
2,
1,
0
] | [] | [] | [
"int",
"list_comprehension",
"python",
"string"
] | stackoverflow_0008016432_int_list_comprehension_python_string.txt |
Q:
'super' object has no attribute '_get_type_value'
I have created a customized module for Sales CRM in OpenERP. While creating opportunity when I click on stage field, it gives me the following error:
list = super(crm_stage_claim, self)._get_type_value(cr, user, context)
AttributeError: 'super' object has no attr... | 'super' object has no attribute '_get_type_value' | I have created a customized module for Sales CRM in OpenERP. While creating opportunity when I click on stage field, it gives me the following error:
list = super(crm_stage_claim, self)._get_type_value(cr, user, context)
AttributeError: 'super' object has no attribute '_get_type_value'
Any Help on this would be app... | [
"Make sure:\n\ncrm_stage_claim extends crm.case.stage\ncrm.case.stage inherits from object (is a new-style class, which\nsupports super)\nyou have not overridden super by assigning something else to it,\nmasking the Python builtin\ncrm.case.stage does in fact have a _get_type_value method\n\n",
"Maybe the base cl... | [
1,
0,
0
] | [] | [] | [
"openerp",
"python"
] | stackoverflow_0008005486_openerp_python.txt |
Q:
Choosing GCC version when building ( setup.py )
I am trying to build a python module (scikit.timeseries) using
python setup.py build
but it's erroring out like this :
/Versions/2.6/lib/python2.6/site-packages/numpy/core/include -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c'
gcc-4.0: sc... | Choosing GCC version when building ( setup.py ) | I am trying to build a python module (scikit.timeseries) using
python setup.py build
but it's erroring out like this :
/Versions/2.6/lib/python2.6/site-packages/numpy/core/include -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c'
gcc-4.0: scikits/timeseries/src/cseries.c
sh: gcc-4.0: command n... | [
"Try\nexport CC=/usr/bin/gcc\npython setup.py build\n\n"
] | [
14
] | [] | [] | [
"distutils",
"gcc",
"python"
] | stackoverflow_0008016520_distutils_gcc_python.txt |
Q:
routing 2 urls to 1 handler
I'm trying to implement some sort of API on tornado and I have such question:
is it possible to route two urls to one handler separating by method.
class Handler():
def get(self):
#only for the first url
def post(self):
#only for the secornd url
handlers = [
(r"/u... | routing 2 urls to 1 handler | I'm trying to implement some sort of API on tornado and I have such question:
is it possible to route two urls to one handler separating by method.
class Handler():
def get(self):
#only for the first url
def post(self):
#only for the secornd url
handlers = [
(r"/url1",Handler), #only GET are allo... | [
"You can use @ee_vin's answer to do this. However, in this situation, why not create two handlers? It's much simpler:\nclass OneHandler():\n def get(self):\n #only for the first url\n\nclass TwoHandler():\n def post(self):\n #only for the second url\n\nhandlers = [\n (r\"/url1\",OneHandler), #only... | [
6,
3
] | [] | [] | [
"python",
"tornado",
"url_routing"
] | stackoverflow_0007855235_python_tornado_url_routing.txt |
Q:
python unicode handling differences between print and sys.stdout.write
I'll start by saying that I've already seen this post: Strange python print behavior with unicode, but the solution offered there (using PYTHONIOENCODING) didn't work for me.
Here's my issue:
Python 2.6.5 (r265:79063, Apr 9 2010, 11:16:46)
[G... | python unicode handling differences between print and sys.stdout.write | I'll start by saying that I've already seen this post: Strange python print behavior with unicode, but the solution offered there (using PYTHONIOENCODING) didn't work for me.
Here's my issue:
Python 2.6.5 (r265:79063, Apr 9 2010, 11:16:46)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
>>> a = u'\xa6'
>>> print a ... | [
"This is due to a long-standing bug that was fixed in python-2.7, but too late to be back-ported to python-2.6.\nThe documentation states that when unicode strings are written to a file, they should be converted to byte strings using file.encoding. But this was not being honoured by sys.stdout, which instead was us... | [
12
] | [] | [] | [
"python",
"python_2.7",
"stdout",
"unicode"
] | stackoverflow_0008016236_python_python_2.7_stdout_unicode.txt |
Q:
python website development
I need to create a simple website, the server is gonna running on Amazon EC2 web service. But I haven't done web development before. It seems like I need to learn a lot of stuff, javascript, html, css, web framework, WSGI, apache web server, etc. And I am confused by some stuff that se... | python website development | I need to create a simple website, the server is gonna running on Amazon EC2 web service. But I haven't done web development before. It seems like I need to learn a lot of stuff, javascript, html, css, web framework, WSGI, apache web server, etc. And I am confused by some stuff that seems much the same.
So first ques... | [
"\nDepends on your website - if you only need static content, you can use static site generators (Blogofile, Hyde to name a few written in Python) or, if your website serves dynamic content, you should use some kind of framework (Flask, Django, etc). With static site generators all you need on the server is the web... | [
2,
1,
1,
0
] | [] | [] | [
"frameworks",
"python",
"web",
"wsgi"
] | stackoverflow_0008016845_frameworks_python_web_wsgi.txt |
Q:
extract rows and filenames from multiple csv files
I have multiple csv files with date as filename (20080101.csv to 20111031.csv) in a folder. The csv files have common headers. The csv file looks like this:
20080101.csv
X ;Y; Z
1 ; 1 ; 3
1 ; 2 ; 6
1 ; 3 ; 24
2 ; 1 ; 24
2 ; 2 ; 24
20080102.csv
... | extract rows and filenames from multiple csv files | I have multiple csv files with date as filename (20080101.csv to 20111031.csv) in a folder. The csv files have common headers. The csv file looks like this:
20080101.csv
X ;Y; Z
1 ; 1 ; 3
1 ; 2 ; 6
1 ; 3 ; 24
2 ; 1 ; 24
2 ; 2 ; 24
20080102.csv
X ;Y; Z
1 ; 1 ; 0.1
1 ; 2 ; 2
1 ; 3 ; 67
2 ; 1 ;... | [
"This is a well-formed question, from which the logic should be apparent. For someone to provide finished code would defeat the purpose of the assignment. First, add a \"homework\" tag to the question, then think about what you want to do:\n1) loop over the files (keeping track of each filename as it's opened)\n2... | [
4,
2,
2,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0008017003_python.txt |
Q:
django-timezones: how to use this app?
I'm trying to use django-timezones but can't find any document relating to it. I read some codes of it and got totally lost. For example, LocalizedDateTimeField of the model has a constructor like:
def __init__(self, verbose_name=None, name=None, timezone=None, **kwargs):
ti... | django-timezones: how to use this app? | I'm trying to use django-timezones but can't find any document relating to it. I read some codes of it and got totally lost. For example, LocalizedDateTimeField of the model has a constructor like:
def __init__(self, verbose_name=None, name=None, timezone=None, **kwargs):
timezone is an argument. But how can a model f... | [
"Three places to look ...\n\nwww.asynchronous.prg/blog\nblog.abourget.net and \npytz.sourceforge.net\n\n",
"For anyone else looking how to use this module, check the tests under timezones/timezones_tests/tests.py. They give a clear idea on how to use it.\n"
] | [
0,
0
] | [] | [] | [
"django",
"python",
"timezone"
] | stackoverflow_0006821702_django_python_timezone.txt |
Q:
How can I parallelize this word counting function?
I have some serial code like this that computes word concordances i.e. counting collocated word pairs. The following program works except that the list of sentences is canned for illustrative purposes.
import sys
from collections import defaultdict
GLOBAL_CONCORD... | How can I parallelize this word counting function? | I have some serial code like this that computes word concordances i.e. counting collocated word pairs. The following program works except that the list of sentences is canned for illustrative purposes.
import sys
from collections import defaultdict
GLOBAL_CONCORDANCE = defaultdict(lambda: defaultdict(lambda: defaultdi... | [
"In general, multiprocessing is easiest when you use a functional style. In this case, my suggestion would be to return a list of result tuples from each instance of the worker function. The extra complexity of the nested defaultdicts doesn't really gain you anything. Something like this:\nimport sys\nfrom collecti... | [
1,
1,
0
] | [] | [] | [
"multiprocessing",
"parallel_processing",
"python",
"windows"
] | stackoverflow_0008016561_multiprocessing_parallel_processing_python_windows.txt |
Q:
Populating a list with objects using list comprehension expression
I am trying to populate a list of 8 Ingredient objects using one list comprehension expression.
The code looks like that:
import random
ings = (('w1', 200, 25, 80),
('su1', 50, 55, 150),
('su2', 400, 100, 203),
('sy1', 10, 150, 355),
('... | Populating a list with objects using list comprehension expression | I am trying to populate a list of 8 Ingredient objects using one list comprehension expression.
The code looks like that:
import random
ings = (('w1', 200, 25, 80),
('su1', 50, 55, 150),
('su2', 400, 100, 203),
('sy1', 10, 150, 355),
('sy2', 123, 88, 101),
('sy3', 225, 5, 30),
('sy4', 1, 44, 99),
(... | [
"[Ingredient(*ing) for ing in ings]\n\n",
"You should just create Ingredient instances directly, instead of defining tuples and then converting them:\nimport random\n\nclass Ingredient: \n def __init__(self, name, price, min, max):\n self.name = name\n self.price = price\n self.min = min\n... | [
9,
1,
0
] | [] | [] | [
"list_comprehension",
"python"
] | stackoverflow_0008017246_list_comprehension_python.txt |
Q:
Why is os.path.expanduser misbehaving when the home directory has special characters?
Currently, my user directory is located in "C:\Users\João", and I'm running the Python 2.7's 64-bit build under Windows 7.
Normally, the Python interpreter runs with 'ascii' as the default encoding. However, for some reason, when... | Why is os.path.expanduser misbehaving when the home directory has special characters? | Currently, my user directory is located in "C:\Users\João", and I'm running the Python 2.7's 64-bit build under Windows 7.
Normally, the Python interpreter runs with 'ascii' as the default encoding. However, for some reason, when Eclipse runs it, the default encoding is 'utf-8'. Now, in the regular Python console, the ... | [
"Try changing Eclipse's default encoding. File Menu: Windows --> Preferences; Tree Bar: General -> Workspace; Change \"Text file encoding\" from Cp1252 to ISO-8859-1.\nYou can also change it for a specific debug configuration if you open up \"Debug Configurations\", go to the \"Common\" tab, change \"Encoding\".\nE... | [
0
] | [] | [] | [
"eclipse",
"internationalization",
"pydev",
"python",
"windows"
] | stackoverflow_0007601300_eclipse_internationalization_pydev_python_windows.txt |
Q:
No effect from ZoomIn in QTextEdit after font size change
This code runs a little window with a toolbar and a QTextEdit area.
If you highlight 'bananas' and change the font size, then using zoom from either the toolbar buttons or CTRL + mouse wheel will only resize 'apples'. Anyone know why?
from PySide import Qt... | No effect from ZoomIn in QTextEdit after font size change | This code runs a little window with a toolbar and a QTextEdit area.
If you highlight 'bananas' and change the font size, then using zoom from either the toolbar buttons or CTRL + mouse wheel will only resize 'apples'. Anyone know why?
from PySide import QtGui, QtCore
class MainWindow(QtGui.QMainWindow):
def __ini... | [
"The default implementation of QTextEdit.zoomIn/Out simply changes the pointSize of the base font for the text-edit.\nThe method used in the example to change font size wraps the selected word in a span tag and uses inline css to set the font-size property to a fixed value. This means that when the text-edit is sub... | [
4
] | [] | [] | [
"pyside",
"python",
"qt4"
] | stackoverflow_0008016530_pyside_python_qt4.txt |
Q:
Most efficient way to index words in a document?
This came up in another question but I figured it is best to ask this as a separate question. Give a large list of sentences (order of 100 thousands):
[
"This is sentence 1 as an example",
"This is sentence 1 as another example",
"This is sentence 2",
"This is sente... | Most efficient way to index words in a document? | This came up in another question but I figured it is best to ask this as a separate question. Give a large list of sentences (order of 100 thousands):
[
"This is sentence 1 as an example",
"This is sentence 1 as another example",
"This is sentence 2",
"This is sentence 3 as another example ",
"This is sentence 4"
]
wh... | [
"Use database for storing values.\n\nFirst add all the sentences to one table (they should have IDs). You may call it eg. sentences.\nSecond, create table with words contained within all the sentences (call it eg. words, give each word an ID), saving connection between sentences' table records and words' table reco... | [
14,
2
] | [] | [] | [
"nlp",
"python",
"text"
] | stackoverflow_0008017432_nlp_python_text.txt |
Q:
Install precompiled python extension with distutils
How can I specify an arbitrary set of files (non necessarily .py files) so that they are distributed and installed just like normal Python modules?
Some background
I am using distutils to distribute and install my Python library. One of the modules in this libra... | Install precompiled python extension with distutils | How can I specify an arbitrary set of files (non necessarily .py files) so that they are distributed and installed just like normal Python modules?
Some background
I am using distutils to distribute and install my Python library. One of the modules in this library imports a 3rd-party Python extension called bpy.so (th... | [
"I would suggest to use setuptools on top of distutils.\nThis is a good reference document to get started with it. The advantage of using setuptools is that it has a few nice features like the possibility to include all files under a given directory (package) automatically or according to filters. This is the secti... | [
0
] | [] | [] | [
"distutils",
"python"
] | stackoverflow_0008016298_distutils_python.txt |
Q:
Summing result of Monte Carlo Sim; python
Working in python 2.7.
I have an argument that takes a list, adds the values of the argument list to the list "team", and then compares certain positional values and returns win, loss, or tie depending upon the values.
def starterTrans3(starter):
wins = 0
losses = ... | Summing result of Monte Carlo Sim; python | Working in python 2.7.
I have an argument that takes a list, adds the values of the argument list to the list "team", and then compares certain positional values and returns win, loss, or tie depending upon the values.
def starterTrans3(starter):
wins = 0
losses = 0
nd = 0
team = [[1, 0], [1, 0], [0, 5]... | [
"i may not getting your point, but...\ndef MonteCarlo(starter, x):\n result = dict(w=0,l=0,n=0)\n for i in range(0, x):\n w,l,n = starterTrans3(starter)\n result['w']+=w\n result['l']+=l\n result['n']+=n\n return result\n\nor\n return result['w']/float(x),result['l']/float(x)... | [
2
] | [] | [] | [
"for_loop",
"montecarlo",
"python",
"sum"
] | stackoverflow_0008017681_for_loop_montecarlo_python_sum.txt |
Q:
specify static variables in a python class in C++
How would one go about specifying a static method or variable in a python class, in CPython C++?
In the PyTypeObject structure, tp_getset, tp_methods, tp_members all seem to assume an instance of the class.
Thanks very much,
Rob.
A:
Static and class methods can b... | specify static variables in a python class in C++ | How would one go about specifying a static method or variable in a python class, in CPython C++?
In the PyTypeObject structure, tp_getset, tp_methods, tp_members all seem to assume an instance of the class.
Thanks very much,
Rob.
| [
"Static and class methods can be defined in tp_methods by adding METH_STATIC or METH_CLASS to the ml_flags field of the PyMethodDef structure. This is equivalent to @staticmethod and @classmethod decorators.\nThe first parameter of the method, which normally is the instance pointer, will be NULL for static methods ... | [
2
] | [] | [] | [
"c++",
"class",
"cpython",
"python",
"static"
] | stackoverflow_0008016089_c++_class_cpython_python_static.txt |
Q:
Security vulnerbility in Python library?
Is there any known security vulnerabilities regarding Python or its libraries?
Thanks,
A:
Yes, there are a few.
| Security vulnerbility in Python library? | Is there any known security vulnerabilities regarding Python or its libraries?
Thanks,
| [
"Yes, there are a few.\n"
] | [
4
] | [] | [] | [
"python",
"security"
] | stackoverflow_0008017889_python_security.txt |
Q:
Python - cross-platform wrapper for GUI libraries?
I have seen through python - Pygtk VS Pyqt VS WxPython VS Tkinter; and my question is slightly different.
For instance, I use Ubuntu Gnome, there python-qt is not by default installed; and so if I want to use a python-qt application, I have to download python-qt ... | Python - cross-platform wrapper for GUI libraries? | I have seen through python - Pygtk VS Pyqt VS WxPython VS Tkinter; and my question is slightly different.
For instance, I use Ubuntu Gnome, there python-qt is not by default installed; and so if I want to use a python-qt application, I have to download python-qt (plus qt libraries); I'd expect it may be something simi... | [
"The library called wxWidgets was created to do exactly that; the “wx” stands for Windows and X. Their history page has more info. The Python bindings for it are wxPython, as you probably know.\nApparently by now it feels like another heavyweight GUI library, but it “just” wraps native GTK/Qt/Windows widgets.\n"
] | [
6
] | [] | [] | [
"cross_platform",
"python",
"user_interface"
] | stackoverflow_0008017814_cross_platform_python_user_interface.txt |
Q:
Transform a regular expression into another
I have to write regular expressions to match some tokenizable text, and it will be cumbersome to add all the \s* and \s+ where the amount of whitespace is insignificant or not required at all.
What I'd like to have is a function that accepts a regex and a list of delimit... | Transform a regular expression into another | I have to write regular expressions to match some tokenizable text, and it will be cumbersome to add all the \s* and \s+ where the amount of whitespace is insignificant or not required at all.
What I'd like to have is a function that accepts a regex and a list of delimiter tokens, and then add the whitespace matching f... | [
"I added an example to the regular expression docs to show how to write a flexible tokenizer using just regular expressions: http://docs.python.org/py3k/library/re.html#writing-a-tokenizer\nIt shows how to build-up the regex from pieces and how to ignore whitespace.\nAlternatively, you could consider doing two pas... | [
3,
1
] | [] | [] | [
"python",
"regex",
"tokenize",
"transformation",
"whitespace"
] | stackoverflow_0007824230_python_regex_tokenize_transformation_whitespace.txt |
Q:
Is there any interactive programming language where 1.0 is an integer?
I'm (very) new to all of this programming stuff and I need help with a program I'm making in Python 3. It's designed, at the moment, to find how many numbers between 1 and 10 are divisible by 5. This is my approach:
def five():
a = 0
b ... | Is there any interactive programming language where 1.0 is an integer? | I'm (very) new to all of this programming stuff and I need help with a program I'm making in Python 3. It's designed, at the moment, to find how many numbers between 1 and 10 are divisible by 5. This is my approach:
def five():
a = 0
b = 0
c = 0
while a <= 9:
a = a + 1
b = a / 5
... | [
"Asking for the type() of a value in Python is not going to tell you whether it is a round integer or not. The resulting type of a calculation doesn't change type depending on the answer. (But in Python 2, the type of the answer in division depends on the type of the inputs. In Python 3, the type after / is always ... | [
6,
2,
1,
1,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0008017750_python.txt |
Q:
Fetching 'https' pages using 'urlopen' vs getpage()
I'm trying to get an 'https' webpage(for eg: https://github.com/twitter/bootstrap) using urlopen(), it returns the page without any problem. But we are evaluating Twisted for a new project and trying to use getPage() to fetch the same page. But seems it requires ... | Fetching 'https' pages using 'urlopen' vs getpage() | I'm trying to get an 'https' webpage(for eg: https://github.com/twitter/bootstrap) using urlopen(), it returns the page without any problem. But we are evaluating Twisted for a new project and trying to use getPage() to fetch the same page. But seems it requires openSSL module.. "exceptions.ImportError: No module named... | [
"Why not just install pyOpenSSL?\n"
] | [
2
] | [] | [] | [
"python",
"twisted",
"urlopen"
] | stackoverflow_0008018063_python_twisted_urlopen.txt |
Q:
django google app engine error
I am absolutely new to django development, and trying my hands on google app engine because of some requirement in the company. i am getting this error while trying to do manage.py syncdb.
Error: No module named appengine_django
Here are my files:
settings.py
# Django settings fo... | django google app engine error | I am absolutely new to django development, and trying my hands on google app engine because of some requirement in the company. i am getting this error while trying to do manage.py syncdb.
Error: No module named appengine_django
Here are my files:
settings.py
# Django settings for blogproject project.
DEBUG = True... | [
"You should use Django-nonrel when using Django in AppEngine. Google introduction.\nIt seems you are trying to use django application called appengine_django that can not be resolved. Do you have it installed? How did you install it?\n",
"This link might help you for a recent complete django implementation:\nhttp... | [
3,
0
] | [] | [] | [
"django",
"google_app_engine",
"python"
] | stackoverflow_0008007864_django_google_app_engine_python.txt |
Q:
restrict movable area of qgraphicsitem
Is there a way to restrict the area where a QGraphicsItem like QRect can be moved when setFlag(ItemIsMovable) is set?
I'm new to pyqt and trying to find a way to move an item with the mouse, and the restrict it to only vertically/horizontally.
A:
If you want to keep a limit... | restrict movable area of qgraphicsitem | Is there a way to restrict the area where a QGraphicsItem like QRect can be moved when setFlag(ItemIsMovable) is set?
I'm new to pyqt and trying to find a way to move an item with the mouse, and the restrict it to only vertically/horizontally.
| [
"If you want to keep a limited area you can reimplement the ItemChanged() \nDeclare:\n#ifndef GRAPHIC_H\n#define GRAPHIC_H\n#include <QGraphicsRectItem>\nclass Graphic : public QGraphicsRectItem\n{\npublic:\n Graphic(const QRectF & rect, QGraphicsItem * parent = 0);\nprotected:\n virtual QVariant itemChang... | [
6,
4,
1
] | [] | [] | [
"pyqt",
"pyqt4",
"python",
"qgraphicsitem",
"qgraphicsview"
] | stackoverflow_0003548254_pyqt_pyqt4_python_qgraphicsitem_qgraphicsview.txt |
Q:
sort a list of dictionary of dictionary in python
I just want to sort by first_name this list in python
list = [ { "profile" : { "first_name" : "a", "last_name" : "b" } } ,
{ "profile" : { "first_name" : "c", "last_name" : "d" } } ,
{ "profile" : { "first_name" : "e", "last_name" : "f" } } ]
... | sort a list of dictionary of dictionary in python | I just want to sort by first_name this list in python
list = [ { "profile" : { "first_name" : "a", "last_name" : "b" } } ,
{ "profile" : { "first_name" : "c", "last_name" : "d" } } ,
{ "profile" : { "first_name" : "e", "last_name" : "f" } } ]
| [
"This should do it:\n>>> sorted(lst, key=lambda x: x['profile']['first_name'])\n\n",
"To sort the list itself, use:\nlst.sort(key=lambda x: x['profile']['first_name'])\n\nTo keep lst unsorted and return a sorted list use:\nsorted(lst, key=lambda x: x['profile']['first_name'])\n\n"
] | [
9,
7
] | [] | [] | [
"dictionary",
"list",
"python",
"sorting"
] | stackoverflow_0008017345_dictionary_list_python_sorting.txt |
Q:
pymongo hangs when creating Connection
When I run the following lines from Python shell, the code hangs:
from pymongo import Connection
c = Connection('localhost', 27017)
I guess it's waiting to hear back from the mongo server. When I interrupt the call, I get the traceback:
^CTraceback (most recent call last):
... | pymongo hangs when creating Connection | When I run the following lines from Python shell, the code hangs:
from pymongo import Connection
c = Connection('localhost', 27017)
I guess it's waiting to hear back from the mongo server. When I interrupt the call, I get the traceback:
^CTraceback (most recent call last):
File "<stdin>", line 1, in <module>
File ... | [
"Sorry dumb mistake. I had the mongod job stopped in the background.\n"
] | [
1
] | [] | [] | [
"mongodb",
"pymongo",
"python"
] | stackoverflow_0008018398_mongodb_pymongo_python.txt |
Q:
How can I fetch the page source of a webpage using Python?
I wish to fetch the source of a webpage and parse individual tags myself. How can I do this in Python?
A:
import urllib2
urllib2.urlopen('http://stackoverflow.com').read()
That's the simple answer, but you should really look at BeautifulSoup
http://www.... | How can I fetch the page source of a webpage using Python? | I wish to fetch the source of a webpage and parse individual tags myself. How can I do this in Python?
| [
"import urllib2\nurllib2.urlopen('http://stackoverflow.com').read()\n\nThat's the simple answer, but you should really look at BeautifulSoup\nhttp://www.crummy.com/software/BeautifulSoup/\n",
"Some options are:\n\nurllib\nurllib2\nhttplib\nhttplib2\nHTMLParser\nBeautiful Soup\n\nAll except httplib2 and Beautiful ... | [
3,
2,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0008018593_python.txt |
Q:
Python conversion madness
I have a code understanding problem related to python:
def convex_hull(pts):
"""Returns the points on the convex hull of pts in CCW order."""
for m in (2 ** (2 ** t) for t in xrange(len(pts))):
hulls = [_graham_scan(pts[i:i + m]) for i in xrange(0, len(pts), m)]
//more cod... | Python conversion madness | I have a code understanding problem related to python:
def convex_hull(pts):
"""Returns the points on the convex hull of pts in CCW order."""
for m in (2 ** (2 ** t) for t in xrange(len(pts))):
hulls = [_graham_scan(pts[i:i + m]) for i in xrange(0, len(pts), m)]
//more code
I can't figure out how are t... | [
"To understand this code, you first need to understand list comprehensions and generator expressions. Here is a an example of a simple list comprehension:\n>>> [str(i) for i in range(5)]\n['0', '1', '2', '3', '4']\n\nAs you can see, this one line does the equivalent of the following regular for loop:\nlst = []\nfo... | [
11
] | [] | [] | [
"for_loop",
"list_comprehension",
"python",
"syntax"
] | stackoverflow_0008018645_for_loop_list_comprehension_python_syntax.txt |
Q:
Is there a way to get the tab label into an array? - wxPython
I know i can use GetSelection() to get the selected tab, however it will return the tab number, i would like to get the tab label.
I am using
print self.GetSelection()
A:
I suposse you are asking about a wx.Notebook as you talk about tabs.
Then use th... | Is there a way to get the tab label into an array? - wxPython | I know i can use GetSelection() to get the selected tab, however it will return the tab number, i would like to get the tab label.
I am using
print self.GetSelection()
| [
"I suposse you are asking about a wx.Notebook as you talk about tabs.\nThen use the method GetPageText()\n"
] | [
0
] | [] | [] | [
"python",
"wxpython"
] | stackoverflow_0008017503_python_wxpython.txt |
Q:
How to solve IOError: [Errno 2] No such file or directory: in Biopython?
I am trying to parse a fasta file in Biopython using the following code.How can I solve this error?
from Bio import SeqIO
handle = open("C:/Users/Desktop/kk.fasta", "rU")
File "<pyshell#19>", line 1, in <module>
IOError: [Errno 2] No such f... | How to solve IOError: [Errno 2] No such file or directory: in Biopython? | I am trying to parse a fasta file in Biopython using the following code.How can I solve this error?
from Bio import SeqIO
handle = open("C:/Users/Desktop/kk.fasta", "rU")
File "<pyshell#19>", line 1, in <module>
IOError: [Errno 2] No such file or directory: 'kk.fasta'
I am getting the above error. But my file is a... | [
"try:\nimport os\nprint os.path.isfile(r\"C:\\Users\\Desktop\\kk.fasta\")\n\nif the output is true, you can try to replace the string in the original code and see if it works. If not, make sure there is no typo in the path.\nthe small r means raw. It will escape all \\ to \\\\ to make sure the path is valid (\\n wo... | [
2,
0
] | [] | [] | [
"biopython",
"python"
] | stackoverflow_0008018558_biopython_python.txt |
Q:
Parsing JSON format
I need help. I want to print all pageid,title from json format using for loop. Can anyone help? thanks
{"query":
{"categorymembers":[{"pageid":13012551,"ns":0,"title":"List of Indian Punjabi films"}
,{"pageid":13662758,"ns":0,"title":"List of Punjabi language films"},
{"pageid":4628722,"ns":... | Parsing JSON format | I need help. I want to print all pageid,title from json format using for loop. Can anyone help? thanks
{"query":
{"categorymembers":[{"pageid":13012551,"ns":0,"title":"List of Indian Punjabi films"}
,{"pageid":13662758,"ns":0,"title":"List of Punjabi language films"},
{"pageid":4628722,"ns":0,"title":"Ae Fond Kiss..... | [
"Try this - In python 2.6.1 there is a module called json this parses json string in python objects\nimport json\nfrom pprint import pprint\n\ndata = json.load(json_data)\npprint(data)\n\nfor category in data['query']['categorymembers']:\n print 'PageID: %d and Title: %s' % (category['pageid'], category['title']... | [
4
] | [] | [] | [
"json",
"python"
] | stackoverflow_0008018870_json_python.txt |
Q:
Python to c# reduce function understanding
I am struggling to understand the 'reduce' call written below in python.
I have found several sources, both here and elsewhere, that state what the function does, and that there's an equivalent 'aggregate' for lists in C#, but I am unable to understand what do the calls b... | Python to c# reduce function understanding | I am struggling to understand the 'reduce' call written below in python.
I have found several sources, both here and elsewhere, that state what the function does, and that there's an equivalent 'aggregate' for lists in C#, but I am unable to understand what do the calls below actually -expect-... possibly because I can... | [
"\n_keep_left returns a list hull, which is initially empty. Turns not going left are removed from it. The current point is added into it, unless it is already the last element on the list.\n, []) is the third parameter to reduce. It is the initial accumulator value, which will be passed to _keep_left, thus making... | [
3
] | [] | [] | [
"c#",
"python",
"reduce"
] | stackoverflow_0008019079_c#_python_reduce.txt |
Q:
Primality test in python
I'm trying to do a simple primality test in Python.
Accoding to Wikipedia, a primality test is the following:
Given an input number n, check whether any integer m from 2 to n − 1 divides n. If n is divisible by any m then n is composite, otherwise it is prime.
I started with ruling out t... | Primality test in python | I'm trying to do a simple primality test in Python.
Accoding to Wikipedia, a primality test is the following:
Given an input number n, check whether any integer m from 2 to n − 1 divides n. If n is divisible by any m then n is composite, otherwise it is prime.
I started with ruling out the even numbers - with the exc... | [
"Have a look at the Miller–Rabin primality test if a probabilistic algorithm will suffice. You could also prove a number to be prime, with for instance Elliptic Curve Primality Proving (ECPP), but it takes more effort.\nA simple trial division algorithm is the following\ndef prime(a):\n return not (a < 2 or any... | [
14,
11,
2,
2
] | [] | [] | [
"primes",
"python"
] | stackoverflow_0008019343_primes_python.txt |
Q:
Replace given line in files in Python
I have several files, and I need to replace third line in them:
files = ['file1.txt', 'file2.txt']
new_3rd_line = 'new third line'
What is the best way to do this?
Files are big enough, several 100mb's files.
A:
I used this solution: Search and replace a line in a file in P... | Replace given line in files in Python | I have several files, and I need to replace third line in them:
files = ['file1.txt', 'file2.txt']
new_3rd_line = 'new third line'
What is the best way to do this?
Files are big enough, several 100mb's files.
| [
"I used this solution: Search and replace a line in a file in Python\nfrom tempfile import mkstemp\nfrom shutil import move\nfrom os import remove, close\n\ndef replace_3_line(file):\n new_3rd_line = 'new_3_line\\n'\n #Create temp file\n fh, abs_path = mkstemp()\n new_file = open(abs_path,'w')\n old_... | [
1
] | [] | [] | [
"python"
] | stackoverflow_0008019287_python.txt |
Q:
looking for the appropriate python data structure
I'm looking for a python 2.7 data structure equivalent to a dictionary but where I can associate more than 1 key.
For example I want to associate:
cars:
-Chevrolet
-Toyota
-hummer
-Ferrari
computer:
-mac
-windows
-linux
-amstrad
I need to be able to search in the... | looking for the appropriate python data structure | I'm looking for a python 2.7 data structure equivalent to a dictionary but where I can associate more than 1 key.
For example I want to associate:
cars:
-Chevrolet
-Toyota
-hummer
-Ferrari
computer:
-mac
-windows
-linux
-amstrad
I need to be able to search in the dictionary for the string 'cars' or 'computers' or oth... | [
"Are you looking for a dictionary mapping strings to lists?\n>>> d = {\"cars\": [\"Chevrolet\", \"Toyota\", \"Hummer\", \"Ferrari\"],\n \"computers\": [\"mac\", \"windows\", \"linux\", \"amstrad\"]}\n>>> d[\"cars\"]\n['Chevrolet', 'Toyota', 'Hummer', 'Ferrari']\n\n"
] | [
3
] | [] | [] | [
"python"
] | stackoverflow_0008019425_python.txt |
Q:
Selenium Ajax wait_for_condition
I am using Selenium with the Python scripting and I am trying to use the wait_for_condition function.
I want to wait for the element defined by this xpath :
"/html/body/form/div[3]/div/div/div[2]/div/div/div/table/tbody/tr[8]/td[2]"
to be present so I am trying the following :
sel... | Selenium Ajax wait_for_condition | I am using Selenium with the Python scripting and I am trying to use the wait_for_condition function.
I want to wait for the element defined by this xpath :
"/html/body/form/div[3]/div/div/div[2]/div/div/div/table/tbody/tr[8]/td[2]"
to be present so I am trying the following :
sel.wait_for_condition(
"var x = sele... | [
"The timeout, 5000, should be given as an integer, not a string:\nsel.wait_for_condition(\n \"var x = selenium.browserbot.findElementOrNull('/html/body/form/div[3]/div/div/div[2]/div/div/div/table/tbody/tr[8]/td[2]'); x != null && x.style.display == 'none';\",\n 5000)\n\nAlso from the docs:\n\n Note that, ... | [
0
] | [] | [] | [
"ajax",
"element",
"python",
"selenium",
"wait"
] | stackoverflow_0008019515_ajax_element_python_selenium_wait.txt |
Q:
Computing complex math equations in python
Are there any libraries or techniques that simplify computing equations ?
Take the following two examples:
F = B * { [ a * b * sumOf (A / B ''' for all i ''' ) ] / [ sumOf(c * d * j) ] }
where:
F = cost from i to j
B, a, b, c, d, j are all vectors in the format [ [zone_... | Computing complex math equations in python | Are there any libraries or techniques that simplify computing equations ?
Take the following two examples:
F = B * { [ a * b * sumOf (A / B ''' for all i ''' ) ] / [ sumOf(c * d * j) ] }
where:
F = cost from i to j
B, a, b, c, d, j are all vectors in the format [ [zone_i, zone_j, cost_of_i_to_j], [..]]
This should pr... | [
"To do an elementwise multiply of two NumPy arrays with the same dimension is simply 'A * B'.\nIn [1]: a = arange(50)\n\nIn [2]: b = ones(50) * 2\n\nIn [3]: a\nOut[3]: \narray([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,... | [
4,
3,
3
] | [] | [] | [
"equation",
"math",
"numpy",
"python"
] | stackoverflow_0002912485_equation_math_numpy_python.txt |
Q:
Python C API - Stopping Execution (and continuing it later)
1) I would like to use the profiling functions in the Python C API to catch the python interpreter when it returns from specific functions.
2) I would like to pause the python interpreter, send execution back to the function that called the interpreter in... | Python C API - Stopping Execution (and continuing it later) | 1) I would like to use the profiling functions in the Python C API to catch the python interpreter when it returns from specific functions.
2) I would like to pause the python interpreter, send execution back to the function that called the interpreter in my C++ program, and finally return execution to the python inter... | [
"If I understand your problem, you have a C++ program that calls into python. When python finishes executing a function, you want to pause the interpreter and pick up where the C++ code left off. Some time later your C++ program needs to cal back into python, and have the python interpreter pick up where it left of... | [
2
] | [] | [] | [
"api",
"c++",
"execution",
"profile",
"python"
] | stackoverflow_0007809321_api_c++_execution_profile_python.txt |
Q:
python key=lambda understanding and c# equivalent
I have documented myself regarding the 'key=lambda' functionality, and have found a good reference on its use:
http://www.daniweb.com/software-development/python/threads/376964
thanks to which I came to understand what the following code is 'supposed' to do:
def _m... | python key=lambda understanding and c# equivalent | I have documented myself regarding the 'key=lambda' functionality, and have found a good reference on its use:
http://www.daniweb.com/software-development/python/threads/376964
thanks to which I came to understand what the following code is 'supposed' to do:
def _min_hull_pt_pair(hulls):
"""Returns the hull, point ... | [
"\nYes. In particular, hulls[i][j] could be any type or any value depending on what happened at runtime. e.g. all of hulls could be integers, but you can set hulls[i][j]='foo'.\nYes, the lambda there returns the jth element of the ith row in hulls. hulls[i][j] could be any comparable thing e.g. min('a','b') is '... | [
1
] | [] | [] | [
"key",
"lambda",
"min",
"python"
] | stackoverflow_0008019784_key_lambda_min_python.txt |
Q:
PyQt and Image in string
Why this code show me a window without image? I try to use QByteArray instead of StringIO, but i have same result. Anyone know answer?
import sys
from PyQt4 import QtGui, QtCore
from StringIO import StringIO
class Example(QtGui.QWidget):
def __init__(self):
super(Example, self)... | PyQt and Image in string | Why this code show me a window without image? I try to use QByteArray instead of StringIO, but i have same result. Anyone know answer?
import sys
from PyQt4 import QtGui, QtCore
from StringIO import StringIO
class Example(QtGui.QWidget):
def __init__(self):
super(Example, self).__init__()
self.initU... | [
"You didn't add the label to the mainwindow. The easiest solution is:\nlbl=QtGui.QLabel(self)\n\nAnd the proper solution is using some layout, so the window will have the appropriate size. Add this after lbl.setPixmap(p):\nlayout = QtGui.QHBoxLayout(self)\nlayout.addWidget(lbl)\n\n"
] | [
4
] | [] | [] | [
"pyqt4",
"python"
] | stackoverflow_0008019737_pyqt4_python.txt |
Q:
Coalition Search Algorithm
I am looking for an algorithm that is implemented in C, C++, Python or Java that calculates the set of winning coalitions for n agents where each agent has a different amount of votes. I would appreciate any hints. Thanks!
A:
In other words, you have an array X[1..n], and want to have ... | Coalition Search Algorithm | I am looking for an algorithm that is implemented in C, C++, Python or Java that calculates the set of winning coalitions for n agents where each agent has a different amount of votes. I would appreciate any hints. Thanks!
| [
"In other words, you have an array X[1..n], and want to have all the subsets of it for which sum(subset) >= 1/2 * sum(X), right?\nThat probably means the whole set qualifies. \nAfter that, you can drop any element k having X[k] < 1/2 * sum(X), and every such a coalition will be fine as an answer, too.\nAfter that, ... | [
3,
1,
0
] | [] | [] | [
"algorithm",
"c",
"c++",
"java",
"python"
] | stackoverflow_0008019172_algorithm_c_c++_java_python.txt |
Q:
automatic detection/conversion of data types?
Is there a function in numpy that determines whether strings should be integers or floating point numbers and automatically converts them? For instance, I often have a collection of records which are parsed from a text file using a combination of str.strip() and str.sp... | automatic detection/conversion of data types? | Is there a function in numpy that determines whether strings should be integers or floating point numbers and automatically converts them? For instance, I often have a collection of records which are parsed from a text file using a combination of str.strip() and str.split(). Then I get something like
List = [['1','a','... | [
"numpy.genfromtxt can guess dtypes if you set dtype=None:\nimport numpy as np\nimport io\n\nalist = [['1','a','.3'],\n ['2','b','-.5']]\n\nf = io.BytesIO('\\n'.join(' '.join(row) for row in alist))\narr = np.genfromtxt(f,dtype=None)\nprint(arr)\nprint(arr.dtype)\n# [(1, 'a', 0.3) (2, 'b', -0.5)]\n# [('f0', '... | [
5
] | [] | [] | [
"numpy",
"python",
"scipy"
] | stackoverflow_0008020081_numpy_python_scipy.txt |
Q:
pythonic way to sort a list of lists by the last item of the inner list
I have a list like this
[[x,y,1],[w,u,4],[m,n,3] ... [p,q,5]]
I need to sort the outer list by the third (last) element of the inner list, the desired result would be:
[[x,y,1],[m,n,3],[w,u,4] ... [p,q,5]]
What's the best way to achieve this... | pythonic way to sort a list of lists by the last item of the inner list | I have a list like this
[[x,y,1],[w,u,4],[m,n,3] ... [p,q,5]]
I need to sort the outer list by the third (last) element of the inner list, the desired result would be:
[[x,y,1],[m,n,3],[w,u,4] ... [p,q,5]]
What's the best way to achieve this?
| [
"my_list.sort(key=lambda x: x[-1])\n\nor\nmy_list.sort(key=operator.itemgetter(-1))\n\nThe second option is slightly faster.\n"
] | [
5
] | [] | [] | [
"algorithm",
"python",
"sorting"
] | stackoverflow_0008020408_algorithm_python_sorting.txt |
Q:
Selenium number of lines in a table?
I have this structure :
<table>
<tbody>
<tr id="1_2011_11_11_07_45_00" class="on">
</tr>
<tr id="1_2011_11_11_09_25_00">
</tr>
<tr id="1_2011_11_11_11_05_00">
</tr>
<tr id="1_2011_11_11_14_50_00">
</tr>
<tr id="1_2011_11_11_16_00_00">
</... | Selenium number of lines in a table? | I have this structure :
<table>
<tbody>
<tr id="1_2011_11_11_07_45_00" class="on">
</tr>
<tr id="1_2011_11_11_09_25_00">
</tr>
<tr id="1_2011_11_11_11_05_00">
</tr>
<tr id="1_2011_11_11_14_50_00">
</tr>
<tr id="1_2011_11_11_16_00_00">
</tr>
<tr id="1_2011_11_11_18_10_00">
... | [
"Can also be done via get_xpath_count.\nfor ex. Number_of_row = $browser.get_xpath_count(\"/tbody/tr\")\nI have not checked the above code but I think it will work\n",
"s = \"\"\"<table>\n<tbody>\n <tr id=\"1_2011_11_11_07_45_00\" class=\"on\">\n </tr>\n <tr id=\"1_2011_11_11_09_25_00\">\n </tr>\n ... | [
3,
0,
0
] | [] | [] | [
"count",
"html_table",
"lines",
"python",
"selenium"
] | stackoverflow_0008018418_count_html_table_lines_python_selenium.txt |
Q:
How to put tcp server on another thread in python
I try to write a daemon in python. But I have no idea how can I use a thread to start parallel tcp server in this daemon. And even what type of server I should use : asyncore?SocketServer?socket?
this is part of my code:
import os
def demonized():
child_pid = os... | How to put tcp server on another thread in python | I try to write a daemon in python. But I have no idea how can I use a thread to start parallel tcp server in this daemon. And even what type of server I should use : asyncore?SocketServer?socket?
this is part of my code:
import os
def demonized():
child_pid = os.fork()
if child_pid == 0:
child_pid = os.for... | [
"In case you want to avoid repeating boilerplate, Python will soon have a standard module that does the fork() pair and standard-I/O manipulations (which you have not added to your program yet?) that make it a daemon. You can download and use this module right now, from:\nhttp://pypi.python.org/pypi/python-daemon\n... | [
6
] | [
"Do you want to append items to the list in while event:... loop and serving this list simultaneously? If so then you have two writers and you must somehow protect your list.\nIn the sample SocketServer.TCPServer and threading.Lock was used:\nimport threading\nimport SocketServer\nimport time\n\n\nclass DataHandle... | [
-1
] | [
"multithreading",
"python",
"tcpserver"
] | stackoverflow_0008020287_multithreading_python_tcpserver.txt |
Q:
Changing a function implementation in Python
I am writing a module that provides one function and needs an initialization step, however due to certain restrictions I need to initialize on first call, so I am looking for the proper idiom in python that would allow me to get rid of the conditional.
#with conditional... | Changing a function implementation in Python | I am writing a module that provides one function and needs an initialization step, however due to certain restrictions I need to initialize on first call, so I am looking for the proper idiom in python that would allow me to get rid of the conditional.
#with conditional
module.py
initialized = False
def function(*args)... | [
"The nothing-fancy way (of the methods I post here, this is probably the best way to do it):\nmodule.py:\ndef initialize():\n print('initialize')\ndef do_the_thing(args):\n print('doing things',args)\ndef function(args):\n _function(args)\ndef firsttime(args):\n global _function\n initialize()\n d... | [
8,
3,
2
] | [] | [] | [
"function",
"metaprogramming",
"python"
] | stackoverflow_0008020159_function_metaprogramming_python.txt |
Q:
Running a Windows service on machine startup
I have a Windows service written with Python. I want to start it automatically when the machine starts.
How can I do that?
class AppServerSvc (win32serviceutil.ServiceFramework):
_svc_name_ = "Service"
_svc_display_name_ = "Myservice"
def __init__(self,args):
win32... | Running a Windows service on machine startup | I have a Windows service written with Python. I want to start it automatically when the machine starts.
How can I do that?
class AppServerSvc (win32serviceutil.ServiceFramework):
_svc_name_ = "Service"
_svc_display_name_ = "Myservice"
def __init__(self,args):
win32serviceutil.ServiceFramework.__init__(self,args)
... | [
"Try the task scheduler:\nhttp://support.microsoft.com/kb/308569\n"
] | [
0
] | [] | [] | [
"python",
"windows",
"windows_services"
] | stackoverflow_0008020418_python_windows_windows_services.txt |
Q:
Tkinter in Python - Is it supposed to be slow or is the bottleneck somewhere else in the program?
In school, we have to create a game using Python and Tkinter as a group project and since the program is getting rather large, I want to know if my problem is caused by Tkinter itself before trying to search for probl... | Tkinter in Python - Is it supposed to be slow or is the bottleneck somewhere else in the program? | In school, we have to create a game using Python and Tkinter as a group project and since the program is getting rather large, I want to know if my problem is caused by Tkinter itself before trying to search for problems in the program.
The problem is, when we start creating units, when there are multiple units to disp... | [
"Nobody will be able to answer to this specific question, because it depends on a lot of factors. When you have a performance issue, you should measure the time you spend in each function to spot where are the bottlenecks. It is called profiling, and you have a nice tutorial here for the python built in profiler: h... | [
8,
3
] | [] | [] | [
"python",
"python_3.x",
"tkinter"
] | stackoverflow_0008017725_python_python_3.x_tkinter.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.