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: What does the Python logo mean? I know this question is not fully programmatic, but I know many are wondering the same thing, so I will go ahead and say it: what does the Python logo mean? Someone get it? A: You mean this one? I think it's just supposed to look like two snakes (pythons). A: Don't you see it? T...
What does the Python logo mean?
I know this question is not fully programmatic, but I know many are wondering the same thing, so I will go ahead and say it: what does the Python logo mean? Someone get it?
[ "You mean this one? I think it's just supposed to look like two snakes (pythons).\n\n", "Don't you see it? They're two snakes (two pythons maybe?)..\nBy the way, I don't think they've any particular meaning, instead I'm wondering how many people think about this thing :P\n", "it is a snake symbol, look closely ...
[ 24, 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008186768_python.txt
Q: python,scipy- homework -- how to keep history of the particle position in the grid i have the following problem: Create a program where a particle will execute a random walk for N=1000 steps for these two cases: i) in a 1D system ii) in a 2D system. The program must calculate the mean(S) where S is the number o...
python,scipy- homework -- how to keep history of the particle position in the grid
i have the following problem: Create a program where a particle will execute a random walk for N=1000 steps for these two cases: i) in a 1D system ii) in a 2D system. The program must calculate the mean(S) where S is the number of grid positions where the particle visited at least one time.You will make 10000 runs a...
[ "I am not sure of understanding what the problem is asking for (where time t is considered in your equations?, what do point refer to?), but relative to the operations you are trying to carry out, I understand you have to include each or your 10-means mean_his arrays resulting from each iteration in a final 10000x1...
[ 0, 0 ]
[]
[]
[ "python", "scipy" ]
stackoverflow_0008124032_python_scipy.txt
Q: How to get the python.exe location programmatically? Basically I want to get a handle of the python interpreter so I can pass a script file to execute (from an external application). A: This works in Linux & Windows: Python 3.x >>> import sys >>> print(sys.executable) C:\path\to\python.exe Python 2.x >>> import...
How to get the python.exe location programmatically?
Basically I want to get a handle of the python interpreter so I can pass a script file to execute (from an external application).
[ "This works in Linux & Windows:\nPython 3.x\n>>> import sys\n>>> print(sys.executable)\nC:\\path\\to\\python.exe\n\nPython 2.x\n>>> import sys\n>>> print sys.executable\n/usr/bin/python\n\n", "sys.executable is not reliable if working in an embedded python environment. My suggestions is to deduce it from \nimport...
[ 373, 63, 5 ]
[]
[]
[ "python" ]
stackoverflow_0000749711_python.txt
Q: How to use values inside range() I have a loop for i in range(0,1000,100): and inside it I compute a list which holds 10 values but the loop goes from 0 to 1000.I want to relate these 10 values with the 1000 values; namely, create a list (or array) which will hold these values (the 10 to 1000 values). UPDATED--...
How to use values inside range()
I have a loop for i in range(0,1000,100): and inside it I compute a list which holds 10 values but the loop goes from 0 to 1000.I want to relate these 10 values with the 1000 values; namely, create a list (or array) which will hold these values (the 10 to 1000 values). UPDATED----------------------------------------...
[ "Your question is very unclear.\nFrom your comment it seems like you're asking about matplotlib? Do you want something like this?\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nx = np.arange(0, 1000, 100)\n# As a placeholder for your calculation...\ny = np.cos(x / 100.0) \n\nplt.plot(x, y, marker='o', mf...
[ 0, 0 ]
[]
[]
[ "python", "scipy" ]
stackoverflow_0008185729_python_scipy.txt
Q: Remove an item from the middle of a Queue? Is it possible to remove an item and have the queue for multithreading reorder itself in Python? I have users queued up in a Queue, but when it's time to process the user and if the user disconnects, that will raise an issue. Is there a way to do this? Thanks A: Queue o...
Remove an item from the middle of a Queue?
Is it possible to remove an item and have the queue for multithreading reorder itself in Python? I have users queued up in a Queue, but when it's time to process the user and if the user disconnects, that will raise an issue. Is there a way to do this? Thanks
[ "Queue objects do not provide random access. However, you can achieve the same goal by retaining references to the objects in the queue somewhere else and marking them stale. When the object is read from the queue, the consumer can check to see if the object is stale, and if it is, throw it away and read again.\n...
[ 9 ]
[]
[]
[ "multithreading", "python", "queue" ]
stackoverflow_0008187104_multithreading_python_queue.txt
Q: python imaging library cannot save PNG to JPG I installed PIL 1.1.7 from source on Mac OSX. I also installed required libraries from Macports. Using python 2.6. After installing PIL, I could successfully run the selftest.py (all tests pass) But when I try running the following code, I find that I am not able to co...
python imaging library cannot save PNG to JPG
I installed PIL 1.1.7 from source on Mac OSX. I also installed required libraries from Macports. Using python 2.6. After installing PIL, I could successfully run the selftest.py (all tests pass) But when I try running the following code, I find that I am not able to convert PNG to JPG. I am however able to convert PNG ...
[ "Use jpeg not jpg for the format identifier.\n", "Thanks to @jterrace for suggesting homebrew.\nSolution: \nInstall homebrew \nbrew install python \nbrew install pil\n\n", "It appears you have to take some additional steps to work with JPG with PIL on Mac OSX.\nI've found some links, but nothing you couldn't al...
[ 4, 2, 1, 1 ]
[]
[]
[ "image", "python", "python_imaging_library" ]
stackoverflow_0008172098_image_python_python_imaging_library.txt
Q: Scaling temporary records in database to count totals to stop over-subscribing I'm looking at a system where people RSVP to a free web conference, these web conferences can get really busy with a lot of interest and there are limited places, so there has to be some way to ensure it doesn't get over-subscribed... S...
Scaling temporary records in database to count totals to stop over-subscribing
I'm looking at a system where people RSVP to a free web conference, these web conferences can get really busy with a lot of interest and there are limited places, so there has to be some way to ensure it doesn't get over-subscribed... So, we need to have a countdown from the time they book their seat to the time that t...
[ "Seems to me that all 200k people could get a \"token\" to start with but only 200 can complete the token.\nSo two things come to mind; \n1) why not keep track of \"Seats Remaining\" on the event itself that way you're not doing a count and over bookings cannot occur because the lock needed to update the event woul...
[ 3, 3, 1, 1, 1, 1, 1, 0 ]
[]
[]
[ "mysql", "nosql", "php", "python", "scalability" ]
stackoverflow_0008069503_mysql_nosql_php_python_scalability.txt
Q: How to execute a series of Python scripts in batch? I frequently find that I need to run a series of python scripts sequentially. The order and number of these scripts may vary, but instead of executing each script individually and sequentially, is there a preferred way of batch automating a series of Python scrip...
How to execute a series of Python scripts in batch?
I frequently find that I need to run a series of python scripts sequentially. The order and number of these scripts may vary, but instead of executing each script individually and sequentially, is there a preferred way of batch automating a series of Python scripts? My programs require multiple and complex file path an...
[ "Refactor them into modules, then make a new script that imports the relevant functions from each module and runs those.\nThe easiest way to do this is to write a main function per module and run all the main function serially.\n", "I think larsmans' option is the best by far. But if there is a reasons you canno...
[ 6, 1 ]
[]
[]
[ "batch_file", "python" ]
stackoverflow_0008187461_batch_file_python.txt
Q: create new string by adding characters of smaller strings one after another You have strings "aaaaa" "bbbbb" "ccccc" "ddddd" Now you want to generate the string: "abcdabcdabcdabcdabcd" How would be the fastest way to do it? PS. This is a very simplified example. I really need to generate the new string from the ex...
create new string by adding characters of smaller strings one after another
You have strings "aaaaa" "bbbbb" "ccccc" "ddddd" Now you want to generate the string: "abcdabcdabcdabcdabcd" How would be the fastest way to do it? PS. This is a very simplified example. I really need to generate the new string from the existing smaller strings.
[ "If the strings are of equal length you can use zip:\nresult = ''.join(map(''.join, zip(*strings)))\n\n", "Use izip_longest from the itertools library, and the flatten recipe from the same library.\nfrom itertools import izip_longest, chain\ndef flatten(listOfLists):\n \"Flatten one level of nesting\"\n ret...
[ 3, 1, 0 ]
[]
[]
[ "merge", "python", "string" ]
stackoverflow_0008187493_merge_python_string.txt
Q: Installing TkTreectrl on OSX I installed TkTreeCtrl 2.4.1 (written in c), as well as TkTreectrl 1.0 ( written in python), which wraps the original c library. When I try to create any treectrl objects in Python, I get the error: _tkinter.TclError: can't find package treectrl I'm pretty new to Python, but I'd guess...
Installing TkTreectrl on OSX
I installed TkTreeCtrl 2.4.1 (written in c), as well as TkTreectrl 1.0 ( written in python), which wraps the original c library. When I try to create any treectrl objects in Python, I get the error: _tkinter.TclError: can't find package treectrl I'm pretty new to Python, but I'd guess that the Python wrapper code can'...
[ "For its Python ports, MacPorts currently builds and installs its own X11-based Tcl and Tk ports. It looks like you would need to be careful when building TkTreeCtrl to specify the correct locations to ./configure for the MacPorts provided Tcl, Tk, and X11 libraries and include files. See ./configure --help for t...
[ 1 ]
[]
[]
[ "dylib", "macos", "python", "tkinter" ]
stackoverflow_0008177008_dylib_macos_python_tkinter.txt
Q: interactive matplotlib through eclipse is it possible to have an interactive session through pydev for using matplotlib? The problem is that I cannot get shell access to drive the charts as the interpretor halts after the show() command. I would like to have an interactive session through pydev. Interactive sessio...
interactive matplotlib through eclipse
is it possible to have an interactive session through pydev for using matplotlib? The problem is that I cannot get shell access to drive the charts as the interpretor halts after the show() command. I would like to have an interactive session through pydev. Interactive sessions are well described by the matplotlib manu...
[ "I've not used pydev much, but IIRC you can change which interactive interpreter you use. If that's possible, install ipython and use it in pylab mode (ipython --pylab from the command line)\nTurns out you can't change the interpreter. You can run interpreter commands so maybe it's possible to run an ipython shell ...
[ 2, 2, 1, 0 ]
[]
[]
[ "eclipse", "matlab", "matplotlib", "pydev", "python" ]
stackoverflow_0003918889_eclipse_matlab_matplotlib_pydev_python.txt
Q: How do I find the attribute to two separate words in Python? I need to select, at random, two different words and then get the value which is linked to both of them. Let me explain, further: The first list would be "masculine, feminine, neuter, plural" and the second would be "nom, acc, gen, dat". I want the progr...
How do I find the attribute to two separate words in Python?
I need to select, at random, two different words and then get the value which is linked to both of them. Let me explain, further: The first list would be "masculine, feminine, neuter, plural" and the second would be "nom, acc, gen, dat". I want the program to select one from each at random, and then have the user provi...
[ "It sounds like you need some sort of table of correct answers. \nIf you make a table like this:\n[[\"der\",\"die\",\"das\",\"die\"],\n [\"den\",\"die\",\"das\",\"die\"],\n [\"dem\",\"der\",\"dem\",\"den\"],\n [\"des\",\"der\",\"des\",\"der\"]]\n\nYou can look the entries up by index like so:\nmfnp = \"masculine, f...
[ 1, 1, 0, 0 ]
[]
[]
[ "python", "random" ]
stackoverflow_0008187724_python_random.txt
Q: mathematical operations on the contents of a list I have got a list which is the output of my code and want to carry some more operations in this list. I have written the code to convert the ranges in the input list to a single value with 3 choices. newlist = [[('s', [(0.0, 0.3), (0.1, 0.8), (0.0, 1.0), (0.0, 0.0...
mathematical operations on the contents of a list
I have got a list which is the output of my code and want to carry some more operations in this list. I have written the code to convert the ranges in the input list to a single value with 3 choices. newlist = [[('s', [(0.0, 0.3), (0.1, 0.8), (0.0, 1.0), (0.0, 0.0), (0.0, 0.5)]), ('aa', [(0.0, 0.3), [0.1,...
[ "It's a simple unpacking change. Replace for i in newlist with for s, i in newlist[e]:\n>>> newlist = [[('s', [(0.0, 0.3), (0.1, 0.8), (0.0, 1.0), (0.0, 0.0), (0.0, 0.5)]),\n ('aa', [(0.0, 0.3), [0.1, 0.8], (0.0, 1.0), [0.0, 1.0], (0.0, 0.5)])],\n [('m', [(0.0, 0.0), (0.0, 0.0), (0.1, 0.5), (0...
[ 3, 2, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008187928_python.txt
Q: How do I autosize text in matplotlib python? I have a plot in matplotlib,and my problem is that because the x axe has strings as values when the plot window gets resized they overlap and they can't be read clearly. A similar thing happens with the legend it doesn't get resized if the windows is resized. Is there a...
How do I autosize text in matplotlib python?
I have a plot in matplotlib,and my problem is that because the x axe has strings as values when the plot window gets resized they overlap and they can't be read clearly. A similar thing happens with the legend it doesn't get resized if the windows is resized. Is there a setting for that ?
[ "Not exactly. (Have a look at the new matplotlib.pyplot.tight_layout() function for something vaguely similar, though...)\nHowever, the usual trick with long x-tick labels is just to rotate them.\nFor example, if we have something with overlapping xticklabels:\nimport matplotlib.pyplot as plt\n\nplt.plot(range(10)...
[ 11 ]
[]
[]
[ "matplotlib", "python" ]
stackoverflow_0008182124_matplotlib_python.txt
Q: Django ModelMultipleChoiceField object has no attribute to_field_name I'm trying to create a custom field for a ModelForm. I'm extending from ModelMultipleChoiceField and then overriding render and render_options, however, I keep getting this exception when just trying to import my form: AttributeError: 'ModelMul...
Django ModelMultipleChoiceField object has no attribute to_field_name
I'm trying to create a custom field for a ModelForm. I'm extending from ModelMultipleChoiceField and then overriding render and render_options, however, I keep getting this exception when just trying to import my form: AttributeError: 'ModelMultipleChoiceField' object has no attribute 'to_field_name' I'm not sure what...
[ "You seem to have got confused between fields and widgets. You inherit from ModelMultipleChoiceField, which (as the name implies) is a field, not a widget. But render and render_options are methods on widgets, not fields. And you've used your class in the widgets dictionary.\nI suspect you do mean to create a widge...
[ 22, 3 ]
[]
[]
[ "django", "model", "modelform", "python" ]
stackoverflow_0008188048_django_model_modelform_python.txt
Q: Counting points inside an ellipse I'm trying to count given data points inside each ring of ellipse: The problem is that I have a function to check that: so for each ellipse, to make sure whether a point is in it, three inputs have to be calculated: def get_focal_point(r1,r2,center_x): # f = square root of r1...
Counting points inside an ellipse
I'm trying to count given data points inside each ring of ellipse: The problem is that I have a function to check that: so for each ellipse, to make sure whether a point is in it, three inputs have to be calculated: def get_focal_point(r1,r2,center_x): # f = square root of r1-squared - r2-squared focal_dist = ...
[ "This may be something similar to what you are doing. I'm just looking to see if \nf(x,y) = x^2/r1^2 + y^2/r2^2 = 1.\nWhen f(x,y) is larger than 1, the point x,y is outside the ellipse. When it is smaller, then it is inside the ellipse. I loop through each ellipse to find the one when f(x,y) is smaller than 1.\nTh...
[ 8, 2, 1 ]
[]
[]
[ "ellipse", "matplotlib", "python" ]
stackoverflow_0008187996_ellipse_matplotlib_python.txt
Q: How do I do this array lookup/replace with numpy? I've got a 2D numpy array, A containing an index into another array, B. What is a good way to get C from A and B using numpy? A = array([[1, 1, 0, 2], [1, 0, 0, 2], [1, 1, 0, 2]]) B = array([0, 5, 3]) C = array([[5, 5, 0, 3], [5, ...
How do I do this array lookup/replace with numpy?
I've got a 2D numpy array, A containing an index into another array, B. What is a good way to get C from A and B using numpy? A = array([[1, 1, 0, 2], [1, 0, 0, 2], [1, 1, 0, 2]]) B = array([0, 5, 3]) C = array([[5, 5, 0, 3], [5, 0, 0, 3], [5, 5, 0, 3]])
[ "How about this C = B[A]. That's the beauty of numpy:\nIn [1]: import numpy as np\nIn [2]: A = np.array([[1, 1, 0, 2],\n ...: [1, 0, 0, 2],\n ...: [1, 1, 0, 2]])\n\nIn [3]: B = np.array([0, 5, 3])\n\nIn [4]: B[A]\nOut[4]: \narray([[5, 5, 0, 3],\n [5, 0, 0, 3],\n [5, 5, 0, 3]])\...
[ 12 ]
[]
[]
[ "numpy", "python" ]
stackoverflow_0008188726_numpy_python.txt
Q: How would I extract the value of this HTML element attribute with Beautiful Soup? I am developing a small tool to scrape a webpage. I am using Beautiful Soup. I would like to fetch the class id from the page. The HTML code looks something like this: <span class='class_id' id='New_line'></span> How would I obtain...
How would I extract the value of this HTML element attribute with Beautiful Soup?
I am developing a small tool to scrape a webpage. I am using Beautiful Soup. I would like to fetch the class id from the page. The HTML code looks something like this: <span class='class_id' id='New_line'></span> How would I obtain class_id?
[ "This answer refers to an older version of the question where beautifulsoup has not been mentioned\nYou can use LXML and iterate over all elements asking them for the value of their \"class\" attribute. LXML is a library for parsing XML documents.\nLike, for example:\nfrom lxml import etree\nroot = etree.parse(file...
[ 5, 3 ]
[]
[]
[ "beautifulsoup", "html", "python", "screen_scraping", "web_scraping" ]
stackoverflow_0008188528_beautifulsoup_html_python_screen_scraping_web_scraping.txt
Q: attributes in python class I have problem updating attributes in a python class, I give a small example. #!/usr/bin/python # -*- coding: utf-8 -*- class myClass(): def __init__(self): self.s=0 self.procedure() def procedure(self):#{{{ s=self.s print s self.operatio...
attributes in python class
I have problem updating attributes in a python class, I give a small example. #!/usr/bin/python # -*- coding: utf-8 -*- class myClass(): def __init__(self): self.s=0 self.procedure() def procedure(self):#{{{ s=self.s print s self.operation() print s def oper...
[ "in myClass.procedure(), you create the local name s with a value copied from self.s, which is 0. In myClass.operation(), you set self.s to 1. But you haven't overwritten your previous copy to s in myClass.procedure(), so it is still 0.\n", "You are printing s instead of self.s in the last print.\n", "Your proc...
[ 2, 1, 1, 1 ]
[]
[]
[ "attributes", "class", "python", "self" ]
stackoverflow_0008188461_attributes_class_python_self.txt
Q: How to pull a BitBucket repository without access to hg I was wondering if it was possible to pull a private mercurial repo to a server without access to hg. I have SSH access, but do not have the ability to install HG. I was thinking some kind of Python script that used http access or something, but I wasn't sure...
How to pull a BitBucket repository without access to hg
I was wondering if it was possible to pull a private mercurial repo to a server without access to hg. I have SSH access, but do not have the ability to install HG. I was thinking some kind of Python script that used http access or something, but I wasn't sure. I was also thinking this might only be possible with public...
[ "What good would getting the repository be if you don't have mercurial installed and can't install it?\nDo you instead mean get the files in a specific revision? If so you can easily do that using:\nwget https://username:password@bitbucket.org/user/repo/get/REVISIONHASH.zip\n\nI'm pretty sure you can put user/pass...
[ 9, 2, 1 ]
[]
[]
[ "bitbucket", "mercurial", "python" ]
stackoverflow_0003082107_bitbucket_mercurial_python.txt
Q: How do you POST and receive a cookie in Python? I'm trying to create a python script that logs into JIRA using their REST api. To do this I need to POST a login form (with the username and password) to the JIRA server and store the cookie that is retrieved (preferably as a field in a file). Here's the login docs: ...
How do you POST and receive a cookie in Python?
I'm trying to create a python script that logs into JIRA using their REST api. To do this I need to POST a login form (with the username and password) to the JIRA server and store the cookie that is retrieved (preferably as a field in a file). Here's the login docs: http://confluence.atlassian.com/display/JIRA042/JIRA+...
[ "You should use LWPCookieJar\nimport urllib, urllib2, cookielib\nurl='http://localhost:8080/rest/auth/latest/session'\npost={\"username\" : \"admin\", \"password\" : \"hunter2\"}\npost_data=urllib.urlencode(post)\ncookie = cookielib.LWPCookieJar()\nopener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie))\...
[ 2 ]
[]
[]
[ "authentication", "cookies", "jira", "python" ]
stackoverflow_0008107311_authentication_cookies_jira_python.txt
Q: Is it is possible to "set" a list to a ComboBox, wxpython? Hi i know its possible to do this with lists however is it possible to do this with Comboboxes? Is there anything similar to the set function? I have tried using set with a Combo box but i receive the following error: AttributeError: 'ComboBox' object ...
Is it is possible to "set" a list to a ComboBox, wxpython?
Hi i know its possible to do this with lists however is it possible to do this with Comboboxes? Is there anything similar to the set function? I have tried using set with a Combo box but i receive the following error: AttributeError: 'ComboBox' object has no attribute 'Set' Thanks.
[ "Well, you can call SetItems(myList) to put a list into a ComboBox, overwriting what's already in it.\nEDIT: The most common method to create a list in a combobox's list is like this:\nmyList = [\"dog\", \"cat\", \"hamster\"]\ncbo = wx.ComboBox(self, choices=myList)\n\nBut since ComboBox inherits from ItemContainer...
[ 4, 1, 1 ]
[]
[]
[ "python", "wxpython" ]
stackoverflow_0008182295_python_wxpython.txt
Q: Need clear explanation about how to download a file in python I needed to download a file within a python program, someone told me to do this. source = urllib2.urlopen("http://someUrl.com/somePage.html").read() open("/path/to/someFile", "wb").write(source) It working very well, but I would like to understand the ...
Need clear explanation about how to download a file in python
I needed to download a file within a python program, someone told me to do this. source = urllib2.urlopen("http://someUrl.com/somePage.html").read() open("/path/to/someFile", "wb").write(source) It working very well, but I would like to understand the code. When you have something like patatoe = 1 Isn't a variable? ...
[ "The word \"source\" is a variable. When you call urllib2's urlopen method and pass it a URL, it will open that url. You could then type \"source.read()\" to read the web page (i.e. download it). In your example, it's combined into one line. See http://docs.python.org/library/urllib2.html\nThe second piece opens a ...
[ 2, 1, 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008189479_python.txt
Q: Access a member in base class in Python? consider the following python code class Base(object): def __init__(self): self.foo = 5 class Derived(Base): def __init__(self): Base.__init__(self) self.foo = 6 bar = Base() print bar.foo foobar = Derived() print foobar.foo Can I access the f...
Access a member in base class in Python?
consider the following python code class Base(object): def __init__(self): self.foo = 5 class Derived(Base): def __init__(self): Base.__init__(self) self.foo = 6 bar = Base() print bar.foo foobar = Derived() print foobar.foo Can I access the foo in the base class from foobar. In C++ we ca...
[ "No, there is no way to access it, since the attribute is overriden. The classes share the same __dict__ storage.\nIf you want to avoid clash of identically named private attributes in subclasses, you can use self.__foo, which will expand to self._ClassName__foo, but you normally shouldn't need that.\n", "You can...
[ 2, 1 ]
[]
[]
[ "inheritance", "python" ]
stackoverflow_0008189330_inheritance_python.txt
Q: sleekxmpp changed_status event, firing multiple times I am using sleekxmpp to connect to Google Talk. I am trying to track when contacts change their status using the changed_status event. The issue I am having is that as I log a status change, the function associated with the changed_status event seems to be call...
sleekxmpp changed_status event, firing multiple times
I am using sleekxmpp to connect to Google Talk. I am trying to track when contacts change their status using the changed_status event. The issue I am having is that as I log a status change, the function associated with the changed_status event seems to be called multiple times. Why might this be? I am thinking it has ...
[ "The answer is that you exposed a bug in SleekXMPP that I need to fix :)\nThe changed_status event was firing for any presence stanza received, and not firing only when a resource's status or show value changed. \nThe bug fix is now in the develop branch and it will be in the soon-to-be RC3 release.\n", "Check th...
[ 5, 0 ]
[]
[]
[ "google_talk", "python", "xmpp" ]
stackoverflow_0008177403_google_talk_python_xmpp.txt
Q: Pyro4, serve object with constructor parameters. how? I have an object that takes a parameter in the constructor. I was wondering how I can serve this from Pyro4. An Example: import Pyro4 class MyPyroThing(object): def __init__(self, theNumber): self.Number = theNumber Pyro4.Daemon.serveSimple( {...
Pyro4, serve object with constructor parameters. how?
I have an object that takes a parameter in the constructor. I was wondering how I can serve this from Pyro4. An Example: import Pyro4 class MyPyroThing(object): def __init__(self, theNumber): self.Number = theNumber Pyro4.Daemon.serveSimple( { MyPyroThing(): None }, ns=True, verbose=Tr...
[ "The answers above where not what I was really asking, meaning I explained my question badly. Mea Culpa.\nI wanted to invoke an instance on the client. But that is not how Pyro4 works at all. A class in instantiated on the server and this instance is transmitted over the wire.\nAfter mailing Irmin (the original dev...
[ 3, 1 ]
[]
[]
[ "pyro", "python" ]
stackoverflow_0008151108_pyro_python.txt
Q: How can I delete the automatic Indexes in App Engine? So I have a live Python application on App Engine that has far too many automatic indexes. I noticed a high amount of datastore writes for my low entity count and I believe this is the cause. Each entity has many StringProperties and some even have StringListPr...
How can I delete the automatic Indexes in App Engine?
So I have a live Python application on App Engine that has far too many automatic indexes. I noticed a high amount of datastore writes for my low entity count and I believe this is the cause. Each entity has many StringProperties and some even have StringListProperties. I added the indexed = False to all my object's pr...
[ "vacuum_indexes is only for indexes defined in index.yaml, for automatic index its enough to set indexed = False and uploaded a new version.\nYou can see the impact of setting indexed to False in the development server datastore page in the write counts column. \n", "To get rid of the existing automatic indices y...
[ 3, 1 ]
[]
[]
[ "google_app_engine", "google_cloud_datastore", "python" ]
stackoverflow_0008185834_google_app_engine_google_cloud_datastore_python.txt
Q: Python deprecated functions I have a Django app written in Python 2.5 and I plan to upgrade it to be compatible with Python 2.6. It contains hundreds of .py files. Is there a simple way to find all deprecated functions in those files? A: Between point releases of Python (like between 2.5 and 2.6) anything that m...
Python deprecated functions
I have a Django app written in Python 2.5 and I plan to upgrade it to be compatible with Python 2.6. It contains hundreds of .py files. Is there a simple way to find all deprecated functions in those files?
[ "Between point releases of Python (like between 2.5 and 2.6) anything that might break is a warning for at least one release. Most deprecation warnings are emitted by default but you have fine-grained control over the emitted warnings with the -W interpreter invocation option.\nThis is a relatively small issue betw...
[ 5, 5, 0, 0, 0 ]
[]
[]
[ "python", "python_2.6" ]
stackoverflow_0001653734_python_python_2.6.txt
Q: wxPython StaticText widget "flickering" I'm trying to make a digital clock. One of the problems with it is that the display will "flicker". In other words the wx.StaticText widget (self.ST in this case), will go blank for very short periods. I believe the cause may find it's root in how self.ST updates (ie, SetLab...
wxPython StaticText widget "flickering"
I'm trying to make a digital clock. One of the problems with it is that the display will "flicker". In other words the wx.StaticText widget (self.ST in this case), will go blank for very short periods. I believe the cause may find it's root in how self.ST updates (ie, SetLabel()). Is there a way to provide smoother tra...
[ "One way to fix the flickering is to enable double buffering in the top container for your widget. Normally this is done by calling self.SetDoubleBuffered(True) within the initialiser, for example within Panel container for your StaticText class.\n", "What happens is that it takes more than one monitor refresh to...
[ 8, 1, 0 ]
[]
[]
[ "clock", "python", "wxpython" ]
stackoverflow_0005294274_clock_python_wxpython.txt
Q: In python 3.2, how to compare a symbols e.g. > Im writing a function which will guess what number I'm thinking of, but how do I compare a symbol like a > or less than symbol? def NumberGuess (low,high): guess = ((low+high//2) if str(input(guess,"?")) == (">") : NumberGuess (guess,high) elif s...
In python 3.2, how to compare a symbols e.g. >
Im writing a function which will guess what number I'm thinking of, but how do I compare a symbol like a > or less than symbol? def NumberGuess (low,high): guess = ((low+high//2) if str(input(guess,"?")) == (">") : NumberGuess (guess,high) elif str(input(guess,"?")) == "<": NumberGuess (l...
[ "def NumberGuess (lo,hi):\n guess = (lo+hi)//2\n user_guess = input(\"Please, input '>' or '<' as a guess: \")\n if user_guess == \">\" :\n ReverseNumberGuess (guess,hi)\n elif user_guess == \"<\":\n ReverseNumberGuess (lo,guess)\n\n" ]
[ 0 ]
[]
[]
[ "python" ]
stackoverflow_0008190017_python.txt
Q: can this python be shorter I tend to obsess about expressing code the most compactly and succinctly possible without sacrificing runtime efficiency. Here's my code: p_audio = plate.parts.filter(content__iendswith=".mp3") p_video = not p_audio and plate.parts.filter(content__iendswith=".flv") p_swf = not p_audi...
can this python be shorter
I tend to obsess about expressing code the most compactly and succinctly possible without sacrificing runtime efficiency. Here's my code: p_audio = plate.parts.filter(content__iendswith=".mp3") p_video = not p_audio and plate.parts.filter(content__iendswith=".flv") p_swf = not p_audio and not p_video and plate.part...
[ "Actually, in your pursuit of compactness and efficiency, you have managed to come up with code that is terribly inefficient. This is because when you refer to p_audio or not p_audio, that causes that queryset to be evaluated - and because you haven't sliced it before then, that means that the entire filter is brou...
[ 3, 2, 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0008188638_django_python.txt
Q: segmenting and writing binary file using Python I have two binary input files, firstfile and secondfile. secondfile is firstfile + additional material. I want to isolate this additional material in a separate file, newfile. This is what I have so far: import os import struct origbytes = os.path.getsize(firstfile)...
segmenting and writing binary file using Python
I have two binary input files, firstfile and secondfile. secondfile is firstfile + additional material. I want to isolate this additional material in a separate file, newfile. This is what I have so far: import os import struct origbytes = os.path.getsize(firstfile) fullbytes = os.path.getsize(secondfile) numbytes = f...
[ "If you know that secondfile is the same as firstfile + appended data, why even read in the first part of secondfile?\nwith open(secondfile,'rb') as f:\n f.seek(origbytes)\n rest = f.read()\n\nAs for writing things out,\nwith open(newfile,'wb') as f:\n f.write(rest)\n\nis just fine. The stuff with struct ...
[ 3, 2, 1, 0 ]
[]
[]
[ "binaryfiles", "python" ]
stackoverflow_0008190161_binaryfiles_python.txt
Q: Python script on server vs. command line I have a simple hello world python script: #!/usr/bin/python print "Content-Type: text/html" print print """\ <html> <body> <h2>Hello World!</h2> </body> </html> """ I uploaded it to my server, which has python installed, yet when I visit it in the browser by hitting http:...
Python script on server vs. command line
I have a simple hello world python script: #!/usr/bin/python print "Content-Type: text/html" print print """\ <html> <body> <h2>Hello World!</h2> </body> </html> """ I uploaded it to my server, which has python installed, yet when I visit it in the browser by hitting http://myserver.foo/script.py , I see the script in...
[ "Stupid (but mandatory) questions:\n1. Do you have this in either your conf file or an .htaccess (assuming Apache)?\nAddHandler cgi-script .cgi .py\n\nOptions +ExecCGI\n\n2. Have you chmod'd the file to 755?\n3. Is Python at /usr/bin/python? (It could be C:\\Python32\\python.exe)\n\nSome notes:\n\nI generally recom...
[ 3 ]
[]
[]
[ "python" ]
stackoverflow_0008190403_python.txt
Q: Elixir EntityCollection.remove() doesn't work I'm trying to remove a certain Entity from the collection in a EntityCollection, which is not working, results in an exception: list.remove(x): x not in list. Code excerpt as follows: user.platformSubscriptions.remove(platform) The platform variable is in fact in the p...
Elixir EntityCollection.remove() doesn't work
I'm trying to remove a certain Entity from the collection in a EntityCollection, which is not working, results in an exception: list.remove(x): x not in list. Code excerpt as follows: user.platformSubscriptions.remove(platform) The platform variable is in fact in the platformSubscriptions collection.
[ "The reason it didn't work was probably because there was no proper comparator function for the platform object. So the solution is to loop through platformSubscriptions to find a match for platform by comparing the id field:\nfor subedPlat in user.platformSubscriptions:\n if subedPlat.id == platform.user.platfo...
[ 0 ]
[]
[]
[ "python", "python_elixir", "sqlalchemy" ]
stackoverflow_0008181998_python_python_elixir_sqlalchemy.txt
Q: How to read ahead in a file when looping through it with Python? I am looping through a file and if I find something, would like to read ahead several lines looking for something before returning control to the main loop. However, I want to return control at the point that I stopped looking ahead. Sample code: fo...
How to read ahead in a file when looping through it with Python?
I am looping through a file and if I find something, would like to read ahead several lines looking for something before returning control to the main loop. However, I want to return control at the point that I stopped looking ahead. Sample code: for line in file: line = line.strip() llist = line.split() ...
[ "It's not a good idea to read ahead if you don't need to, which is the case here. What you need to do can be accomplished in a single for loop, by maintaining one bit of state. This allows for error checking, and scales up to much more complicated requirements than can be handled by nested loops over the same itera...
[ 6, 4 ]
[]
[]
[ "file", "python" ]
stackoverflow_0008189982_file_python.txt
Q: calling a function in a separate script from a class that is not a member of a class I have program with two files; main.py that has my main logic and class.py which has my classes. My problem is that I can't figure out how to call a function in main.py from a function in a class in class.py. Here's a simple exa...
calling a function in a separate script from a class that is not a member of a class
I have program with two files; main.py that has my main logic and class.py which has my classes. My problem is that I can't figure out how to call a function in main.py from a function in a class in class.py. Here's a simple example: in class1.py class Class1: def __init__(self, value): self.value = v...
[ "This is generally not the best method of writing code, but you could: import main; main.display1() (or import whateverTHEfileNAMEis if its not main.py) like so:\nclass Class1:\n    def __init__(self, value):\n   self.value = value\n\n    def main_logic(self):\n        if self.value == 'y':\n return...
[ 1 ]
[]
[]
[ "class", "function", "python", "structure" ]
stackoverflow_0008190513_class_function_python_structure.txt
Q: Can I tell an XmlTextWriter to write instead of ? I have a situation where XML data is being processed by two different mechanisms. In one place it is being processed using Python's xml.dom.minidom library. In the other, similar processing is being performed in .NET, via an XmlTextWriter. In the output generated ...
Can I tell an XmlTextWriter to write instead of ?
I have a situation where XML data is being processed by two different mechanisms. In one place it is being processed using Python's xml.dom.minidom library. In the other, similar processing is being performed in .NET, via an XmlTextWriter. In the output generated by the Python code, empty elements are written <ElementN...
[ "Probably not the answer you are after: Don't compare the XML output as pure text. We do that for our unit tests (two apps which communicate via xml messages) and it's brittle, easy to break, annoying and requires a lot of maintenance. You should parse the xml output and compare the structure - it will take more wo...
[ 5, 1, 0, 0, 0 ]
[]
[]
[ ".net", "python", "xml" ]
stackoverflow_0008187959_.net_python_xml.txt
Q: Python 3 if statements calling wrong function if action == 1: forage() elif action == 2: forage() else: display() Without knowing the context of what I'm trying to do, here's my problem: whenever I put in 1 or 2, it calls display() rather than calling forage(). Sorry if this question is too dumb to be...
Python 3 if statements calling wrong function
if action == 1: forage() elif action == 2: forage() else: display() Without knowing the context of what I'm trying to do, here's my problem: whenever I put in 1 or 2, it calls display() rather than calling forage(). Sorry if this question is too dumb to be Stackoverflow material I suppose, but I seem to ge...
[ "This is a difference between Python 2 and Python 3. In Python 2, the input function would evaluate the string input as a Python expression and return the integer 1 so your example would work as you expected. In Python 3, input will return the unevaluated string typed-in, e.g. '1'. So, for Python 3, you would nee...
[ 7, 3, 0, 0 ]
[]
[]
[ "function", "if_statement", "python" ]
stackoverflow_0008190667_function_if_statement_python.txt
Q: Python 3.2.1: Variable Referenced Before Assignment, Previously Working I have searched through similar questions on here, and cannot find an exact answer. I keep getting a "...referenced before assignment" error. I am trying to put two graphics objects returned from one function into two variables in another func...
Python 3.2.1: Variable Referenced Before Assignment, Previously Working
I have searched through similar questions on here, and cannot find an exact answer. I keep getting a "...referenced before assignment" error. I am trying to put two graphics objects returned from one function into two variables in another function. I had basically the exact same piece of code in an earlier version, and...
[ "What happens before if moveE:?\nMost likely, moveE and moveW are falsey.\n" ]
[ 3 ]
[]
[]
[ "graphics", "python", "return" ]
stackoverflow_0008190932_graphics_python_return.txt
Q: python - setup.py copy file to certain location As part of the installation process I would like to copy a config file to user's home directory, i.e. ~/.foo.conf What is the usual approach to do this with setup.py? Should I write code in setup.py to copy the file after the setup(), or is there some built-in mechan...
python - setup.py copy file to certain location
As part of the installation process I would like to copy a config file to user's home directory, i.e. ~/.foo.conf What is the usual approach to do this with setup.py? Should I write code in setup.py to copy the file after the setup(), or is there some built-in mechanism in place for this kind of task? Update I ended up...
[ "I think this might be a misuse of setuptools. If you want to stick to a setuptools install, you should probably look for a config file there, and advertise it loudly to your users, but if defaults are needed, they should be read from inside the package itself, using something like resource_stream so that you can ...
[ 4 ]
[]
[]
[ "distutils", "python", "setup.py" ]
stackoverflow_0008190964_distutils_python_setup.py.txt
Q: Pyparsing - literal text with line breaks in varying locations I'm using pyparsing to parse documents containing text in which the line ends vary in location. I need to write a parser expression that matches the text regardless of line break location. The following does NOT work: from __future__ import print_fun...
Pyparsing - literal text with line breaks in varying locations
I'm using pyparsing to parse documents containing text in which the line ends vary in location. I need to write a parser expression that matches the text regardless of line break location. The following does NOT work: from __future__ import print_function from pyparsing import * string_1 = """The quick brown fox ju...
[ "Your question is a good example of why I discourage people from defining literals with embedded whitespace, because this defeats pyparsing's built-in whitespace skipping. Pyparsing skips over whitespace between expressions. In your case, you are specifying only a single expression, a Literal comprising an entire ...
[ 2 ]
[]
[]
[ "line_breaks", "literals", "location", "pyparsing", "python" ]
stackoverflow_0008187835_line_breaks_literals_location_pyparsing_python.txt
Q: sqlalchemy query object over sqlite3 returning Nones I'm using sqlalchemy 0.6.6 and sqlite 3.6.22 on Python 2.6. When I do: In [1]: for i in ses.query(UserSnapshot): ...: print i ...: if i is None: break ...: I see: ... <twopt.UserSnapshot object at 0x86a52f50> <twopt.UserSnapshot object at...
sqlalchemy query object over sqlite3 returning Nones
I'm using sqlalchemy 0.6.6 and sqlite 3.6.22 on Python 2.6. When I do: In [1]: for i in ses.query(UserSnapshot): ...: print i ...: if i is None: break ...: I see: ... <twopt.UserSnapshot object at 0x86a52f50> <twopt.UserSnapshot object at 0x86a55050> <twopt.UserSnapshot object at 0x86a55110> <tw...
[ "Oy...this turned out to be due to my own fiddling with the DB outside of sqlalchemy, where I swapped out the user_snapshot table with a copy that had\nid int primary key\n\ninstead of\nid integer primary key\n\nApparently sqlite treats these differently:\nsqlite> create table a (a integer primary key, b integer);\...
[ 1 ]
[]
[]
[ "python", "sqlalchemy", "sqlite" ]
stackoverflow_0008190928_python_sqlalchemy_sqlite.txt
Q: simplejson double escapes data causing invalid JSON string I have a simple form for managing manufacturers in my shop. After posting form, ajax call returns json with updated data to the form. Problem is, that the returned string is invalid. It looks like it was double-escaped. Strangely similar approach across th...
simplejson double escapes data causing invalid JSON string
I have a simple form for managing manufacturers in my shop. After posting form, ajax call returns json with updated data to the form. Problem is, that the returned string is invalid. It looks like it was double-escaped. Strangely similar approach across the whole shop works without any problems. I'm also using jquery 1...
[ "There are both double quote and its html encoding inside your json text regions. For example all your class attributes are like this in the error output:\nclass=\"\\&quote;classname\\&quote;\"\n\nThe above should read:\nclass=\\\"classname\\\"\n\nA raw json.dumps will output this:\n>>> json.dumps([\"#data\", '<div...
[ 0 ]
[]
[]
[ "django", "django_lfs", "jquery", "python", "simplejson" ]
stackoverflow_0008190894_django_django_lfs_jquery_python_simplejson.txt
Q: numpy array <=> python DB-API adapter? Anyone knows is there any other adapter between numpy array and sqlite database besides the atpy? Thanks! Rgs, KC A: Can you use the default package, sqlite3? In [1]: import sqlite3 In [3]: conn = sqlite3.connect('test.db') In [4]: cur = conn.cursor() In [5]: cur.execut...
numpy array <=> python DB-API adapter?
Anyone knows is there any other adapter between numpy array and sqlite database besides the atpy? Thanks! Rgs, KC
[ "Can you use the default package, sqlite3?\nIn [1]: import sqlite3\n\nIn [3]: conn = sqlite3.connect('test.db')\n\nIn [4]: cur = conn.cursor()\n\nIn [5]: cur.execute('select * from table1')\nOut[5]: <sqlite3.Cursor object at 0xa3142c0>\n\nIn [6]: scipy.array(cur.fetchall())\nOut[6]: \narray([[ 1., 2.],\n [ 3...
[ 3 ]
[]
[]
[ "adapter", "numpy", "python", "sqlite" ]
stackoverflow_0003725394_adapter_numpy_python_sqlite.txt
Q: How do I instrument my python code? I'm developing some web apps with the grok framework, and I want to know what the framework is doing when serving a simple page. So, what tools are out there to grab such data, and maybe, graph it? A: Python has plenty of built-in reflectivity that could be used for instrumen...
How do I instrument my python code?
I'm developing some web apps with the grok framework, and I want to know what the framework is doing when serving a simple page. So, what tools are out there to grab such data, and maybe, graph it?
[ "Python has plenty of built-in reflectivity that could be used for instrumentation. For example:\ndef hax_all_the_things():\n for x in list(globals()):\n func = globals()[x]\n if callable(func) and not hasattr(func, 'instrumented'):\n globals()[x] = lambda func = func, *args, **kwargs: (\n __impo...
[ 0 ]
[]
[]
[ "grok", "python" ]
stackoverflow_0008191190_grok_python.txt
Q: Streaming stdin/stdout in Python I'm trying to stream a bash shell to/from a simple WebSockets UI, but I'm having trouble redirecting the IO. I want to start an instance of bash and connect stdout and stdin to write_message() and on_message() functions that interact with my web UI. Here's a simplified version of...
Streaming stdin/stdout in Python
I'm trying to stream a bash shell to/from a simple WebSockets UI, but I'm having trouble redirecting the IO. I want to start an instance of bash and connect stdout and stdin to write_message() and on_message() functions that interact with my web UI. Here's a simplified version of what I'm trying to do: class Handler(...
[ "It looks to me like the line:\nline = self.app.stdout.readline()\n\nwill block the ioloop from running because the application will spend most of its time hung up in the readline() waiting for the application to write some output instead. To get this to work, you are going to have to get the stdin and stdout of th...
[ 3 ]
[]
[]
[ "python", "tornado", "websocket" ]
stackoverflow_0008190648_python_tornado_websocket.txt
Q: Why does installing a python package break setuptools and causes pkg_resources to not be found? This is partly a question, partly my own findings on what I found to be the issue when I encountered this error: (cdbak)USER-MBP-2:.virtualenvs <YOUR_USER_NAME>$ pip Traceback (most recent call last): File "/Users/...
Why does installing a python package break setuptools and causes pkg_resources to not be found?
This is partly a question, partly my own findings on what I found to be the issue when I encountered this error: (cdbak)USER-MBP-2:.virtualenvs <YOUR_USER_NAME>$ pip Traceback (most recent call last): File "/Users/<YOUR_USER_NAME>/.virtualenvs/cdbak/bin/pip", line 6, in <module> from pkg_resources import load_...
[ "I'm not sure about all of your problems but there is at least one problem caused by the loremipsum package that is a dependency for the pypsum package. For some reason, in the setup.py file of loremipsum, the author includes specific requirements for the distribute package:\negg = {\n 'name': name,\n 'versi...
[ 3 ]
[]
[]
[ "django", "python", "setuptools" ]
stackoverflow_0008190620_django_python_setuptools.txt
Q: Why is an empty function call in python around 15% slower for dynamically compiled python code This is pretty bad micro-optimizing, but I'm just curious. It usually doesn't make a difference in the "real" world. So I'm compiling a function (that does nothing) using compile() then calling exec on that code and gett...
Why is an empty function call in python around 15% slower for dynamically compiled python code
This is pretty bad micro-optimizing, but I'm just curious. It usually doesn't make a difference in the "real" world. So I'm compiling a function (that does nothing) using compile() then calling exec on that code and getting a reference to the function I compiled. Then I'm executing it a couple million times and timing ...
[ "The dis.dis() function shows that the code object for each version is identical:\naa\n 1 0 LOAD_CONST 0 (None)\n 3 RETURN_VALUE \nlocalFunc\n 10 0 LOAD_CONST 0 (None)\n 3 RETURN_VALUE \n\nSo the difference is in the function object. ...
[ 11 ]
[]
[]
[ "dynamic", "micro_optimization", "optimization", "python", "python_2.7" ]
stackoverflow_0008191390_dynamic_micro_optimization_optimization_python_python_2.7.txt
Q: django making radio select required How can I make the radio select required? The only way I can think of now is to overwrrite my_list_choices = ( (1,'Yes'),(0,'No'),) widgets = { 'my_radio_field' : forms.RadioSelect(choices=my_list_choices), } edit: My model is as follows class MyModel(models.Model): na...
django making radio select required
How can I make the radio select required? The only way I can think of now is to overwrrite my_list_choices = ( (1,'Yes'),(0,'No'),) widgets = { 'my_radio_field' : forms.RadioSelect(choices=my_list_choices), } edit: My model is as follows class MyModel(models.Model): name = models.CharField(max_length=32, blan...
[ "Unless I'm much mistaken, when using a form, you can have the form.is_valid() check in your views.\nI have a site where this goes down and have a file field as well as radio widget. If I don't select one of them (or both) and press submit, the page reloads and prints out the error (field required).\nform = myform(...
[ 1, 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0008188421_django_python.txt
Q: drop down with onchange events I have a dropdown with onchange events. When ever user change the drop down box then ajax called and result displayed. All this working fine. I have following list in template. Apple Pineapple When ever user changed the drop down value. Then result merged Orange Graps Apple Pinea...
drop down with onchange events
I have a dropdown with onchange events. When ever user change the drop down box then ajax called and result displayed. All this working fine. I have following list in template. Apple Pineapple When ever user changed the drop down value. Then result merged Orange Graps Apple Pineapple But output should be like this...
[ "if you are using jQuery to call ajax, I would recommend you use the .empty() straight after the .change() function.\nI have no idea what yours looks like, although it should be something like this.\n$('#id_category').change(function() {\n /* Set your string to nothing */\n var str = \"\";\n /* once your d...
[ 0, 0 ]
[]
[]
[ "django", "django_templates", "python" ]
stackoverflow_0008181320_django_django_templates_python.txt
Q: In Python, is it possible to iterate over values stored in a thread local by each thread? Suppose I have this: from threading import local tl = local() At various points, different threads in a thread pool will set something on the thread local: tl.resource = <something> Is it possible to iterate over all tl.res...
In Python, is it possible to iterate over values stored in a thread local by each thread?
Suppose I have this: from threading import local tl = local() At various points, different threads in a thread pool will set something on the thread local: tl.resource = <something> Is it possible to iterate over all tl.resource set by each thread?
[ "Not in Python, although you might be able to dig around in the interpreter state in C and acquire this information (although I doubt it). It would be reasonable to assume that this might be possible if local() returned a singleton for each thread, but it does not - calling local() multiple times in the same threa...
[ 3 ]
[]
[]
[ "multithreading", "python", "thread_local" ]
stackoverflow_0008191841_multithreading_python_thread_local.txt
Q: matplotlib drawing contour labels outside AxesSubplot in .eps file I am making a plot using matplotlib.pyplot imported as PL: FIG = PL.figure(figsize=(12,8), dpi=150) AX = FIG.add_subplot(111, aspect='equal', xlim=(lonMin,lonMax), ylim=(latMin,latMax)) PL.contourf(lon, lat, swath, range(2,56,1)) PL.colorbar(shrink...
matplotlib drawing contour labels outside AxesSubplot in .eps file
I am making a plot using matplotlib.pyplot imported as PL: FIG = PL.figure(figsize=(12,8), dpi=150) AX = FIG.add_subplot(111, aspect='equal', xlim=(lonMin,lonMax), ylim=(latMin,latMax)) PL.contourf(lon, lat, swath, range(2,56,1)) PL.colorbar(shrink=0.8, extend='both', ticks=range(5,55,5)) CNTR = PL.contour(lon, lat, ra...
[ "Sounds like a bug you could file as an issue on Github, but as a workaround, if pdf output looks correct, you could use pdftops (comes with xpdf) and then ps2eps.\n" ]
[ 1 ]
[]
[]
[ "eps", "matplotlib", "python" ]
stackoverflow_0008189121_eps_matplotlib_python.txt
Q: Using an Array to analyze input and utilizing it for a counter of array listing within the input in Python this time I got stuck on the second part. Thought'll it'll be easier but I ended up getting a bunch of syntax error. Here's the program: def main(): Characters = ["A", "B", "C", "D", "E", "F", "G"\ ...
Using an Array to analyze input and utilizing it for a counter of array listing within the input in Python
this time I got stuck on the second part. Thought'll it'll be easier but I ended up getting a bunch of syntax error. Here's the program: def main(): Characters = ["A", "B", "C", "D", "E", "F", "G"\ , "H", "I", "J", "K", "L", "M", "N"\ , "O", "P", "Q", "R", "S", "T", "U", "V"\ ...
[ "I think what you're trying to do is count how often each letter occurs in text2. If that's the case, there are a number of things wrong here.\nFirst, stop saying array. These are lists that you're using. Arrays are not common in Python.\nSecond, you've written if Characters[\"A\"]. This doesn't make any sense. Lis...
[ 2, 0 ]
[]
[]
[ "arrays", "counter", "python" ]
stackoverflow_0008191637_arrays_counter_python.txt
Q: Automate Install mysql-server and postfix remotely I am running a Python script with Fabric which sent a bash script over remotely and execute. The script will have to run over multiple remote servers automatically (without user interference). But when I am installing these 2 package, there is a small complication...
Automate Install mysql-server and postfix remotely
I am running a Python script with Fabric which sent a bash script over remotely and execute. The script will have to run over multiple remote servers automatically (without user interference). But when I am installing these 2 package, there is a small complication of GUI interface prompt in the command line. This cause...
[ "In http://www.muhuk.com/2010/05/how-to-install-mysql-with-fabric/ it's described a solution to the installation of mysql-server, basically what you have to do is:\n# password prompt \nwhile True:\n mysql_password = getpass('Please enter MySQL root password: ')\n mysql_password_confirmation = getpass('Please ...
[ 2 ]
[]
[]
[ "automation", "fabric", "installation", "python" ]
stackoverflow_0008170691_automation_fabric_installation_python.txt
Q: How to read stdin to a 2d python array of integers? I would like to read a 2d array of integers from stdin (or from a file) in Python. Non-working code: from StringIO import StringIO from array import array # fake stdin stdin = StringIO("""1 2 3 4 5 6""") a = array('i') a.fromstring(stdin.read()) This gives me ...
How to read stdin to a 2d python array of integers?
I would like to read a 2d array of integers from stdin (or from a file) in Python. Non-working code: from StringIO import StringIO from array import array # fake stdin stdin = StringIO("""1 2 3 4 5 6""") a = array('i') a.fromstring(stdin.read()) This gives me an error: a.fromstring(stdin.read()) ValueError: stri...
[ "Several approaches to accomplish this are available. Below are a few of the possibilities.\nUsing an array\nFrom a list\nReplace the last line of code in the question with the following.\na.fromlist([int(val) for val in stdin.read().split()])\n\nNow:\n>>> a\narray('i', [1, 2, 3, 4, 5, 6])\n\nCon: does not preserve...
[ 13, 2 ]
[ "arr = []\narr = raw_input()\n\nIf you want to split the input by spaces:\narr = []\narr = raw_input().split()\n\n" ]
[ -1 ]
[ "arrays", "python", "stdin" ]
stackoverflow_0008192379_arrays_python_stdin.txt
Q: Flip (reverse) image vertically given its string? So I have a string of RGBA image data, each pixel is a byte long. I know the image's x and y resolution too. Now I want to edit the string in a way which would cause the image to be flipped or reversed vertically, which means have the first "row" of pixels become t...
Flip (reverse) image vertically given its string?
So I have a string of RGBA image data, each pixel is a byte long. I know the image's x and y resolution too. Now I want to edit the string in a way which would cause the image to be flipped or reversed vertically, which means have the first "row" of pixels become the last row and the opposite, and like this for all oth...
[ "To do what you want to the letter this is one way to proceed:\n>>> img = 'ABCDEFGHIJKL'\n>>> x, y = 4, 3\n>>> def chunks(l, n):\n... for i in xrange(0, len(l), n):\n... yield l[i:i+n]\n... \n>>> [row for row in chunks(img, x)]\n['ABCD', 'EFGH', 'IJKL']\n>>> ''.join(reversed([row for row in chunks(img, ...
[ 5, 0 ]
[]
[]
[ "flip", "image", "image_processing", "python", "reverse" ]
stackoverflow_0008192508_flip_image_image_processing_python_reverse.txt
Q: Fast way to find locally maximal gradient values in a numpy array? I have a 2-d array for which I want to detect all locally maximal array indices. That is, given an index (i, j), its maximum gradient is the largest absolute change from any of its 8 neighboring values: Index: (i, j) Neighbors: (i-1,j+1) (i,j+1) ...
Fast way to find locally maximal gradient values in a numpy array?
I have a 2-d array for which I want to detect all locally maximal array indices. That is, given an index (i, j), its maximum gradient is the largest absolute change from any of its 8 neighboring values: Index: (i, j) Neighbors: (i-1,j+1) (i,j+1) (i+1,j+1) (i-1,j) [index] (i+1,j) (i-1,j-1) (i,j-1) (i+1,j-1) ...
[ "Consider these 8 relative indexes:\nX1 X2 X3\nX4 X X5\nX6 X7 X8\n\nYou can compute for every pixel X the differences D1=Val(X)-Val(X1), D2=Val(X)-Val(X2), D3=Val(X)-Val(X3), D4=Val(X)-Val(X4). You don't need to compute the other differences because they are mirrors of the first four.\nTo compute the differences, ...
[ 2, 1 ]
[]
[]
[ "linear_algebra", "matrix", "numpy", "python" ]
stackoverflow_0008178129_linear_algebra_matrix_numpy_python.txt
Q: Trying to show object state in plone gives a "No workflow provides '${name}' information." error I'm trying to return an objects state using the following code: workflow = getToolByName(context,'portal_workflow') status = workflow.getInfoFor(obj,'review_state') When I try to output this using: print "State: %s" %...
Trying to show object state in plone gives a "No workflow provides '${name}' information." error
I'm trying to return an objects state using the following code: workflow = getToolByName(context,'portal_workflow') status = workflow.getInfoFor(obj,'review_state') When I try to output this using: print "State: %s" % (status) I get the following error: Exception Type Workflow Exception Exception Value No workflow p...
[ "Actually, Giacomo's answer is correct. The obj you were trying to pass to the getInfoFor method is a catalog brain, not an actual content object. That is why asking for it's review_state directly worked for you. \nA Plone content object has no knowledge of it's own workflow state. That information is maintained by...
[ 5, 2, 0 ]
[]
[]
[ "plone", "python", "zope" ]
stackoverflow_0008181849_plone_python_zope.txt
Q: Read a javascript variable from python? i have a problem with python script and javascript script in a website. I have this website www.orangedropdesign.com/progetti/default/ and in the source i can view this script: ` var idDebitoPubblico = "debito"; var idDebitoTesta = "Testa"; var valoreInizialeDebito = Ma...
Read a javascript variable from python?
i have a problem with python script and javascript script in a website. I have this website www.orangedropdesign.com/progetti/default/ and in the source i can view this script: ` var idDebitoPubblico = "debito"; var idDebitoTesta = "Testa"; var valoreInizialeDebito = Math.round(1449.361*1321693021); var incremento...
[ "Get your basics right.\nJavascript is client-side.\nPython is server side. Make this clear.\nSo basically how can these two access variables of each other. In simple terms not possible.\nThe only workaround it to explicitly send that variables content via an ajax call.\nThis might help you :\nhttp://api.jquery.com...
[ 0 ]
[]
[]
[ "parsing", "python", "web" ]
stackoverflow_0008193018_parsing_python_web.txt
Q: Ntlk & Python, plotting ROC curve I am using nltk with Python and I would like to plot the ROC curve of my classifier (Naive Bayes). Is there any function for plotting it or should I have to track the True Positive rate and False Positive rate ? It would be great if someone would point me to some code already doin...
Ntlk & Python, plotting ROC curve
I am using nltk with Python and I would like to plot the ROC curve of my classifier (Naive Bayes). Is there any function for plotting it or should I have to track the True Positive rate and False Positive rate ? It would be great if someone would point me to some code already doing it... Thanks.
[ "PyROC looks simple enough: tutorial, source code\nThis is how it would work with the NLTK naive bayes classifier:\n# class labels are 0 and 1\nlabeled_data = [\n (1, featureset_1),\n (0, featureset_2),\n (1, featureset_3),\n # ...\n]\n\n# naive_bayes is your already trained classifier,\n# preferrably n...
[ 3 ]
[]
[]
[ "machine_learning", "nlp", "nltk", "python" ]
stackoverflow_0008192455_machine_learning_nlp_nltk_python.txt
Q: How to debug 0 mb unnamed uploads? Looking from the datastore console admin blobstore viewer it appears many files are 0 sizes: Could you comment or say why this has happened? I think the file upload code I have is pretty clean so where is the bug? for upload in self.get_uploads(): try: img = Image(re...
How to debug 0 mb unnamed uploads?
Looking from the datastore console admin blobstore viewer it appears many files are 0 sizes: Could you comment or say why this has happened? I think the file upload code I have is pretty clean so where is the bug? for upload in self.get_uploads(): try: img = Image(reference=ad) img.primary_image = ...
[ "You're specifying multiple file fields, so the datastore is attempting to process multiple files. This might be considered a bug in the blobstore (in which case you could file one), but if your browser is submitting the empty fields, it's unclear to me what the proper response is.\nYou could work around this by de...
[ 1, 1 ]
[]
[]
[ "blobstore", "google_app_engine", "google_cloud_datastore", "jinja2", "python" ]
stackoverflow_0008163956_blobstore_google_app_engine_google_cloud_datastore_jinja2_python.txt
Q: How to sort a list of dictionaries by 2 keys, one of which is based on an arbitrary list I'm using python. How do I sort the list of dictionaries below first by 'day' then by 'job'. The sort on 'job' needs to be based on priority_list (not alphabetically): priority_list= ['c','a','b'] my_list_of_dicts = [ {'day':...
How to sort a list of dictionaries by 2 keys, one of which is based on an arbitrary list
I'm using python. How do I sort the list of dictionaries below first by 'day' then by 'job'. The sort on 'job' needs to be based on priority_list (not alphabetically): priority_list= ['c','a','b'] my_list_of_dicts = [ {'day':5,'job':'c','irrelevant_key':'more stuff'}, {'day':1,'job':'a','irrelevant_key':'stuff'}, {'da...
[ "def key(d):\n return d['day'], priority_list.index(d['job'])\n\nsorted(my_list_of_dicts, key=key)\n\n", "my_list_of_dicts.sort(key=lambda x: (x['day'], priority_list.index(x['job'])))\n\n", "For a very small list, such as your example, the answers using list.index() will work fine.\nHowever, if the list is ...
[ 3, 3, 2 ]
[]
[]
[ "dictionary", "list", "python", "sorting" ]
stackoverflow_0008191355_dictionary_list_python_sorting.txt
Q: Installing python cgi in wamp apache on windows 7 I'm trying to install mod_wsgi on windows 7, but can't get it to work. I've validated that everything is 32-bit, the filenames are correct and I've installed python 2.7 for all users. The python path has been added to PATH and I have checked it's working in console...
Installing python cgi in wamp apache on windows 7
I'm trying to install mod_wsgi on windows 7, but can't get it to work. I've validated that everything is 32-bit, the filenames are correct and I've installed python 2.7 for all users. The python path has been added to PATH and I have checked it's working in console. Does anyone have any idea why apache produces the fol...
[ "Install/Re-install python for \"All users\". I faced the same problem.\n" ]
[ 0 ]
[]
[]
[ "apache", "mod_wsgi", "python", "wamp", "windows_7" ]
stackoverflow_0007126981_apache_mod_wsgi_python_wamp_windows_7.txt
Q: Python 3 with NumPy and object references I need to create a large matrix (array) structure (3 axis) and each element should store the reference to a Python object (myclass instance). Is it possible to use numpy to create such an array. Which data type should I use in order to store Python references? The advantag...
Python 3 with NumPy and object references
I need to create a large matrix (array) structure (3 axis) and each element should store the reference to a Python object (myclass instance). Is it possible to use numpy to create such an array. Which data type should I use in order to store Python references? The advantage of numpy is the support of slicing at differe...
[ "Use dtype=object to store Python objects in the array.\nimport numpy as np\n\nclass Foo: pass\n\narr=np.empty(2,dtype=object)\narr[:]=[Foo(),Foo()]\nprint(arr)\n# [<__main__.Foo instance at 0xb7827d0c>\n# <__main__.Foo instance at 0xb748b5ac>]\n\nprint(arr.dtype)\n# object\n\n", "Just give object as the dtype, ...
[ 2, 1, 1 ]
[]
[]
[ "arrays", "numpy", "python" ]
stackoverflow_0008193118_arrays_numpy_python.txt
Q: Python 2.7 on App Engine, simplejson vs native json, who's faster? I've had the understanding that simplejson is much faster than the native json in Python, such as this thread: What are the differences between json and simplejson Python modules? However, I was just thrown for a loop when I read in App Engines doc...
Python 2.7 on App Engine, simplejson vs native json, who's faster?
I've had the understanding that simplejson is much faster than the native json in Python, such as this thread: What are the differences between json and simplejson Python modules? However, I was just thrown for a loop when I read in App Engines documentation that with Python 2.7 Uses the native JSON library, which is...
[ "Before the release of the Python 2.7 runtime, nearly every module included with App Engine, and literally every module you could include yourself were pure python. With the 2.7 release, the json module includes speedups written in C, making it much faster than any simplejson you can run on App Engine.\nThe benefit...
[ 23, 4 ]
[]
[]
[ "google_app_engine", "json", "python", "python_2.7", "simplejson" ]
stackoverflow_0008191945_google_app_engine_json_python_python_2.7_simplejson.txt
Q: How to verify if a Neo4j Graph DB exist with Python? I've this small snipped of code that load a file in an embedded Neo4j Database. With this code I've two problems and I don't find documentation to solve it. I'm following the samples of the documentation to create an index, but: a) How can I detect if the index ...
How to verify if a Neo4j Graph DB exist with Python?
I've this small snipped of code that load a file in an embedded Neo4j Database. With this code I've two problems and I don't find documentation to solve it. I'm following the samples of the documentation to create an index, but: a) How can I detect if the index exists yet? The documentation explais that if the index al...
[ "In your first example, the documentation is wrong. There is currently only one way to determine if an index exists, and it is to check for a ValueError when getting an index. Like this:\ntry:\n idx = db.node.indexes.get('my_index')\nexcept ValueError,e:\n idx = db.node.indexes.create('my_index')\n\nThat shou...
[ 2 ]
[]
[]
[ "neo4j", "neo4j.py", "python" ]
stackoverflow_0008189409_neo4j_neo4j.py_python.txt
Q: Is there a __getattribute__ to get a class or object from a python module? I have a string like this: classname = "Recipe" Now I have a module "contenttype.py" and I want to do something like this: import contenttype myobject = contenttype.__getobject__(classname)(param=value) Is there something similar to getat...
Is there a __getattribute__ to get a class or object from a python module?
I have a string like this: classname = "Recipe" Now I have a module "contenttype.py" and I want to do something like this: import contenttype myobject = contenttype.__getobject__(classname)(param=value) Is there something similar to getattribute to be used in module's top level? I know I can do it with exec() but I a...
[ "A module is just an object, so yes, you can use __getattribute__ on it.\nBut you don't want to call __getattribute__ directly, that's an implementation detail. For accessing named attributes on objects, including module members, use getattr().\ngetattr(contenttype, classname)(param= value)\n\n" ]
[ 7 ]
[]
[]
[ "class", "python" ]
stackoverflow_0008193998_class_python.txt
Q: Compiling Python Extension On Windows With Cygwin I have been having a terrible time trying to compile a python extension - hopefully someone can help. I initially tried executing 'python.exe setup.py build' but received the error: 'Python was built Visual Studio 2003; extensions must be built with a compiler that...
Compiling Python Extension On Windows With Cygwin
I have been having a terrible time trying to compile a python extension - hopefully someone can help. I initially tried executing 'python.exe setup.py build' but received the error: 'Python was built Visual Studio 2003; extensions must be built with a compiler that can generate compatible binaries...". So I then downlo...
[ "I know it's inelegant, but you can rename the symlink and copy gcc-3.exe to gcc.exe. That worked for me when I used Cygwin's gcc. You might want to switch to the mingw64-i686 (or mingw64-x86_64) package to get gcc 4.5.3, or just install MinGW-w64 separately for compiling under Windows.\nAlso, you can permanently c...
[ 3 ]
[]
[]
[ "cygwin", "python", "windows" ]
stackoverflow_0008194188_cygwin_python_windows.txt
Q: Python to JavaScript for iPhone Have a webapplication with backend developed on python ( running on Django) and front end on HTML5 & javascript. Python generated data is passed on to JavaScript/HTML using JSON. Now, I would like to make it a mobile application, iPhone app to begin with. The Front end is very much...
Python to JavaScript for iPhone
Have a webapplication with backend developed on python ( running on Django) and front end on HTML5 & javascript. Python generated data is passed on to JavaScript/HTML using JSON. Now, I would like to make it a mobile application, iPhone app to begin with. The Front end is very much the same with changes in CSS files t...
[ "What I cannot understand is why you need your backend being native to iPhone. This doesn't make sense. The backend is a server-side infrastructure that speaks HTTP, so it is independent from your frontend, which may be implemented in any language (usually in HTML/Javascript, but also a GUI in *).\nThen, there is c...
[ 0 ]
[]
[]
[ "iphone", "javascript", "mobile", "pyjamas", "python" ]
stackoverflow_0008194214_iphone_javascript_mobile_pyjamas_python.txt
Q: Python regex with look behind and alternatives I want to have a regular expression that finds the texts that are "wrapped" in between "HEAD or HEADa" and "HEAD. That is, I may have a text that starts with the first word as HEAD or HEADa and the following "heads" are of type HEAD. HEAD\n\n text...text...HEAD \n\n ...
Python regex with look behind and alternatives
I want to have a regular expression that finds the texts that are "wrapped" in between "HEAD or HEADa" and "HEAD. That is, I may have a text that starts with the first word as HEAD or HEADa and the following "heads" are of type HEAD. HEAD\n\n text...text...HEAD \n\n text....text HEAD\n\n text....text ..... HEADa\n\n t...
[ "Currently, the first part of your regex looks like this:\n(?<=^\\bHEADa|HEAD\\b)\n\nYou have two alternatives; one matches five characters and the other matches four, and that's why you get the error. Some regex flavors will let you do that even though they say they don't allow variable-length lookbehinds, but no...
[ 14 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0008194470_python_regex.txt
Q: What is the difference between these two types of exponential in Python Please explain to me the difference between them? import math print math.exp(2) print print 2 ** 3 ============================ 7.38905609893 8 A: You are squaring e with math.exp(2), e is 2.71828183, see here With 2 ** 3, you are raisi...
What is the difference between these two types of exponential in Python
Please explain to me the difference between them? import math print math.exp(2) print print 2 ** 3 ============================ 7.38905609893 8
[ "You are squaring e with math.exp(2), e is 2.71828183, see here\nWith 2 ** 3, you are raising 2 to the third power.\n", "You're confusing math.exp() with math.pow(): math.pow(2, 3) == float(2**3).\n", "math.exp(2) is e raised to the second power, 2 ** 3 is 2 raised to the 3rd power.\n" ]
[ 3, 3, 1 ]
[]
[]
[ "exponential", "math", "python" ]
stackoverflow_0008195026_exponential_math_python.txt
Q: Understanding Python function arg notation like this: str.find(sub[, start[, end]]) Can someone describe what's happening syntactically in functions like functions like str.find(sub[, start[, end]])? I don't understand what the function arguments are doing or supposed to be. For one thing, what is the [, x] const...
Understanding Python function arg notation like this: str.find(sub[, start[, end]])
Can someone describe what's happening syntactically in functions like functions like str.find(sub[, start[, end]])? I don't understand what the function arguments are doing or supposed to be. For one thing, what is the [, x] construct?
[ "This square bracket notation is used to denote optional arguments. You can omit them if you wish and thus invoke default behaviour. The optional arguments will always be described in the documentation.\nNote that the square brackets used in the documentation are not part of Python itself. You can never write that ...
[ 5, 2 ]
[]
[]
[ "python" ]
stackoverflow_0008195016_python.txt
Q: How do you access a serial port in Python for mobiles? The serial port must be over USB cable, from the phone to a computer. In Java, I got it working by using the following code: CommConnection comm = (CommConnection)Connector.open("comm:USB1"); // Now use comm to read and write data How can I do this in Python...
How do you access a serial port in Python for mobiles?
The serial port must be over USB cable, from the phone to a computer. In Java, I got it working by using the following code: CommConnection comm = (CommConnection)Connector.open("comm:USB1"); // Now use comm to read and write data How can I do this in Python for mobiles, specifically PyS60?
[ "I got this from here:\n import pys60usb\n usb = pys60usb.USBConnection()\n\n # Connect to port 1. Works with most S60 3rd devices.\n usb.connect( port = 1, mode = pys60usb.ECommExclusive )\n\n" ]
[ 1 ]
[]
[]
[ "mobile", "pys60", "python", "serial_port", "usb" ]
stackoverflow_0008195148_mobile_pys60_python_serial_port_usb.txt
Q: indexes in a list Possible Duplicate: comparing lists python I have 1 original list such as: original = [1, 2, 3] and another list with nested lists (with the same size) such as: bigList = [[1, 2, 3], [2, 2, 2], [3, 2, 3]...] and I want to count how many indexes in each nested list is the same as in the origin...
indexes in a list
Possible Duplicate: comparing lists python I have 1 original list such as: original = [1, 2, 3] and another list with nested lists (with the same size) such as: bigList = [[1, 2, 3], [2, 2, 2], [3, 2, 3]...] and I want to count how many indexes in each nested list is the same as in the original list. this is what ...
[ "You did ask this question in the past and my answer was as follows:\n\nYou can do it like this:\nfrom itertools import izip\ndef matches(input_lists, base_list):\n for l in input_lists:\n yield sum(1 for a, b in izip(l, base_list) if a==b)\n\nand the result will be following:\n>>> for i in matches([[1,2,...
[ 1, 1 ]
[]
[]
[ "python" ]
stackoverflow_0008195313_python.txt
Q: Python and FTPlib Module Recently I have been interested in FTP servers and I was wondering how to get a python script to download and upload files onto a FTP server I have set up. But I can't seem to get it to work. Every time I typ in this like of code: ftp = FTP_TLS("ftp.10.0.1.14") It gives me an error, sorry...
Python and FTPlib Module
Recently I have been interested in FTP servers and I was wondering how to get a python script to download and upload files onto a FTP server I have set up. But I can't seem to get it to work. Every time I typ in this like of code: ftp = FTP_TLS("ftp.10.0.1.14") It gives me an error, sorry if it's a stupid question but...
[ "Remove that \"ftp.\" from the beginning of the address you have - it is not part of the IP address. Also, make sure you are importing FTP_TLS:\nfrom ftplib import FTP_TLS\nftp = FTP_TLS(\"10.0.1.14\")\n\nAs a side note, when you are getting an error it is a good idea to include the exact error you are getting in y...
[ 2 ]
[]
[]
[ "ftp", "ftplib", "python" ]
stackoverflow_0008195146_ftp_ftplib_python.txt
Q: repeated numpy subarrays This is a simplification of my question. I have a numpy array: x = np.array([0,1,2,3]) and I have a function: def f(y): return y**2 I can compute f(x). Now suppose I really want to compute f(x) for a repeated x: x = np.array([0,1,2,3,0,1,2,3,0,1,2,3]) Is there a way to do this without c...
repeated numpy subarrays
This is a simplification of my question. I have a numpy array: x = np.array([0,1,2,3]) and I have a function: def f(y): return y**2 I can compute f(x). Now suppose I really want to compute f(x) for a repeated x: x = np.array([0,1,2,3,0,1,2,3,0,1,2,3]) Is there a way to do this without creating a repeated version of ...
[ "You can (almost) do this by using a few tricks with strides.\nHowever, there are some major caveats...\nimport numpy as np\nx = np.arange(4)\nnumrepeats = 3\n\ny = np.lib.stride_tricks.as_strided(x, (numrepeats,)+x.shape, (0,)+x.strides)\n\nprint y\nx[0] = 9\nprint y\n\nSo, y is now a view into x where each row is...
[ 8 ]
[]
[]
[ "numpy", "python" ]
stackoverflow_0008194739_numpy_python.txt
Q: passing contents of a list to different functions I have a list like the following, plist = [[('s', [0.0, 0.1, 0.0, 0.4, 0.0]), ('aa', [0.0, 0.1, 0.0, 0.5, 0.0])], [('m', [0.0, 0.0, 0.1, 0.3, 0.0]), ('ih', [0.0, 0.1, 0.1, 0.2, 0.0])], [('k', [0.0, 0.1, 0.0, 0.1, 0.0]), ...
passing contents of a list to different functions
I have a list like the following, plist = [[('s', [0.0, 0.1, 0.0, 0.4, 0.0]), ('aa', [0.0, 0.1, 0.0, 0.5, 0.0])], [('m', [0.0, 0.0, 0.1, 0.3, 0.0]), ('ih', [0.0, 0.1, 0.1, 0.2, 0.0])], [('k', [0.0, 0.1, 0.0, 0.1, 0.0]), ('l', [0.0, 0.1, 0.0, 0.6, 0.0]), ('eh', [0....
[ "I suggest you modify the function that generates plist so that it returns a dict with a string value as a key and a list as value, or write a new function if you don't have an opportunity of modification. This way, besides u_value you can pass the dict and iteration number as arguments to all your functions in the...
[ 1 ]
[]
[]
[ "python" ]
stackoverflow_0008195534_python.txt
Q: is there some kind of expression evaluation within list/tuple slicing syntax within Python? with numpy arrays, you can use some kind of inequality within the square bracket slicing syntax: >>>arr = numpy.array([1,2,3]) >>>arr[arr>=2] array([2, 3]) is there some kind of equivalent syntax within regular python data...
is there some kind of expression evaluation within list/tuple slicing syntax within Python?
with numpy arrays, you can use some kind of inequality within the square bracket slicing syntax: >>>arr = numpy.array([1,2,3]) >>>arr[arr>=2] array([2, 3]) is there some kind of equivalent syntax within regular python data structures? I expected to get an error when I tried: >>>lis = [1,2,3] >>>lis[lis > 2] 2 but in...
[ "In Python 2.x lis > 2 returns True. This is because the operands have different types and there is no comparison operator defined for those two types, so it compares the class names in alphabetical order (\"list\" > \"int\"). Since True is the same as 1, you get the item at index 1.\nIn Python 3.x this expression ...
[ 7, 1 ]
[]
[]
[ "expression", "list", "python", "slice", "tuples" ]
stackoverflow_0008196349_expression_list_python_slice_tuples.txt
Q: Python: warnings after installation of version 2.7.2 Mac os 10.6 I've successfulle installed Python 2.7.2. I open terminal and see the following messages /Library/Python/2.6/site-packages/virtualenvwrapper/hook_loader.py:16: UserWarning: Module pkg_resources was already imported from /System/Library/Frameworks/Pyt...
Python: warnings after installation of version 2.7.2 Mac os 10.6
I've successfulle installed Python 2.7.2. I open terminal and see the following messages /Library/Python/2.6/site-packages/virtualenvwrapper/hook_loader.py:16: UserWarning: Module pkg_resources was already imported from /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.pyc, but /L...
[ "In general, you should never remove anything in /System/Library. That directory and the files in it are supplied by Apple as part of OS X. You risk breaking your system by doing so. Deleting /System/​Library/​Frameworks/​Python.framework/​Versions/​2.6/​Extras/​lib/​pyth‌​on/​pkg_resources.pyc isn't the end of ...
[ 1 ]
[]
[]
[ "osx_leopard", "python" ]
stackoverflow_0008193163_osx_leopard_python.txt
Q: Sending data to and from local app to remote hosted server Newbie here, looking for advice on which technology I should use for my particular project. Not looking for code per se, just opinions. Here's an ugly diagram of what I'm trying to achieve: [local Python app] <--ADVICE NEEDED HERE--> [hosted web server] So...
Sending data to and from local app to remote hosted server
Newbie here, looking for advice on which technology I should use for my particular project. Not looking for code per se, just opinions. Here's an ugly diagram of what I'm trying to achieve: [local Python app] <--ADVICE NEEDED HERE--> [hosted web server] So from above, I'm looking for the technology that will allow my l...
[ "Maybe paramiko could be a good solution for your problem. I used paramiko for some project I had half a year ago, here is the part of my code where I connected with another computer/server and executed a simple python file:\nimport paramiko\n\nssh = paramiko.SSHClient()\nssh.set_missing_host_key_policy(paramiko.Au...
[ 3, 1 ]
[]
[]
[ "networking", "python", "shared_hosting", "sockets" ]
stackoverflow_0008195228_networking_python_shared_hosting_sockets.txt
Q: Django Templates "for loops" not working correctly I'm trying to build template tags that take use a dictionary in settings.py to build a menu. I have this as part of my template. {% for menu_item in menu %} <li class="single-link"><a href="{{ menu_item.url }}" title="{{ menu_item.caption }}">{{ menu_item.cap...
Django Templates "for loops" not working correctly
I'm trying to build template tags that take use a dictionary in settings.py to build a menu. I have this as part of my template. {% for menu_item in menu %} <li class="single-link"><a href="{{ menu_item.url }}" title="{{ menu_item.caption }}">{{ menu_item.caption }}</a></li> {% endfor %} The context passed to thi...
[ "In Django templates, as in standard Python, using for on a dictionary just loops through the keys. You need to use the .items() method:\n{% for key, value in menu.items %}\n <li class=\"single-link\"><a href=\"{{ value.url }}\" title=\"{{ value.caption }}\">{{ value.caption }}</a></li>\n{% endfor %}\n\n(Althoug...
[ 8, 1 ]
[]
[]
[ "dictionary", "django", "python" ]
stackoverflow_0008196630_dictionary_django_python.txt
Q: showing a filled combobox in modelform that is filtered by a pk I have these models: class LocationType(models.Model): Name=models.CharField(max_length=50) Description=models.CharField(max_length=200) class Location(models.Model): Name=models.CharField(max_length=100) ParentCode=models.BigIntegerFiel...
showing a filled combobox in modelform that is filtered by a pk
I have these models: class LocationType(models.Model): Name=models.CharField(max_length=50) Description=models.CharField(max_length=200) class Location(models.Model): Name=models.CharField(max_length=100) ParentCode=models.BigIntegerField() LocationType=models.ForeignKey(LocationType) class Visa(mode...
[ "Something on the lines of:\nclass VisaForm(ModelForm):\n def __init__(self, location_type, *args, **kwargs):\n super(VisaForm, self).__init__(*args, **kwargs)\n self.fields['Country'] = forms.ModelChoiceField(queryset=Location.objects.filter(LocationType=location_type))\n\n class Meta:\n ...
[ 3, 1 ]
[]
[]
[ "django", "python" ]
stackoverflow_0008195915_django_python.txt
Q: Fastest way to get data from server up to Javascript So the program I'm working on give the user possibility to view different Javascript implemented graphical representation (using WebGL, JIT etc.) of various data. The server side is written in python, and uses cherrypy with genshi + buffet. The problem is that ...
Fastest way to get data from server up to Javascript
So the program I'm working on give the user possibility to view different Javascript implemented graphical representation (using WebGL, JIT etc.) of various data. The server side is written in python, and uses cherrypy with genshi + buffet. The problem is that many of the files are really big and the time it takes for...
[ "Use the staticdir tool. See http://docs.cherrypy.org/dev/progguide/files/static.html#serving-files-through-the-staticdir-tool\n" ]
[ 0 ]
[]
[]
[ "cherrypy", "javascript", "python" ]
stackoverflow_0008182528_cherrypy_javascript_python.txt
Q: Error using lxml library to parse xml in Python I am not able to use the pretty_print argument to print the xml. Any idea what could be wrong ? I am attaching the code sample as well. Thanks import xml.etree.cElementTree as etree import os def main(): root = etree.Element("root") Series = etree.SubEle...
Error using lxml library to parse xml in Python
I am not able to use the pretty_print argument to print the xml. Any idea what could be wrong ? I am attaching the code sample as well. Thanks import xml.etree.cElementTree as etree import os def main(): root = etree.Element("root") Series = etree.SubElement(root, "Element") SeriesID = etree.SubElement...
[ "xml.etree.ElementTree.tostring() does not have a pretty_print parameter.\nlxml.etree.tostring() on the other hand has a pretty_print parameter.\n" ]
[ 1 ]
[]
[]
[ "lxml", "pretty_print", "python", "xml" ]
stackoverflow_0008197017_lxml_pretty_print_python_xml.txt
Q: Parsing Content With Beautiful Soup Between Two Closing Tags I'm using BeautifulSoup to parse the contents of a webpage with Artist and Album info. I have parsed the information down to this: `<span dir="ltr"><a href="unique?id=1234">Jay-Z</a> &amp; <a href="unique?id" = 321">Kanye West</a> - Watch the Throne</spa...
Parsing Content With Beautiful Soup Between Two Closing Tags
I'm using BeautifulSoup to parse the contents of a webpage with Artist and Album info. I have parsed the information down to this: `<span dir="ltr"><a href="unique?id=1234">Jay-Z</a> &amp; <a href="unique?id" = 321">Kanye West</a> - Watch the Throne</span>` The album name (in this case "Watch the Throne") is always be...
[ ">>> from BeautifulSoup import BeautifulSoup\n>>> html = '''<span dir=\"ltr\"><a href=\"unique?id=1234\">Jay-Z</a> &amp; \n... <a href=\"unique?id\" = 321\">Kanye West</a> - Watch the Throne</span>'''\n>>> soup = BeautifulSoup(html)\n>>> soup.span.contents[-1].strip('- ')\nu'Watch the Throne'\n\n", "If i understa...
[ 1, 0, 0 ]
[]
[]
[ "beautifulsoup", "html", "parsing", "python" ]
stackoverflow_0008196863_beautifulsoup_html_parsing_python.txt
Q: Exception AttributeError message when using manage.py in django-nonrel for Google app engine I'm using Python 2.7 and django-nonrel for running Django projects on Google app engine. I'm using version 1.6 of the Google app engine SDK. I run python manage.py syncdb or python manage.py deploy. After the command compl...
Exception AttributeError message when using manage.py in django-nonrel for Google app engine
I'm using Python 2.7 and django-nonrel for running Django projects on Google app engine. I'm using version 1.6 of the Google app engine SDK. I run python manage.py syncdb or python manage.py deploy. After the command completes I get the following message: Exception AttributeError: "'NoneType' object has no attribute 'm...
[ "It has already been reported. \nSee this.\nApparently, it doesn't break anything.\nAs you can see, the answer is:\n\"Dont worry, just ignore it\"\n", "GAE 1.6.0 doesnt work for me too, 1.5.2 does.\n" ]
[ 2, 1 ]
[]
[]
[ "django", "django_nonrel", "google_app_engine", "python" ]
stackoverflow_0008112775_django_django_nonrel_google_app_engine_python.txt
Q: PyObjC Not Working I've installed PyObjC on my Mac, but I can't get it to work at all. Even trying to import the AddressBook class just fails immediately. Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license...
PyObjC Not Working
I've installed PyObjC on my Mac, but I can't get it to work at all. Even trying to import the AddressBook class just fails immediately. Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. ...
[ "You appear to have a conflicting file named AddressBook.py in your working directory. Rename or remove it or change to another directory.\n" ]
[ 2 ]
[]
[]
[ "macos", "pyobjc", "python" ]
stackoverflow_0008197423_macos_pyobjc_python.txt
Q: Questions about Django urls.py Basically, I'm writing blog software using Django/Python. Currently I have the following files urls.py: from django.conf.urls.defaults import * from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Example: # (r'^sovietware/', include('sovietwa...
Questions about Django urls.py
Basically, I'm writing blog software using Django/Python. Currently I have the following files urls.py: from django.conf.urls.defaults import * from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Example: # (r'^sovietware/', include('sovietware.foo.urls')), # Uncomment the...
[ "I'm not sure what your / url returns as far as data, but if you want all of the patterns in your blog app to start with \"blog\" in the URL, you can add that to the pattern in your root urls.py when you do the include:\n(r'^blog/', include('sovietware.blog.urls')),\n\n", "In your main urls.py, rename urlpatterns...
[ 1, 0 ]
[]
[]
[ "django", "django_urls", "python" ]
stackoverflow_0008197317_django_django_urls_python.txt
Q: Python Removing Letters From a String This is a homework assignment. I just need a nudge. I'm trying to create a loop in which the letters of a string will be removed when it is beyond a certain number. Example: Enter Your String: David Enter Your Amount: 4 Returns: Davi What I've made so far: word = raw_input("E...
Python Removing Letters From a String
This is a homework assignment. I just need a nudge. I'm trying to create a loop in which the letters of a string will be removed when it is beyond a certain number. Example: Enter Your String: David Enter Your Amount: 4 Returns: Davi What I've made so far: word = raw_input("Enter your string:") amount = raw_input("Ent...
[ "A string itself in Python is immutable -- it cannot be changed and letters cannot be deleted. But you can create new string objects based on your string. One way of doing so is slicing.\nRead through the linked section of the official Python tutorial until you find what you need. :)\nEdit: If you need to use a l...
[ 5, 3, 2, 0, 0, 0 ]
[]
[]
[ "letters", "python", "string" ]
stackoverflow_0008197674_letters_python_string.txt
Q: SMTPHandler in Python's logging module sending emails one at a time. How can I stop this? I'm attempting to use Python's logging module to send emails containing logs. The problem that I'm having is that each time I write a log entry, an email is sent. How do I queue the log messages and send a single email at t...
SMTPHandler in Python's logging module sending emails one at a time. How can I stop this?
I'm attempting to use Python's logging module to send emails containing logs. The problem that I'm having is that each time I write a log entry, an email is sent. How do I queue the log messages and send a single email at the conclusion of the script? I have a feeling that it's done with the emit() method, but I can...
[ "See this answer which I gave for a similar question. An example handler to use is here; you can adapt it to your requirements. \n", "Simply subclass SMTPHandler in order to produce the wanted behavior.\nyou could for example override the emit method in order to send a mail on every third logged message\nCaution:...
[ 11, 2 ]
[]
[]
[ "logging", "python" ]
stackoverflow_0008191721_logging_python.txt
Q: Python string equality test delivers inconsistent results The following function is used in a script to create a static version of a Django site: def write_file(filename, content): filename = '{0}{1}.html'.format(BASEDIR, filename) if os.path.exists(filename): existing_file = io.open(filename, enco...
Python string equality test delivers inconsistent results
The following function is used in a script to create a static version of a Django site: def write_file(filename, content): filename = '{0}{1}.html'.format(BASEDIR, filename) if os.path.exists(filename): existing_file = io.open(filename, encoding='utf-8') existing_content = existing_file.read() ...
[ "What you describe is symptomatic of data getting encoded twice somewhere in the process or text being compared to unicode. In Python 2.x, abc` == u`abc so some files that contain only ASCII will pass the comparison test with the other half of your files have non-ascii characters won't be the same before and after...
[ 0, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008197773_python.txt
Q: Testing specific apps in Django As far as I know, it is possible to run tests for either all installed apps or a single app. Testing all apps seem to be as an overkill as it usually contains also Django's native modules (django.contrib.auth etc). Is it possible to create a test suite containing only apps I specify...
Testing specific apps in Django
As far as I know, it is possible to run tests for either all installed apps or a single app. Testing all apps seem to be as an overkill as it usually contains also Django's native modules (django.contrib.auth etc). Is it possible to create a test suite containing only apps I specify (which would cointain all tests from...
[ "you could write a custom test runner that only tests your apps. in the past i've used something like \ntests/runner.py:\nfrom django.test.simple import DjangoTestSuiteRunner\nfrom django.conf import settings\n\nclass AppsTestSuiteRunner(DjangoTestSuiteRunner):\n \"\"\" Override the default django 'test' command...
[ 6, 1, 1 ]
[]
[]
[ "django", "python", "unit_testing" ]
stackoverflow_0008194023_django_python_unit_testing.txt
Q: Cherrypy form validation What do most cherrypy developers do for server side form validation? I've done a google but nothing jumped out as "the one way to do it". A: You may write a tool and use it as decorator Or you can use my Validation decorator: import re from simplejson import JSONDecoder from simplejson....
Cherrypy form validation
What do most cherrypy developers do for server side form validation? I've done a google but nothing jumped out as "the one way to do it".
[ "You may write a tool and use it as decorator\nOr you can use my Validation decorator:\nimport re\nfrom simplejson import JSONDecoder\nfrom simplejson.decoder import JSONDecodeError\n#from cherrypy._cperror import HTTPError\nfrom decimal import Decimal\n\nclass ValidationException(Exception):\n pass \n\nclass Ar...
[ 6 ]
[]
[]
[ "cherrypy", "decorator", "python", "validation", "web" ]
stackoverflow_0008197744_cherrypy_decorator_python_validation_web.txt
Q: XML CSV convert with Python I want to make a command line program that will hopefully work on both Windows and Linux. I want to use Python since it is my programming language of choice. The goal is the make the program take file name as an argument, and output the information from the file in a different format....
XML CSV convert with Python
I want to make a command line program that will hopefully work on both Windows and Linux. I want to use Python since it is my programming language of choice. The goal is the make the program take file name as an argument, and output the information from the file in a different format. In this case XML -> CSV and CSV...
[ "You would be better-off converting XML to JSON and back. Both formats support multiple layers of nesting. In contrast, CSV is suited for a list of rows with no additional nesting.\n", "You should just convert the data into standard python dict, and then from that to any format you need.\nOf course, to convert ...
[ 1, 0 ]
[]
[]
[ "csv", "file_conversion", "python", "xml" ]
stackoverflow_0008196399_csv_file_conversion_python_xml.txt
Q: PyCurl Install not successful While trying to install pycurl in my system (MAC OS X), I am getting the following error. No idea how to solve it. Please help !!! nsh$ sudo easy_install pycurl Searching for pycurl Reading http://pypi.python.org/simple/pycurl/ Reading http://pycurl.sourceforge.net/ Rea...
PyCurl Install not successful
While trying to install pycurl in my system (MAC OS X), I am getting the following error. No idea how to solve it. Please help !!! nsh$ sudo easy_install pycurl Searching for pycurl Reading http://pypi.python.org/simple/pycurl/ Reading http://pycurl.sourceforge.net/ Reading http://pycurl.sourceforge.net/...
[ "Try to use:\n# sudo env ARCHFLAGS=\"-arch i386 -arch x86_64\" pip install pycurl\n\nBut before that, install Xcode. Now it's free.\n", "Perhaps you should try installing gcc-4.2?\n", "This might work, depending on whether or not you actually have gcc-4.2 installed.\ncd /usr/bin\nln -s gcc gcc-4.2\n\nIf that do...
[ 6, 1, 0 ]
[]
[]
[ "macos", "pycurl", "python", "python_2.6" ]
stackoverflow_0007252480_macos_pycurl_python_python_2.6.txt
Q: django specifying multiple labels By default, when a form is created in django using ModelForm, the labels for each field are basically the name of each field with the first letter capitalized. However, I want to write my own labels for each of the fields instead of using the default ones. Is there a shortcut for ...
django specifying multiple labels
By default, when a form is created in django using ModelForm, the labels for each field are basically the name of each field with the first letter capitalized. However, I want to write my own labels for each of the fields instead of using the default ones. Is there a shortcut for doing that?
[ "Yes, add verbose_name to the field definition.\n" ]
[ 2 ]
[]
[]
[ "django", "label", "modelform", "python" ]
stackoverflow_0008198573_django_label_modelform_python.txt
Q: Where should an absolute beginning programmer start? Yea, I own a couple of Python, C++ and Java books. I'm 16 and pretty interested in programming, but I am kind of lost on where to start to get an idea of the basics. I want to know the in's and out's of programming. Any book and programming language recommendati...
Where should an absolute beginning programmer start?
Yea, I own a couple of Python, C++ and Java books. I'm 16 and pretty interested in programming, but I am kind of lost on where to start to get an idea of the basics. I want to know the in's and out's of programming. Any book and programming language recommendations? My only current experience is HTML (but that isn't re...
[ "Follow these Google Python Class. Trust me, best way to begin, really! Video lectures, exercises, it's all in there and teached by the best: Nick Parlante\nI followed those classes after knowing Python (quite well) and I still learned a lot!\n" ]
[ 5 ]
[]
[]
[ "python" ]
stackoverflow_0008198234_python.txt
Q: Python Interpreter in Emacs repeats lines What is happening: >>> 2 * 10 2 * 10 20 >>> What I want to happen: >>> 2 * 10 20 >>> Does anyone know why the command is printed out before being executed and how to stop it from doing that? I can't find any documentation about this. I'm using Emacs 23 on Mac OS X with...
Python Interpreter in Emacs repeats lines
What is happening: >>> 2 * 10 2 * 10 20 >>> What I want to happen: >>> 2 * 10 20 >>> Does anyone know why the command is printed out before being executed and how to stop it from doing that? I can't find any documentation about this. I'm using Emacs 23 on Mac OS X with Python 2.7.
[ "I don't use python, but I would guess that the python feature you are using has set the variable comint-process-echoes incorrectly. Whatever the value in your buffer is, just reverse the boolean value.\nComint is a support library in Emacs for running inferior processes in Emacs. It interacts with the prompts, a...
[ 11 ]
[]
[]
[ "emacs", "python" ]
stackoverflow_0008060609_emacs_python.txt
Q: How do I get multiple values from checkboxes in Django I want to get values of a multiple select check box using request.POST['xzy'] as a list. Here is my model and template code. My Model class Recommend(models.Model): user=models.ForeignKey(User) book=models.ForeignKey(BookModel) friends=models.ManyToManyF...
How do I get multiple values from checkboxes in Django
I want to get values of a multiple select check box using request.POST['xzy'] as a list. Here is my model and template code. My Model class Recommend(models.Model): user=models.ForeignKey(User) book=models.ForeignKey(BookModel) friends=models.ManyToManyField(User, related_name="recommended") My Template {% for f...
[ "request.POST.getlist('recommendations')\n\n", "if not request.POST.has_key(strName):\n return \"\" \n if request.POST[strName]:\n return ','.join(request.POST.getlist(strName)) \n else:\n return \"\"\n\n" ]
[ 122, 2 ]
[]
[]
[ "checkbox", "django", "django_models", "python" ]
stackoverflow_0004359238_checkbox_django_django_models_python.txt
Q: Parallelizing reads from MySQL database via Python I need to read data from a huge table (>1million rows, 16 cols of raw text) and do some processing on it. Reading it row by row seems very slow (python, MySQLdb) indeed and I would like to be able to read multiple rows at a time (possibly parallelize it). Just FY...
Parallelizing reads from MySQL database via Python
I need to read data from a huge table (>1million rows, 16 cols of raw text) and do some processing on it. Reading it row by row seems very slow (python, MySQLdb) indeed and I would like to be able to read multiple rows at a time (possibly parallelize it). Just FYI, my code currently looks something like this: cursor.e...
[ "The LIMIT clause can take two parameters, where the first is the start row and the second is the row count.\nSELECT ...\n ...\nLIMIT 200000,200000\n\n", "You may also run into i/o contention on the DB server (even though you are getting the data in chunks, the disks need to serialize the reads at some level). So...
[ 2, 1, 0 ]
[]
[]
[ "mysql_python", "parallel_processing", "python" ]
stackoverflow_0008198705_mysql_python_parallel_processing_python.txt