content
stringlengths
85
101k
title
stringlengths
0
150
question
stringlengths
15
48k
answers
list
answers_scores
list
non_answers
list
non_answers_scores
list
tags
list
name
stringlengths
35
137
Q: Python load multiple objects into mapping to use in memcache This code works: for num in range(1,4): results = memcache.get("link_" + str(num)) output.write('An anonymous person wrote: <blockquote>%s</blockquote>' % results.date) return output.getvalue() This code is not working: results...
Python load multiple objects into mapping to use in memcache
This code works: for num in range(1,4): results = memcache.get("link_" + str(num)) output.write('An anonymous person wrote: <blockquote>%s</blockquote>' % results.date) return output.getvalue() This code is not working: results = memcache.get_multi(linkKeys,"link_") for results in results: ...
[ "for result*s* in result*s* ??\n", "memcache can only store pickleable objects. Can you safely pickle a GqlQuery result? If not, you may need to convert it to a dict first before handing it off to memcache.\nSee the pickle docs and probably the relevant GAE docs.\nYou may also want to benchmark this and see if us...
[ 1, 0 ]
[]
[]
[ "mapping", "memcached", "python" ]
stackoverflow_0005235422_mapping_memcached_python.txt
Q: Sum in html template using template tag I am trying to sum in HTML,but template tag return 0 , View.py def gen_Report(request): ### query returns below output list=[{'total': 1744, 'user': u'x'}, {'total': 13, 'user': u'y'}, {'total': 126, 'user': u'z'}, {'total': 46, 'user': u'm'}, {'total': 4, 'user': u'n'}, {...
Sum in html template using template tag
I am trying to sum in HTML,but template tag return 0 , View.py def gen_Report(request): ### query returns below output list=[{'total': 1744, 'user': u'x'}, {'total': 13, 'user': u'y'}, {'total': 126, 'user': u'z'}, {'total': 46, 'user': u'm'}, {'total': 4, 'user': u'n'}, {'total': 8, 'user': u'o'}, {'total': 3, 'use...
[ "Your template tag looks wrong. You have role_total as the parameter and then iterate through list_total (seemingly undefined) and from each dictionary in the list try getting the key list_sum which is also seemingly undefined.\nfrom django.template import Library\nregister = Library()\n@register.filter\ndef runni...
[ 7, 2 ]
[]
[]
[ "django", "django_template_filters", "django_templates", "python" ]
stackoverflow_0005275639_django_django_template_filters_django_templates_python.txt
Q: a way to use Paramiko ssh / scp functionality from Unix to Windows or Windows to Windows? is there a way to use Python paramiko package in order to scp or ssh from Unix to Windows or from Windows to Windows ? It works very well from Windows to Unix and from Unix to Unix but not for the other configurations. My cod...
a way to use Paramiko ssh / scp functionality from Unix to Windows or Windows to Windows?
is there a way to use Python paramiko package in order to scp or ssh from Unix to Windows or from Windows to Windows ? It works very well from Windows to Unix and from Unix to Unix but not for the other configurations. My code is client = SSHClient() client.set_missing_host_key_policy(AutoAddPolicy()) client.con...
[ "Windows socket error 10061 means : no connection, target machine actively refused it.\n- Is your SSH server running (are you using OpenSSH ?)\n- Try to disable your firewall\n" ]
[ 2 ]
[]
[]
[ "networking", "paramiko", "python", "scp", "ssh" ]
stackoverflow_0005275949_networking_paramiko_python_scp_ssh.txt
Q: Create functions within classes in google app engine? I was trying to include my own functions in mainpage class, but when calling them it's not working at all, so what i did is to create a class for it and included that function in it. and in get () of mainpage class i created an instance for that class and calle...
Create functions within classes in google app engine?
I was trying to include my own functions in mainpage class, but when calling them it's not working at all, so what i did is to create a class for it and included that function in it. and in get () of mainpage class i created an instance for that class and called the function like object_name.function name() but it ain'...
[ "A python instance method needs to accept at least one parameter, self. \"It's not working\" is a horrible explanation of a problem; if you'd read your tracebacks you'd see an error about .keygen() accepting 0 arguments with 1 provided.\nBut yes, there's no reason to encapsulate methods in a class if what you real...
[ 3, 0 ]
[]
[]
[ "class", "google_app_engine", "python" ]
stackoverflow_0005271008_class_google_app_engine_python.txt
Q: MoinMoin 1.9 programmatically creating page error: MoinMoin.PageEditor.AccessDenied: You are not allowed to edit this page! I am trying to create a new wiki page programmatically with MoinMoin. But it is not allowing me to edit the page, how do I provide a user to create this page as? [Fri Mar 11 11:44:35] [root]@...
MoinMoin 1.9 programmatically creating page error: MoinMoin.PageEditor.AccessDenied: You are not allowed to edit this page!
I am trying to create a new wiki page programmatically with MoinMoin. But it is not allowing me to edit the page, how do I provide a user to create this page as? [Fri Mar 11 11:44:35] [root]@[dev] /usr/local/share/moin # python2.6 Python 2.6.5 (r265:79063, Jun 4 2010, 21:43:07) [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] ...
[ "You need to get a User and attach it to the ScriptContext object, here called request.\n>>> import MoinMoin.user\n>>> user = MoinMoin.user.get_by_email_address(request,'jarrod.roberson@mycompany.com')\n>>> request.user = user\n>>> pe = PageEditor(request, 'MyNewTestPage')\n>>> pe.saveText('Hello World!', 0)\n\nThe...
[ 2 ]
[]
[]
[ "moinmoin", "python" ]
stackoverflow_0005275856_moinmoin_python.txt
Q: Fast 'Record Update' To Binary Files? I have 3000 binary files (each of size 40[MB]) of known format (5,000,000 'records' of 'int32,float32' each). they were created using numpy tofile() method. A method that I use, WhichShouldBeUpdated(), determines which file (out of the 3000) should be updated, and also, which ...
Fast 'Record Update' To Binary Files?
I have 3000 binary files (each of size 40[MB]) of known format (5,000,000 'records' of 'int32,float32' each). they were created using numpy tofile() method. A method that I use, WhichShouldBeUpdated(), determines which file (out of the 3000) should be updated, and also, which records in this file should be changed. The...
[ "Since the records are of fixed length you can just open the file and seek to the position, which is a multiple of the record size and record offset. To encode the ints and floats as binary you can use struct.pack. Update: Given that the files are originally generated by numpy, the fastest way may be numpy.memmap....
[ 7, 1 ]
[]
[]
[ "binary", "linux", "numpy", "python" ]
stackoverflow_0005268850_binary_linux_numpy_python.txt
Q: How to annotate/highlight a 3d plot in MatPlotLib I would like to do something like this: http://matplotlib.sourceforge.net/_images/86cbd17f31.png in a 3d space. Basically I want to highlight a portion of a surface plot. Any suggestions? A: edit3 (this replaces a very mis-guided previous answer) updated again. ...
How to annotate/highlight a 3d plot in MatPlotLib
I would like to do something like this: http://matplotlib.sourceforge.net/_images/86cbd17f31.png in a 3d space. Basically I want to highlight a portion of a surface plot. Any suggestions?
[ "edit3 (this replaces a very mis-guided previous answer)\nupdated again. See comment\nYou can modify the face colors of a surface plot if you drill down to the polygon collection that is generated by the plot. It does some magic shading and re-orders the list of colors depending on zorder so I had some trouble fi...
[ 8 ]
[]
[]
[ "matplotlib", "python" ]
stackoverflow_0005276303_matplotlib_python.txt
Q: lxml: How to make new Element tree from given element in a tree I am using lxml for parsing xml data. I have to divide the xml at various nodes and write the data in each of these subtrees to separate files. lxml provides the write() method in _ElementTree class which conveniently writes the xml represented by the...
lxml: How to make new Element tree from given element in a tree
I am using lxml for parsing xml data. I have to divide the xml at various nodes and write the data in each of these subtrees to separate files. lxml provides the write() method in _ElementTree class which conveniently writes the xml represented by the parse tree to a file. So if I can make tree (_ElementTree object) by...
[ "Sorry to bother, I found the answer. Its:\nnew_tree = etree.ElementTree(node_in_tree)\n\n", "You don't need to create a new ElementTree in order to write an element and its contents to a file, you can just write the result of etree.tostring(element), e.g.:\nfrom lxml import etree\n\nwith open(\"whatever.xml\") a...
[ 9, 4 ]
[]
[]
[ "lxml", "python" ]
stackoverflow_0005276555_lxml_python.txt
Q: How do I execute python programs in a Google Chrome extension I have a python program and I need to call this code using JavaScript since I am using chrome extension. So is there any way that we can call python code in java script and execute them i.e if I click the plug-in the manifest.json file should have an ex...
How do I execute python programs in a Google Chrome extension
I have a python program and I need to call this code using JavaScript since I am using chrome extension. So is there any way that we can call python code in java script and execute them i.e if I click the plug-in the manifest.json file should have an external command so that it calls python program and executes it and ...
[ "You can try Pyjamas. It's a Python-to-Javascript compiler.\n" ]
[ 0 ]
[]
[]
[ "google_chrome_extension", "javascript", "python" ]
stackoverflow_0005276652_google_chrome_extension_javascript_python.txt
Q: Python threads and daemons I'm working with daemons in python using the Sander's recipy. Till now has run fine, but I have to introduce some changes which are drilling my brain. The fact is: The Sander's daemon way of life creates a new instance of the object everytime you ask for it. Example: [prompt]> python my...
Python threads and daemons
I'm working with daemons in python using the Sander's recipy. Till now has run fine, but I have to introduce some changes which are drilling my brain. The fact is: The Sander's daemon way of life creates a new instance of the object everytime you ask for it. Example: [prompt]> python my_daemon.py start [prompt]> pytho...
[ "I'm not sure whether a new process would be necessary per-se, but it would probably be a lot cleaner to implement than having to carefully manage your way around the GIL, depending on the size of the tasks the daemon's threads execute, and whether they are pure-python, or can release the GIL by calling a foreign l...
[ 0, 0 ]
[]
[]
[ "daemon", "pthreads", "python" ]
stackoverflow_0005274669_daemon_pthreads_python.txt
Q: Cross-tabulation (contingency table) using Python ORM? Anyone doing very basic statistical explorations on data living in a relational database has had to calculate cross tabulations,also known as contingency tables(wikipedia page). these are indispensable when you need to count how many items fall more than one c...
Cross-tabulation (contingency table) using Python ORM?
Anyone doing very basic statistical explorations on data living in a relational database has had to calculate cross tabulations,also known as contingency tables(wikipedia page). these are indispensable when you need to count how many items fall more than one category at the same time. For example: How many customers ar...
[ "I hate to have to answer my own question, but sometimes we just can't wait for help. And since I have found the answer and a good one, I feel obliged to share with the community. So here it is:\ntable = self.session.query(Table.var1, Table.var2, func.count(Table)).group_by(Table.var1, Table.var2).all()\n\nThis wil...
[ 2 ]
[]
[]
[ "orm", "pivot_table", "python", "sql", "sqlalchemy" ]
stackoverflow_0005273397_orm_pivot_table_python_sql_sqlalchemy.txt
Q: Associating a Google App Engine custom subdomain with a user I have an application running on GAE, and would like to allow the user to use a subdomain on their own google app domain (e.g. myapp.example.com) to host their own customized version of my app. It's easy to add the subdomain... just add the app by id on ...
Associating a Google App Engine custom subdomain with a user
I have an application running on GAE, and would like to allow the user to use a subdomain on their own google app domain (e.g. myapp.example.com) to host their own customized version of my app. It's easy to add the subdomain... just add the app by id on their Google app, and assign it a custom subdomain. But since I wa...
[ "This is tough. You could use the Apps Marketplace, and you're right that it would allow you to solicit configuration information from admins before setting it up. That's likely your best option, and also allows you to expose your app to more users, as well as making single-signin possible.\nIf you don't want to do...
[ 0 ]
[]
[]
[ "dns", "google_app_engine", "google_apps", "python", "subdomain" ]
stackoverflow_0005270303_dns_google_app_engine_google_apps_python_subdomain.txt
Q: Python: except EOFError: ... doesn't work I have a try/except block that sends a message and waits for confirmation from client. If the client terminates, pickle raises an EOFError, but the code below does not catch the error and execute the graceful shut down. It instead prints stack trace. I assume it has to do ...
Python: except EOFError: ... doesn't work
I have a try/except block that sends a message and waits for confirmation from client. If the client terminates, pickle raises an EOFError, but the code below does not catch the error and execute the graceful shut down. It instead prints stack trace. I assume it has to do with the line "except socket.error, EOFError:" ...
[ "In Python 2.x, the form except a, b catches an exception of type a and assign it to a variable called b. In your case this would result in EOFError being ignored. Try this instead:\n...\nexcept (socket.error, EOFError):\n ...\n\nEdit: to elaborate, the new syntax in Python 3.0, and available, though not requi...
[ 2, 0 ]
[]
[]
[ "eoferror", "exception_handling", "python" ]
stackoverflow_0005277277_eoferror_exception_handling_python.txt
Q: Loop line by line and wall clock time with a Python Filter I have a simple loop like: #Core Loop chunk_size=1000 while True: line_c = 0 chunk_array = [] while True: line = sys.stdin.readline() line_c +=1 m = line_regex.match(line) if m: chunk_array.append...
Loop line by line and wall clock time with a Python Filter
I have a simple loop like: #Core Loop chunk_size=1000 while True: line_c = 0 chunk_array = [] while True: line = sys.stdin.readline() line_c +=1 m = line_regex.match(line) if m: chunk_array.append(m.groupdict()) if line_c >= chunk_size: #pr...
[ "Do this\nimport time\ndef time_chunk( some_source, period=10 ):\n start= time.time()\n buffer= []\n for line in some_source:\n buffer.append( line )\n if time.time() - start >= period:\n start= time.time()\n yield buffer\n buffer= []\n yield buffer\n\nfor ...
[ 2, 1 ]
[]
[]
[ "filter", "python" ]
stackoverflow_0005276551_filter_python.txt
Q: How can I get Mercurial to push commits again? I'm not aware that I changed anything and am running Ubuntu 10.10. Mercurial had been working fine and then all of a sudden when I started pushing commits this morning I started receiving the following error: ** unknown exception encountered, details follow ** report ...
How can I get Mercurial to push commits again?
I'm not aware that I changed anything and am running Ubuntu 10.10. Mercurial had been working fine and then all of a sudden when I started pushing commits this morning I started receiving the following error: ** unknown exception encountered, details follow ** report bug details to http://mercurial.selenic.com/bts/ ** ...
[ "I ran hg verify as Dan D. mentioned and ended up erasing my local repo and re-cloned it. This got me back on track.\n", "This is a typical stacktrace from a corrupted server. The last (1.8) release helps having better error messages in that case.\n" ]
[ 2, 1 ]
[]
[]
[ "bitbucket", "mercurial", "python" ]
stackoverflow_0004377880_bitbucket_mercurial_python.txt
Q: why use wsgiref simple_server? I have a simple webapp to build, and I am just beginning to mess around with mod_wsgi. In various tutorials, the first hello world app looks something like the following: def application(environ,start_response): response_body = 'Hello World' status = '200 OK' response_heade...
why use wsgiref simple_server?
I have a simple webapp to build, and I am just beginning to mess around with mod_wsgi. In various tutorials, the first hello world app looks something like the following: def application(environ,start_response): response_body = 'Hello World' status = '200 OK' response_headers = [('Content-Type', 'text/plain')...
[ "I would guess the tutorial assumes you do not have mod_wsgi set up and running. This way you can run the script from the command line and it will start the wsgiref server running the application so that you can test it without having to install Apache and mod_wsgi.\n" ]
[ 8 ]
[]
[]
[ "mod_wsgi", "python", "wsgi", "wsgiref" ]
stackoverflow_0005277448_mod_wsgi_python_wsgi_wsgiref.txt
Q: how to change the test description of python (2.7) untitest It seems that the unittest module has been changed a lot in Python 2.7 I have a test case: class DemoTest(unittest.TestCase): def test_foo(self): """Test foo""" pass The console output is: Test foo ... ok After upgrading to Python 2.7, the ...
how to change the test description of python (2.7) untitest
It seems that the unittest module has been changed a lot in Python 2.7 I have a test case: class DemoTest(unittest.TestCase): def test_foo(self): """Test foo""" pass The console output is: Test foo ... ok After upgrading to Python 2.7, the console output is now: test_foo (testcase.demotest.DemoTest) Test...
[ "Given that you've taken the trouble to write docstrings for your test, the extra output looks a bit redundant. Below is one way it could be suppressed; you'd need to add this to the top of your test file:\nfrom unittest.runner import TextTestResult\nTextTestResult.getDescription = lambda _, test: test.shortDescrip...
[ 5 ]
[]
[]
[ "docstring", "python", "unit_testing" ]
stackoverflow_0005274942_docstring_python_unit_testing.txt
Q: TypeError: not all arguments converted during string formatting I'm having a bit of trouble loading an CSV file into a mysql database. Here's my code: for q in csvReader: name, price, LastUpdate, today = q co.execute("""INSERT INTO fundata (name, price, LastUpdate) VALUES(name, price, LastUpdate);""",q) ...
TypeError: not all arguments converted during string formatting
I'm having a bit of trouble loading an CSV file into a mysql database. Here's my code: for q in csvReader: name, price, LastUpdate, today = q co.execute("""INSERT INTO fundata (name, price, LastUpdate) VALUES(name, price, LastUpdate);""",q) I get an error saying TypeError: not all arguments converted during s...
[ "If I recall correctly, you should use %s with MySQLdb in query to denote positions you want the argument tuple elements to be formatted. This is different from usual ? placeholders used in most other implementations.\nfor q in csvReader:\n name, price, LastUpdate, today = q\n co.execute(\"INSERT INTO fundata...
[ 15, 5, 1 ]
[]
[]
[ "mysql", "python" ]
stackoverflow_0005277679_mysql_python.txt
Q: how to find specific digit values in a text file of one column? for line in fname: fields = line.rstrip("\n").split() dc = refindall('0.8|0.9).group() samples = line sys.stdout.writelines(samples) I got another problem with finding a specific float(digit ( 0.8 and 0.9) value in each line of one col...
how to find specific digit values in a text file of one column?
for line in fname: fields = line.rstrip("\n").split() dc = refindall('0.8|0.9).group() samples = line sys.stdout.writelines(samples) I got another problem with finding a specific float(digit ( 0.8 and 0.9) value in each line of one column text file. Secondly, if it finds this line, it should be delet...
[ "You have a number of errors in your code:\n\nThere is a missing dot between re and findall.\nThe dot in the regular expression means \"match any character\".\nYour string is not terminated correctly because there is a missing quote.\nre.findall takes two parameters. You seem to be providing only one.\nre.findall r...
[ 4, 0 ]
[]
[]
[ "python" ]
stackoverflow_0005277887_python.txt
Q: Optimised Python dictionary / negative index storage Raised by this question's comments (I can see that this is irrelevant), I am now aware that using dictionaries for data that needs to be queried/accessed regularly is not good, speedwise. I have a situation of something like this: someDict = {} someDict[(-2, -2...
Optimised Python dictionary / negative index storage
Raised by this question's comments (I can see that this is irrelevant), I am now aware that using dictionaries for data that needs to be queried/accessed regularly is not good, speedwise. I have a situation of something like this: someDict = {} someDict[(-2, -2)] = something somedict[(3, -10)] = something else I am s...
[ "To start off with\n\nSpeed up dictionary lookups, so this would not be an issue\n\nDictionary lookups are pretty fast O(1), but (from your other question) you're not relying on the hash-table lookup of the dictionary, your relying on a linear search of the dictionary's keys.\n\nFind some kind of container that wil...
[ 2, 2, 1, 1, 0 ]
[]
[]
[ "dictionary", "indices", "optimization", "python" ]
stackoverflow_0005277704_dictionary_indices_optimization_python.txt
Q: Piping output from a python script to a remote machine? I have a python script that output/prints a large array (50MB in size) to the screen. This script is running on machineA. Is it at all possible to 'pipe' this output to machineB, where it will be processed? I know I can save the output in a file on machineA a...
Piping output from a python script to a remote machine?
I have a python script that output/prints a large array (50MB in size) to the screen. This script is running on machineA. Is it at all possible to 'pipe' this output to machineB, where it will be processed? I know I can save the output in a file on machineA and then send the file to machineB. I was just wondering if it...
[ "This is a work for nc (netcat)... on machineB you do\nnc -l 12345 | processing_program\n\nThis command will start netcat in \"listen mode\" waiting for a connection. Once the connection is established what is coming from the network will be sent to stdout and what is sent to stdin will be sent back to whoever conn...
[ 5, 1, 1, 1, 1 ]
[]
[]
[ "bash", "linux", "python", "shell" ]
stackoverflow_0005278044_bash_linux_python_shell.txt
Q: Backing up sqlite3 database in Python 2.5 I'm working on a project that needs to support both Python 2.5 and 2.6, and uses sqlite3. I'd like to be able to backup the database from within the program. It seems to be that there are two ways to do this: create a new database in sqlite3 and move all the data, or si...
Backing up sqlite3 database in Python 2.5
I'm working on a project that needs to support both Python 2.5 and 2.6, and uses sqlite3. I'd like to be able to backup the database from within the program. It seems to be that there are two ways to do this: create a new database in sqlite3 and move all the data, or simply copy the database file on the drive. My in...
[ "Copying a SQLite3 file that's currently in use may work 99% of the time, but it's not safe, as I learned the hard way. I mean, you could actually copy the DB file itself, but you have to be absolutely sure that all file handles to the DB file are closed, otherwise you risk precisely the situation you're concerned ...
[ 3, 0 ]
[]
[]
[ "python", "sqlite" ]
stackoverflow_0003265228_python_sqlite.txt
Q: Dijkstra - Nearest Neighbour Determination I have come unstuck in my determination of nearest neighbours in Dijkstra's algorithm. I am getting strange results as follows Firstly this is the contents of my network file, representing the distances between the 7 nodes: http://pastebin.com/PUM5qT6D (The numbers 1-7 in...
Dijkstra - Nearest Neighbour Determination
I have come unstuck in my determination of nearest neighbours in Dijkstra's algorithm. I am getting strange results as follows Firstly this is the contents of my network file, representing the distances between the 7 nodes: http://pastebin.com/PUM5qT6D (The numbers 1-7 in the first column aren't included) Now for my co...
[ "You're passing the method nearestNeighbour to tentativeDistance instead of the result of the method.\n", "This is the issue\ntentativeDistance(theNetwork, nodeTable, nearestNeighbour)\n\nshould be\n x = nearestNeighbour(nodeTable, theNetwork)\n tentativeDistance(theNetwork, nodeTable, x)\n\nTaking a look at the ...
[ 2, 1 ]
[]
[]
[ "dijkstra", "python" ]
stackoverflow_0005278158_dijkstra_python.txt
Q: How can I change a Python object into XML? I am looking to convert a Python object into XML data. I've tried lxml, but eventually had to write custom code for saving my object as xml which isn't perfect. I'm looking for something more like pyxser. Unfortunately pyxser xml code looks different from what I need. For...
How can I change a Python object into XML?
I am looking to convert a Python object into XML data. I've tried lxml, but eventually had to write custom code for saving my object as xml which isn't perfect. I'm looking for something more like pyxser. Unfortunately pyxser xml code looks different from what I need. For instance I have my own class Person Class Perso...
[ "Best is rather subjective and I'm not sure it's possible to say what's best without knowing more about your requirements. However Gnosis has previously been recommended for serializing Python objects to XML so you might want to start with that.\nFrom the Gnosis homepage:\n\nGnosis Utils contains several Python mod...
[ 2 ]
[ "Mike,\nyou can either implement object rendering into XML :\nclass Person:\n ...\n def toXml( self):\n print '<Person>'\n print '\\t<name>...</name>\n ...\n print '</Person>'\n\nor you can transform Gnosis or pyxser output using XSLT.\n" ]
[ -5 ]
[ "python", "xml", "xml_serialization" ]
stackoverflow_0003334446_python_xml_xml_serialization.txt
Q: Django: How do I get the model a model inherits from? Possible Duplicate: get python class parent(s) I have a: class Animal(models.Model): pass class Cat(Aminal): pass class StreetCat(Cat): pass How can I find out the model a model inherits from? A: You can get the direct superclass in python th...
Django: How do I get the model a model inherits from?
Possible Duplicate: get python class parent(s) I have a: class Animal(models.Model): pass class Cat(Aminal): pass class StreetCat(Cat): pass How can I find out the model a model inherits from?
[ "You can get the direct superclass in python through __base__\n>>> StreetCat.__base__ is Cat\n>>> True\n\n__bases__ will get you a tuple of all parent classes if you have multiple base classes class Foo(A, B)\n\nUpdate thanks to OP: the following django method does not retrieve abstract base classes, as technically...
[ 10 ]
[]
[]
[ "django", "python" ]
stackoverflow_0005278316_django_python.txt
Q: How to remove underscore('_') along with preceeding digits in first columns only I have been trying to remove underscore('_') with associated digits after it. This is the first row in my text file. JP_001033692.1_551 N -1 NO 99.5425% 0.0022875 I would like to remove "_551" from "JP_001033692.1_551" wit...
How to remove underscore('_') along with preceeding digits in first columns only
I have been trying to remove underscore('_') with associated digits after it. This is the first row in my text file. JP_001033692.1_551 N -1 NO 99.5425% 0.0022875 I would like to remove "_551" from "JP_001033692.1_551" without removing other items from the subsequent columns. Expected row would be...
[ "str.rpartition(sep)¶ will split the string on the last occurance of sep\n\n\n\ns = \"this_is_a_string\"\nsplit_s = s.rpartition('_')\nsplit_s\n\n\n\n('this_is_a', '_', 'string')\n\n\n\nsplit_s[0]\n\n\n\n'this_is_a'\n\n\n\n\n\n\n\n", "Does this do what you're looking for?\nre.sub(\"(?P<x>(_.*)?)_\\w*\",\"\\g<x>\"...
[ 1, 0, 0, 0 ]
[]
[]
[ "python", "python_3.x" ]
stackoverflow_0005277174_python_python_3.x.txt
Q: (Embedded?) Ruby/Python, existing XAMPP stack I've been plugging away for about a year and a bit now with PHP on my local XAMPP install. I've learned very much, but am now needing to expand my knowledge base with concern to other languages. So, I figured I'd try tackling Ruby/Python. Now, since I'm sticking to web...
(Embedded?) Ruby/Python, existing XAMPP stack
I've been plugging away for about a year and a bit now with PHP on my local XAMPP install. I've learned very much, but am now needing to expand my knowledge base with concern to other languages. So, I figured I'd try tackling Ruby/Python. Now, since I'm sticking to web application development, I would assume embedded R...
[ "Couldn't you just install ruby and python, and then use mod_rails and mod_wsgi? I do the same thing on my local machine (MacOS, though) and it works great - never tried it through XAMPP though. Some people have had luck with MAMP but it's a pain due to how they distribute it - you may have better luck with XAMPP...
[ 1 ]
[]
[]
[ "python", "ruby", "xampp" ]
stackoverflow_0005278619_python_ruby_xampp.txt
Q: Special End-line characters/string from lines read from text file, using Python I need to read lines from a text file but, where the 'end of line' caracter is not always \n or \x or a combination and may be any combination of characters like 'xyz' or '|', but the 'end of line' is always the same and known for each...
Special End-line characters/string from lines read from text file, using Python
I need to read lines from a text file but, where the 'end of line' caracter is not always \n or \x or a combination and may be any combination of characters like 'xyz' or '|', but the 'end of line' is always the same and known for each type of file. As the text file may be a big one and I have to keep performances and ...
[ "Obviously simplest would be to just read the whole thing and then call .split('|').\nHowever if that's undesirable because it requires you to read the whole thing into memory you might read in arbitrary chunks and perform the split on them. You could write a class that grabs another arbitrary chunk when the curre...
[ 2, 2, 1, 1 ]
[]
[]
[ "python" ]
stackoverflow_0005276837_python.txt
Q: Children of a DBus Object I'm trying to write a dbus object that exports users and have created my object at /path/to/users. This object has signals such as 'user-added', 'user-removed' etc. I then want to provide access to each of these users at /path/to/users/[a, b, c] for users a, b and c which will have some m...
Children of a DBus Object
I'm trying to write a dbus object that exports users and have created my object at /path/to/users. This object has signals such as 'user-added', 'user-removed' etc. I then want to provide access to each of these users at /path/to/users/[a, b, c] for users a, b and c which will have some methods for each user. My quest...
[ "The standard D-Bus Introspectable interface provides a method to introspect an object; the data returned by it includes a list of objects.\nMost D-Bus bindings, including dbus-python, implement Introspectable on the service-side for you; so your client should be able to call the Introspect method on the object at ...
[ 1 ]
[]
[]
[ "dbus", "python" ]
stackoverflow_0005268033_dbus_python.txt
Q: Ironpython and Sqlite I'm trying my hands on ironpython instead of working on python and thought about writing simple program to fetch data from sqlite database. I've scrolled some of old questions and google (it's not showing decent resutls these days). One more question how to create redistributable for ironpyth...
Ironpython and Sqlite
I'm trying my hands on ironpython instead of working on python and thought about writing simple program to fetch data from sqlite database. I've scrolled some of old questions and google (it's not showing decent resutls these days). One more question how to create redistributable for ironpython program if you're using ...
[ "May be here THE WEBSITE, TECHNICAL BLOG AND PROJECTS OF MICHAEL FOORD\n" ]
[ 2 ]
[]
[]
[ "ironpython", "python", "sqlite" ]
stackoverflow_0005278424_ironpython_python_sqlite.txt
Q: Tkinter button command activates upon running program? I'm trying to make a build retrieval form, and seem to have issues with the buttons... I'm a novice at Python/tkinter GUI programming (and GUI programming in general) and borrowed the skeleton of a Hello World app, and sorta built off that. In the code below, ...
Tkinter button command activates upon running program?
I'm trying to make a build retrieval form, and seem to have issues with the buttons... I'm a novice at Python/tkinter GUI programming (and GUI programming in general) and borrowed the skeleton of a Hello World app, and sorta built off that. In the code below, I've set the "command" option of my Browse button to call my...
[ "Make your event handler a lambda function, which calls your get_dir() with whatever arguments you want:\nxbBrowse = Button(frameN, text=\"Browse...\", font=fontReg, command=lambda : self.get_dir(xbPath))\n\n", "In the above code:\nxbBrowse = Button(frameN,text=\"Browse...\",font=fontReg,command=self.get_dir(xbPa...
[ 40, 20, 9 ]
[]
[]
[ "python", "tkinter", "user_interface" ]
stackoverflow_0003704568_python_tkinter_user_interface.txt
Q: pythonic way to map set of strings to integers Is there shorter way to do this? g_proptypes = { 'uint8' : 0 'sint8' : 1, 'uint16' : 2, 'sint16' : 3, 'uint32' : 4, ... # more strings } The dict is necessary as I'll have the string with me and need to find the corresponding integer. A: If you...
pythonic way to map set of strings to integers
Is there shorter way to do this? g_proptypes = { 'uint8' : 0 'sint8' : 1, 'uint16' : 2, 'sint16' : 3, 'uint32' : 4, ... # more strings } The dict is necessary as I'll have the string with me and need to find the corresponding integer.
[ "If you have your strings in an iterable you can do:\ng_proptypes = dict((string, i) for i, string in enumerate(string_list))\n\n", ">>> lst = ['uint8','sint8','unit16','sint16','uint32','etc']\n>>> g_proptypes = dict(map(reversed,enumerate(lst)))\n>>> g_proptypes\n{'sint16': 3, 'unit16': 2, 'uint8': 0, 'etc': 5,...
[ 6, 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0005243537_python.txt
Q: Fonts problem, when switching from wxPython 2.8 to 2.9 I recently switched to wxPython 2.9 from 2.8. I ran one of my programs with 2.9. Everything seems to have worked, except the portion of my code that dynamically resizes fonts. The line where I change the font size seems to be the root of the problem. Snippet:...
Fonts problem, when switching from wxPython 2.8 to 2.9
I recently switched to wxPython 2.9 from 2.8. I ran one of my programs with 2.9. Everything seems to have worked, except the portion of my code that dynamically resizes fonts. The line where I change the font size seems to be the root of the problem. Snippet: sw, sh = self.get_geom(opt='wh') font = wx.Font(s...
[ "family can be:\nwx.DECORATIVE, wx.DEFAULT,wx.MODERN, wx.ROMAN, wx.SCRIPT or wx.SWISS.\n\nthus you should use:\nfont = wx.Font(sw/10 , wx.DEFAULT, wx.NORMAL, wx.NORMAL)\n\n" ]
[ 1 ]
[]
[]
[ "fonts", "python", "wxpython" ]
stackoverflow_0005278884_fonts_python_wxpython.txt
Q: store html templates in docstrings? I am using Flask to write a web service for an internal app here at my work. Many of the web services URI's return HTML partials, and I am trying to figure out a clean way to store the html template strings. I don't want to put the template strings in separate files, since the...
store html templates in docstrings?
I am using Flask to write a web service for an internal app here at my work. Many of the web services URI's return HTML partials, and I am trying to figure out a clean way to store the html template strings. I don't want to put the template strings in separate files, since they are usually only a few lines long and I...
[ "I think its a bad plan.\nDocstrings are for documentation, the template is not documentation. Documentation is supposed to describe what the function is being used for. An HTML template is a poor substitute for that.\nYou can use multi-line strings to hold your template, and thats probably a good idea. You don't g...
[ 3, 0, 0 ]
[]
[]
[ "docstring", "flask", "python" ]
stackoverflow_0005278899_docstring_flask_python.txt
Q: Porting c++ to python code I want to convert this C++ code to Python v2: static unsigned char asConvCode[3] = {0xFC, 0xCF, 0xAB}; void asConv(char* str, int size) { int i = 0; for (i = 0; n< size; n++) { str[i] ^= asConvCode[n % 3]; } } tried to make like that: def asConv(self, data): ...
Porting c++ to python code
I want to convert this C++ code to Python v2: static unsigned char asConvCode[3] = {0xFC, 0xCF, 0xAB}; void asConv(char* str, int size) { int i = 0; for (i = 0; n< size; n++) { str[i] ^= asConvCode[n % 3]; } } tried to make like that: def asConv(self, data): asConvCode= [0xFC, 0xCF, 0xAB]...
[ "In Python, characters in strings are simply strings of length 1, not integers. So you must use this:\ndata[i] = chr(ord(data[i]) ^ asConvCode[i % 3])\n\nAlso, as I wrote in a comment, your return data is at the wrong indentation level, and will cause your function to return after processing the first character.\n"...
[ 2 ]
[]
[]
[ "c++", "python" ]
stackoverflow_0005279188_c++_python.txt
Q: ImproperlyConfigured: Error importing middleware django.middleware.common: "No module named _md5" I am running Apache2 on Ubuntu 9 with python 2.6.2 installed. I get the following error when I try to access a page on my django application: File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py...
ImproperlyConfigured: Error importing middleware django.middleware.common: "No module named _md5"
I am running Apache2 on Ubuntu 9 with python 2.6.2 installed. I get the following error when I try to access a page on my django application: File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 42, in load_middleware raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%...
[ "Try to append to python path you project directory and parent one\n\n\nsys.path.append('path_to_dynamicuddi_project')\nsys.path.append('path_to_dynamicuddi_parent_dir')\n\n\n", "I don't think this is a pathing issue, like the one here.\nI think it's finding the django.middleware.common module just fine and attem...
[ 1, 1, 0 ]
[]
[]
[ "apache", "django", "mod_wsgi", "python", "ubuntu" ]
stackoverflow_0004911289_apache_django_mod_wsgi_python_ubuntu.txt
Q: Accessing API objc constants and enums from python I am using pyobjc to add some needed OSX functionality to some random python software. I will need to access API-defined objc-land constants from python-land. An example of such constants lies far down in the NSRunningApplication page, specifically the three possi...
Accessing API objc constants and enums from python
I am using pyobjc to add some needed OSX functionality to some random python software. I will need to access API-defined objc-land constants from python-land. An example of such constants lies far down in the NSRunningApplication page, specifically the three possible values of NSApplicationActivationPolicy. For context...
[ "The Apple-supplied PyObjC predates some of the additions that were made to Cocoa in 10.6. NSRunningApplication is one of these additions, and so PyObjC doesn't know about it. You need to add some metadata to the AppKit BridgeSupport file at: /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/pytho...
[ 1 ]
[]
[]
[ "constants", "enums", "objective_c", "pyobjc", "python" ]
stackoverflow_0004106332_constants_enums_objective_c_pyobjc_python.txt
Q: Django-Piston and Python Client Vs Java Client I've built a web service using Django-Piston that allows for POST and GET requests. As part of testing I wrote a quick Python script. Using the script I can successfully do both types of requests; however, when a client written in Java attempts to do a POST I get an e...
Django-Piston and Python Client Vs Java Client
I've built a web service using Django-Piston that allows for POST and GET requests. As part of testing I wrote a quick Python script. Using the script I can successfully do both types of requests; however, when a client written in Java attempts to do a POST I get an error: "POST /api/service/ HTTP/1.1" 400 225 "-" "Apa...
[ "A little search would help you a lot. This was the first Google result.\nhttp://weblog.mattdorn.com/content/restful-web-apps-with-django-piston-and-ext-js/\n\nThe reason for the 400 errors is that\n ExtJS is appending a charset onto the\n Content-Type field, which causes\n piston to not interpret the\n Conten...
[ 2 ]
[]
[]
[ "apache", "django_piston", "java", "python" ]
stackoverflow_0005279425_apache_django_piston_java_python.txt
Q: Efficient math operations on parts of "sparse" numpy arrays I have the following challenge in a simulation for my PhD thesis: I need to optimize the following code: repelling_forces = repelling_force_prefactor * np.exp(-(height_r_t/potential_steepness)) In this code snippet 'height_r_t' is a real Numpy array and ...
Efficient math operations on parts of "sparse" numpy arrays
I have the following challenge in a simulation for my PhD thesis: I need to optimize the following code: repelling_forces = repelling_force_prefactor * np.exp(-(height_r_t/potential_steepness)) In this code snippet 'height_r_t' is a real Numpy array and 'potential_steepness' is an scalar. 'repelling_force_prefactor' i...
[ "masked arrays are implemented exactly for your purposes.\nPerformance is the same as Sven's answer:\nheight_r_t = np.ma.masked_where(repelling_force_prefactor == 0, height_r_t)\nrepelling_forces = np.ma.exp(-(height_r_t/potential_steepness))\n\nthe advantage of masked arrays is that you do not have to slice and ex...
[ 3, 2 ]
[]
[]
[ "arrays", "mask", "numpy", "python", "slice" ]
stackoverflow_0005276061_arrays_mask_numpy_python_slice.txt
Q: Triggering another model's data to change (M2M) based on this model Basically, I am trying to use data from one model to trigger a switch in another model. If my invoice object is linked with a file, I want the file to be "locked" (a boolean). I find that when I save the invoice, after linking it with a file, it d...
Triggering another model's data to change (M2M) based on this model
Basically, I am trying to use data from one model to trigger a switch in another model. If my invoice object is linked with a file, I want the file to be "locked" (a boolean). I find that when I save the invoice, after linking it with a file, it doesn't register that invoice_file.count() is > 0 - until the next time I ...
[ "Remove the following line:\nif self.invoice_file.count() > 0:\n\nIf you're going to do a database hit, you may as well do it by retrieving all of the files associated with an invoice. This should have the added benefit of retrieving a 'fresh' view of related objects.\nThe problem is probably deeper though. ManyToM...
[ 2 ]
[]
[]
[ "django", "django_models", "many_to_many", "python", "relationship" ]
stackoverflow_0005279728_django_django_models_many_to_many_python_relationship.txt
Q: conditional evaluation of source file in python Say I have a file that's only used in pre-production code I want to ensure it gets not run in production code- any calls out to it have to fail. This snippet at the top of the file doesn't work - it breaks the Python grammar, which specifies that return must take pla...
conditional evaluation of source file in python
Say I have a file that's only used in pre-production code I want to ensure it gets not run in production code- any calls out to it have to fail. This snippet at the top of the file doesn't work - it breaks the Python grammar, which specifies that return must take place in a function. if not __debug__: return None W...
[ "if not __debug__:\n raise RuntimeError('This module must not be run in production code.')\n\n", "Maybe split the non-production code out into a module which is conditionally imported from the main code?\nif __debug__:\n import non_production\n non_production.main()\n\nUpdated: Based on your comment, you...
[ 7, 4, 1, 1 ]
[]
[]
[ "python" ]
stackoverflow_0005227292_python.txt
Q: python class with many attributes I am trying to create a class with lots of attributes (about 10). Is there a prettier (more Pythonic) way to initiate the class than: class myClass: def __init__(self,atributeA,atributeB,atributeC) self.atributeA=atributeA self.atributeB=atributeB self.atributeC=atributeC...
python class with many attributes
I am trying to create a class with lots of attributes (about 10). Is there a prettier (more Pythonic) way to initiate the class than: class myClass: def __init__(self,atributeA,atributeB,atributeC) self.atributeA=atributeA self.atributeB=atributeB self.atributeC=atributeC and is there a better way to make a c...
[ "Well, you could use keyword arguments. It would be as simple as:\nthisInstance=myClass(atributeA=valueA, atributeB=valueB, atributeC=valueC)\n\nOne of the advantages of this is that you can pass the values in any order you want.\nYou don't even have to modify the class definition at all.\n", "You can use the fol...
[ 2, 2, 1, 0 ]
[]
[]
[ "class", "python" ]
stackoverflow_0005279855_class_python.txt
Q: Running bunch of python methods on a single piece of data I would like to run a set of methods given some data. I was wondering how I can remove or chose to run different methods to be run. I would like to groups them within a larger method so I can call it; and it will go along the lines of test case. In code: N...
Running bunch of python methods on a single piece of data
I would like to run a set of methods given some data. I was wondering how I can remove or chose to run different methods to be run. I would like to groups them within a larger method so I can call it; and it will go along the lines of test case. In code: Now these are the methods that process the data. I may sometimes...
[ "Send the methods you want to run as a parameter:\ndef runmethods(self, variables, methods):\n for method in methods:\n method(variables)\n\nthen call something like:\nself.runmethods(variables, (method1, method2))\n\nThis is the nice thing of having functions as first-class objects in Python\nFor the quest...
[ 4, 2, 1 ]
[]
[]
[ "methods", "python" ]
stackoverflow_0005279952_methods_python.txt
Q: Getting Twitter news feed using Python Hey everybody, I've been playing around with Python 2.7 and BeautifulSoup 3.2 recently and I've gotten my code to work for Facebook where it makes a POST request to Facebook to login and downloads the HTML to the page, then saves it to my computer. I tried doing this with Twi...
Getting Twitter news feed using Python
Hey everybody, I've been playing around with Python 2.7 and BeautifulSoup 3.2 recently and I've gotten my code to work for Facebook where it makes a POST request to Facebook to login and downloads the HTML to the page, then saves it to my computer. I tried doing this with Twitter but it doesn't seem to be working*.. he...
[ "\nDon't use BeatufulSoup, use lxml instead http://lxml.de/ (much more powerfull, faster and convenient)\nDon't grab twitter web-interface, use oficial twitter API instead http://dev.twitter.com/doc/get/statuses/home_timeline\n\n", "You may want to check out the Twitter libraries for Python.\n" ]
[ 2, 0 ]
[]
[]
[ "beautifulsoup", "python", "twitter", "urllib", "urllib2" ]
stackoverflow_0005278813_beautifulsoup_python_twitter_urllib_urllib2.txt
Q: reading # char in python can someone help with me reading "#" char in python? i can't seem to get the file. because this is an output from the stanford postagger, is there any scripts available to convert the stanford postagger http://nlp.stanford.edu/software/tagger.shtml file to cwb. http://cogsci.uni-osnabrueck...
reading # char in python
can someone help with me reading "#" char in python? i can't seem to get the file. because this is an output from the stanford postagger, is there any scripts available to convert the stanford postagger http://nlp.stanford.edu/software/tagger.shtml file to cwb. http://cogsci.uni-osnabrueck.de/~korpora/ws/CWBdoc/CWB_Enc...
[ "If Python does not recognize an escape sequence then it will include the backslash in the string.\n>>> '\\#' == '\\\\#'\nTrue\n\n", "if word == '\\#':\n\nThis probably doesn't do what you think it does. (Hint: print \"\\#\")\n" ]
[ 1, 1 ]
[]
[]
[ "nlp", "python", "stanford_nlp", "utf_8" ]
stackoverflow_0005280421_nlp_python_stanford_nlp_utf_8.txt
Q: Numeric GUI bottleneck I've made a GUI to set up and start a numerical integrator using PyQT4, Wing, QT, and Python 2.6.6, on my Mac. The thing is, when I run the integrator form the GUI, it takes very many times longer than when I crudely run the integrator from the command line. As an example, a 1000 year integr...
Numeric GUI bottleneck
I've made a GUI to set up and start a numerical integrator using PyQT4, Wing, QT, and Python 2.6.6, on my Mac. The thing is, when I run the integrator form the GUI, it takes very many times longer than when I crudely run the integrator from the command line. As an example, a 1000 year integration took 98 seconds on the...
[ "In general it is not a good idea to use python threads within a pyqt application. Instead use a QThread.\nBoth python and QThreads call the same underlying mechanisms, but they don't play well together. I don't know if this will solve your problem or not, but it might be part of the issue.\n", "Is your thread...
[ 0, 0 ]
[]
[]
[ "pyqt4", "python", "qt" ]
stackoverflow_0005279627_pyqt4_python_qt.txt
Q: SWIG, boost shared pointers and inheritance I'm having trouble with SWIG, shared pointers, and inheritance. I am creating various c++ classes which inherit from one another, using Boost shared pointers to refer to them, and then wrapping these shared pointers with SWIG to create the python classes. My problem is t...
SWIG, boost shared pointers and inheritance
I'm having trouble with SWIG, shared pointers, and inheritance. I am creating various c++ classes which inherit from one another, using Boost shared pointers to refer to them, and then wrapping these shared pointers with SWIG to create the python classes. My problem is the following: B is a subclass of A sA is a share...
[ "The following change appears to solve the problem.\nIn swig_shared_ptr.i the two lines:\n%template(base_sptr) boost::shared_ptr<Base>;\n%template(derived_sptr) boost::shared_ptr<Derived>;\n\nare moved so that they are above the line\n%include <swig_shared_ptr.h>\n\nand are then replaced (in SWIG 1.3) by:\nSWIG_SHA...
[ 6, 5 ]
[]
[]
[ "boost", "c++", "python", "shared_ptr", "swig" ]
stackoverflow_0004710037_boost_c++_python_shared_ptr_swig.txt
Q: ImportError when using web.py with new environment I just recreated all my python environment, reinstalled python and setuptools, and installed virtualenv. I started a test enviroment with virtualenv --no-site-packages test, activated it with Scripts\activate.bat and then easy_install web.py. Then I create a code....
ImportError when using web.py with new environment
I just recreated all my python environment, reinstalled python and setuptools, and installed virtualenv. I started a test enviroment with virtualenv --no-site-packages test, activated it with Scripts\activate.bat and then easy_install web.py. Then I create a code.py file: import web urls = ( '/.*', 'index', ) app...
[ "Solved.\nWindows was configured to open .py files with C:\\Python27\\python.exe. I can even remember setting this mannualy some time ago so I wouldn't have to use python to run files (oh lazyness, what have you done to me?).\nThat's why it was working with the interactive shell, but not by executing the code.py fi...
[ 1 ]
[]
[]
[ "python", "virtualenv", "web.py" ]
stackoverflow_0005280418_python_virtualenv_web.py.txt
Q: Every request hits server twice in Appengine I have small app in appengine. Every request hits the server twice in my local dev server. In debug mode i can see that the get method called twice. Its happening in both chrome and firefox browsers. here is the log from my localserver.. INFO 2011-03-12 00:44:31,07...
Every request hits server twice in Appengine
I have small app in appengine. Every request hits the server twice in my local dev server. In debug mode i can see that the get method called twice. Its happening in both chrome and firefox browsers. here is the log from my localserver.. INFO 2011-03-12 00:44:31,076 dev_appserver.py:3317] "GET /movie/tanu_weds_man...
[ "When I set up my app.yaml I just poured through this page: http://code.google.com/appengine/docs/python/config/appconfig.html\nYou have to think like a regular expression parser. Anything that fails to match the preceding expressions will fall through to your wildcard handler and cause weirdness.\nOne thing I not...
[ 3 ]
[]
[]
[ "google_app_engine", "python" ]
stackoverflow_0005277418_google_app_engine_python.txt
Q: python: ImportError: No module named patheffects When i try to run a python script in which i do an import statement matplotlib.patheffects, i get an error message saying there is no module called patheffects. the statement is import matplotlib.patheffects Kindly help me to figure out the reason for this error an...
python: ImportError: No module named patheffects
When i try to run a python script in which i do an import statement matplotlib.patheffects, i get an error message saying there is no module called patheffects. the statement is import matplotlib.patheffects Kindly help me to figure out the reason for this error and how to make the code run without this glitch.
[ "import matplotlib.patheffects works perfectly well for me. Please make sure you have matplotlib installed. The most current version is 1.0.1. You can download from here. \nMatplotlib depends on numpy, so make sure you have it installed before installing matplotlib. \nAlso check out the tips on installing matplotli...
[ 2 ]
[]
[]
[ "matplotlib", "python" ]
stackoverflow_0005280945_matplotlib_python.txt
Q: python re codecs ä ö, finnish language, define that is word IS it possible to define that specific languages characters would be considered as word. I.e. re do not accept ä,ö as word characters if i search them in following way Ft=codecs.open('c:\\Python27\\Scripts\\finnish2\\textfields.txt','r','utf–8') word=Ft.r...
python re codecs ä ö, finnish language, define that is word
IS it possible to define that specific languages characters would be considered as word. I.e. re do not accept ä,ö as word characters if i search them in following way Ft=codecs.open('c:\\Python27\\Scripts\\finnish2\\textfields.txt','r','utf–8') word=Ft.readlines() word=smart_str(word, encoding='utf-8', strings_only=Fa...
[ "[A-Za-z0-9] will only match the characters listed here, but the docs also mention some other special constructs like:\n\n\\w which stands for alphanumeric characters (namely [a-zA-Z0-9_] plus all unicode characters which are declared to be alphanumeric\n\\W which stands for all nun-alphanumeric characters [^a-zA-Z...
[ 4, 2, 0 ]
[]
[]
[ "codec", "python", "regex" ]
stackoverflow_0005281165_codec_python_regex.txt
Q: How to convert string variable from python into a javascript literal array? I have tried to convert python string data separated by commas into a javascript array variable but the process does not seem to be working. these are my current codes: var tagstring = {{ tag_data }}; var availableTags = new Array(...
How to convert string variable from python into a javascript literal array?
I have tried to convert python string data separated by commas into a javascript array variable but the process does not seem to be working. these are my current codes: var tagstring = {{ tag_data }}; var availableTags = new Array(); var availableTags = tagstring.split(","); I need the array to look someth...
[ "Assuming this is in a Django template, then this should work:\nvar tagstring = \"{{ tag_data|escapejs }}\";\n\nI've added quotation marks (\") around the tag_data, since otherwise just the literal text in the string will be inserted into the Javascript; you want to construct a Javascript string that contains this ...
[ 3, 1, 1 ]
[]
[]
[ "arrays", "javascript", "python" ]
stackoverflow_0005281288_arrays_javascript_python.txt
Q: GAE webapp alternative working outside of GAE environment I like working with GAE environment as well as with its webapp framework. I am creating a web application using GAE environment. What I think about is how to create a version of my application that could run in another environment, like some other hosting o...
GAE webapp alternative working outside of GAE environment
I like working with GAE environment as well as with its webapp framework. I am creating a web application using GAE environment. What I think about is how to create a version of my application that could run in another environment, like some other hosting or cloud service the easiest way. I know I will have to think ab...
[ "Have a look to web2py, in my opinion it's a great and well documented web framework and it offers a powerful Dal that allows your application to be portable among different types of database, GAE datastore included *.\n* with some limitation explained here\n", "The pre-release version of Tipfy is adding the abil...
[ 1, 1, 0, 0, 0, 0, 0 ]
[]
[]
[ "google_app_engine", "python", "web_applications" ]
stackoverflow_0005278308_google_app_engine_python_web_applications.txt
Q: How do I create a POINTER to the Structure being defined? I'm writing a Python wrapper around getifaddrs(). The interface uses the struct ifaddrs type, the first field of which is a pointer to another struct ifaddrs. struct ifaddrs { struct ifaddrs *ifa_next; /* Pointer to the next structure. */ ... /* ...
How do I create a POINTER to the Structure being defined?
I'm writing a Python wrapper around getifaddrs(). The interface uses the struct ifaddrs type, the first field of which is a pointer to another struct ifaddrs. struct ifaddrs { struct ifaddrs *ifa_next; /* Pointer to the next structure. */ ... /* SNIP!!11 */ }; However, representing this in Python: class str...
[ "How about this?\nclass struct_ifaddrs(Structure):\n pass\nstruct_ifaddrs._fields_ = [\n ('ifa_next', POINTER(struct_ifaddrs)),]\n\nAs Paul McGuire notes in the comments, this is documented as standard solution for this problem in the ctypes documentation and yet another time in the same docs.\n" ]
[ 5 ]
[]
[]
[ "ctypes", "linked_list", "pointers", "python", "structure" ]
stackoverflow_0005281618_ctypes_linked_list_pointers_python_structure.txt
Q: Getting confirmation window with Selenium-rc I'm running a selenium server (v.2.0b2) and writing a python script to run a test suite on my webapp. from selenium import webdriver import selenium selenium = selenium.selenium('127.0.0.1', 3333, '*firefox', 'http://localhost/') selenium.start() profile = webdriver.Fi...
Getting confirmation window with Selenium-rc
I'm running a selenium server (v.2.0b2) and writing a python script to run a test suite on my webapp. from selenium import webdriver import selenium selenium = selenium.selenium('127.0.0.1', 3333, '*firefox', 'http://localhost/') selenium.start() profile = webdriver.FirefoxProfile('selenium') browser = webdriver.Firef...
[ "I have not worked with Selenium 2.0 (web driver) but would suggest you to test this with Thread.sleep(10). And if that works then it means conditional wait in required in your case.\n" ]
[ 0 ]
[]
[]
[ "python", "selenium_rc" ]
stackoverflow_0005277860_python_selenium_rc.txt
Q: Best Python clustering library to use for product data analysis I have a collection of alphanumeric product codes of various products. Similar products have no intrinsic similarity in their codes, ie product code "A123" might mean "Harry Potter Volume 1 DVD" and "B123" might mean "Kellogs Corn Flakes". I also do n...
Best Python clustering library to use for product data analysis
I have a collection of alphanumeric product codes of various products. Similar products have no intrinsic similarity in their codes, ie product code "A123" might mean "Harry Potter Volume 1 DVD" and "B123" might mean "Kellogs Corn Flakes". I also do not actually have the description or identify of the product. All I ha...
[ "What you have is a bipartite graph. As an initial stab, it sounds like you are going to treat neighbour lists as zero-one vectors between which you define some kind of similarity/correlation. This could be a normalised Hamming distance for example. Depending on which way you do that you will obtain a graph on a si...
[ 8, 2, 2, 1, 0, 0 ]
[]
[]
[ "cluster_analysis", "python" ]
stackoverflow_0005002783_cluster_analysis_python.txt
Q: How would one convert a Python string representation of a byte-string to an actual byte-string? I'm trying to figure out how one might convert a string representation of a byte-string into an actual byte-string type. I'm not very used to Python (just hacking on it to help a friend), so I'm not sure if there's some...
How would one convert a Python string representation of a byte-string to an actual byte-string?
I'm trying to figure out how one might convert a string representation of a byte-string into an actual byte-string type. I'm not very used to Python (just hacking on it to help a friend), so I'm not sure if there's some easy "casting" method (like my beloved Java has ;) ). Basically I have a text file, which has as it'...
[ ">>> r'\\x03\\xacgB\\x16\\xf3\\xe1\\\\v\\x1e\\xe1\\xa5\\xe2U\\xf0g\\x956#\\xc8\\xb3\\x88\\xb4E\\x9e\\x13\\xf9x\\xd7\\xc8F\\xf4'.decode('string-escape')\n'\\x03\\xacgB\\x16\\xf3\\xe1\\\\v\\x1e\\xe1\\xa5\\xe2U\\xf0g\\x956#\\xc8\\xb3\\x88\\xb4E\\x9e\\x13\\xf9x\\xd7\\xc8F\\xf4'\n\nThis will work for strings that don't ...
[ 3, 0 ]
[]
[]
[ "python", "python_3.x" ]
stackoverflow_0005281799_python_python_3.x.txt
Q: (Django) (Foreign Key Issues) model.person_id May not be NULL I know this seems to be an over-asked question in the Django circles but I'm afraid to say that i've not yet found the solution to this. My Model - from djago.... import User class InfoPersonal(models.Model): ... person = models.OneToOneField(User) I'v...
(Django) (Foreign Key Issues) model.person_id May not be NULL
I know this seems to be an over-asked question in the Django circles but I'm afraid to say that i've not yet found the solution to this. My Model - from djago.... import User class InfoPersonal(models.Model): ... person = models.OneToOneField(User) I've tried overriding the save_model() in the admin definition and als...
[ "I got the answer!!! I feel good!\npersonal = form.save(commit = False)\npersonal.person = request.user\npersonal.save()\n\nThis goes into the view much like Ignacio said, only commit = False being a critical statement for it to save an instance without throwing an exception. Thanks all who helped!!\nCheers\n"...
[ 1, 0, 0 ]
[]
[]
[ "autocomplete", "django", "foreign_keys", "model", "python" ]
stackoverflow_0005281935_autocomplete_django_foreign_keys_model_python.txt
Q: Is a custom ForeignKey subclass necessary if the Django ORM is to work with bad PK values? The project that I'm working has dirty data in the database. Basically, the original designer created foreign key fields but didn't enforce them with referential integrity. Now there are FK values that are invalid and don'...
Is a custom ForeignKey subclass necessary if the Django ORM is to work with bad PK values?
The project that I'm working has dirty data in the database. Basically, the original designer created foreign key fields but didn't enforce them with referential integrity. Now there are FK values that are invalid and don't actually point to existent records. Normally I would simply remove these invalid FK values bu...
[ "I think there should be better possibilities to solve this, as your solution still doesn't bring any integrity to your database. Possibilities would be:\n\nChange your model: set the FK's parameters to null=True and change the zeros to None\nSet all the FKs with '0' to another value and create a related 'dummy obj...
[ 1 ]
[]
[]
[ "django", "django_models", "orm", "primary_key", "python" ]
stackoverflow_0005276960_django_django_models_orm_primary_key_python.txt
Q: Websocket handshake problem using Python server This is a question regarding handshaking in Websocket Protocol 76. I have written a client and server, but am having trouble getting the client to accept the handshake. I can see that it is being returned, but the client immediately closes the connection. I'm guessin...
Websocket handshake problem using Python server
This is a question regarding handshaking in Websocket Protocol 76. I have written a client and server, but am having trouble getting the client to accept the handshake. I can see that it is being returned, but the client immediately closes the connection. I'm guessing that my md5sum response must be incorrect. As far a...
[ "You have a couple problems that immediately jump out at me:\n\nYou aren't counting spaces properly. You counter should start at 0 not -1.\nYour response headers are still v75 style. Any header starting with \"WebSocket-\" (WebSocket-Origin, WebSocket-Location, WebSocket-Protocol) should instead start with \"Sec-W...
[ 5, 2 ]
[]
[]
[ "html", "python", "websocket" ]
stackoverflow_0004372657_html_python_websocket.txt
Q: submitting webforms python I am trying to submit this webform and log into this site: https://www.kalahari.net/profile/pipeline/signin.aspx I keep getting the login site's source code as output when the script is done,so it seems like all is working (no errors) but it's just not logging in. I can't find what I am ...
submitting webforms python
I am trying to submit this webform and log into this site: https://www.kalahari.net/profile/pipeline/signin.aspx I keep getting the login site's source code as output when the script is done,so it seems like all is working (no errors) but it's just not logging in. I can't find what I am doing wrong.Please help. I am us...
[ "The site is probably using cookies for the login, so you must too. That means you must save the cookies you get when you log in and send them to the site with each following request.\nCheck out http.cookiejar. \n" ]
[ 1 ]
[]
[]
[ "python", "python_3.x", "urllib", "webforms" ]
stackoverflow_0005282290_python_python_3.x_urllib_webforms.txt
Q: How to deploy a simple python application in linux for shared, company environment? I have written an (obviously) excellent tool in python (under linux) that I would like to share with my co-workers. We work on different machines, but with the same, shared environment. Also, we are users, so there is no way of eas...
How to deploy a simple python application in linux for shared, company environment?
I have written an (obviously) excellent tool in python (under linux) that I would like to share with my co-workers. We work on different machines, but with the same, shared environment. Also, we are users, so there is no way of easily installing dependencies. Now here's the catch: I like python, my users don't care. Th...
[ "Assuming your standard installs are Python 2.6 or later and you don't use any C extension modules, you can just throw it all in a zipfile, include a __main__.py file and then prepend a shell header to the zipfile. Your scenario is precisely why this feature was added.\nSee http://bugs.python.org/issue1739468 for m...
[ 3, 3, 1, 0 ]
[]
[]
[ "deployment", "linux", "python" ]
stackoverflow_0005281336_deployment_linux_python.txt
Q: zlib decompress header check error I have an issue with a dictionary I'm compressing and storing to a postgres database. I can compress the dictionary and decompress it without fault but when I insert it into the database, and then select it back and try to decompress the data I get an error: zlib.error: Error -3 ...
zlib decompress header check error
I have an issue with a dictionary I'm compressing and storing to a postgres database. I can compress the dictionary and decompress it without fault but when I insert it into the database, and then select it back and try to decompress the data I get an error: zlib.error: Error -3 while decompressing data: incorrect head...
[ "The binary string requires escaping\npsycopg2\nhttp://initd.org/psycopg/docs/usage.html#adaptation-of-python-values-to-sql-types\nhttp://initd.org/psycopg/docs/module.html#psycopg2.Binary\nPostgres Binary String\nhttps://www.postgresql.org/docs/current/static/datatype-binary.html#DATATYPE-BINARY-SQLESC\n" ]
[ 1 ]
[]
[]
[ "postgresql", "python", "zlib" ]
stackoverflow_0005279068_postgresql_python_zlib.txt
Q: Error in Selenium Python Script I am trying to get the hang of both Python and Selenium RC and am having some difficulty getting the following sample Selenium Python Script to parse. I have resolved all of the following code's errors besides one: from selenium import selenium import unittest class SignUpTask(unit...
Error in Selenium Python Script
I am trying to get the hang of both Python and Selenium RC and am having some difficulty getting the following sample Selenium Python Script to parse. I have resolved all of the following code's errors besides one: from selenium import selenium import unittest class SignUpTask(unittest.TestCase): """ The following...
[ "def test_that_will_print_out_a_url_as_answer_for_task(sel):\nThat should have been self.\n", "The first step in debugging a problem like this is to assume the error message is telling the truth. Look at it literally. It says \"self is not defined\". So ask yourself, why isn't it defined?. There really can be onl...
[ 3, 1, 0 ]
[]
[]
[ "error_handling", "python", "selenium", "selenium_rc" ]
stackoverflow_0004655310_error_handling_python_selenium_selenium_rc.txt
Q: How do I upload many files at the time to cloud files with Python? I'm using the cloudfile module to upload files to rackspace cloud files, using something like this pseudocode: import cloudfiles username = '---' api_key = '---' conn = cloudfiles.get_connection(username, api_key) testcontainer = conn.create_cont...
How do I upload many files at the time to cloud files with Python?
I'm using the cloudfile module to upload files to rackspace cloud files, using something like this pseudocode: import cloudfiles username = '---' api_key = '---' conn = cloudfiles.get_connection(username, api_key) testcontainer = conn.create_container('test') for f in get_filenames(): obj = testcontainer.create_...
[ "The ConnectionPool class is meant for a multithreading application that ocasionally has to send something to rackspace.\nThat way you can reuse your connection but you don't have to keep 100 connections open if you have 100 threads.\nYou are simply looking for a multithreading/multiprocessing uploader.\nHere's an ...
[ 8 ]
[]
[]
[ "cloudfiles", "multithreading", "python" ]
stackoverflow_0005249008_cloudfiles_multithreading_python.txt
Q: Evaluation inside string Is there something like Rubys "Hello #{userNameFunction()}" in python? A: In Python, you would use string interpolation "Hello %s" % user_name_function() or string formating "Hello {0}".format(user_name_function()) The latter is available in Python 2.6 or above. Also note that by conve...
Evaluation inside string
Is there something like Rubys "Hello #{userNameFunction()}" in python?
[ "In Python, you would use string interpolation\n\"Hello %s\" % user_name_function()\n\nor string formating\n\"Hello {0}\".format(user_name_function())\n\nThe latter is available in Python 2.6 or above.\nAlso note that by convention you don't use CamelCase for function names in Python (CamelCase is for class names ...
[ 9, 2, 1 ]
[]
[]
[ "python" ]
stackoverflow_0005282503_python.txt
Q: Django uploading and importing a file I have a Django app that is basically a web front end on a database. Every now and then, users upload files containing perhaps 1000s of records. These records will need to be parsed out of the file, processed, and used to create new records or update existing records in the da...
Django uploading and importing a file
I have a Django app that is basically a web front end on a database. Every now and then, users upload files containing perhaps 1000s of records. These records will need to be parsed out of the file, processed, and used to create new records or update existing records in the database. I'm just wondering what is the bett...
[ "Celery seems to be pretty hot these days too, you should definitely look into this:\nhttps://github.com/ask/django-celery\nhttp://celeryproject.org/\n\nSend an email when done, or have the front end poll for results every X seconds after submission. \"Are we there yet?\" \"Are we there yet?\"\n\nI'd like to know t...
[ 2 ]
[]
[]
[ "django", "python" ]
stackoverflow_0005283520_django_python.txt
Q: Load JavaScript in Google App Engine I got so confused loading JavaScript in Google App Engine. I am using the Django template. First, in my base HTML file, I can't load my downloaded jQuery code from local say, d:/jquery.js, like <script src="d:\jquery.js" type="text/javascript" ></script></head>, This line is i...
Load JavaScript in Google App Engine
I got so confused loading JavaScript in Google App Engine. I am using the Django template. First, in my base HTML file, I can't load my downloaded jQuery code from local say, d:/jquery.js, like <script src="d:\jquery.js" type="text/javascript" ></script></head>, This line is in my base HTML file. It works when I load ...
[ "AppEngine doesn't know anything about paths on your local system; it will only upload files that you configure it to. Do this by having a line like this in your app.yaml file:\nhandlers:\n- url: /js\n static_dir: js\n\nIn this case, /js represents a subdirectory of your main project directory, and you can put all...
[ 20 ]
[]
[]
[ "google_app_engine", "javascript", "jquery", "python" ]
stackoverflow_0005283559_google_app_engine_javascript_jquery_python.txt
Q: Why python.exe stopped working? I try to use OpenCV for Python. I have just two lines of the code: import cv capture = cv.CreateFileCapture('test.avi') If I run this code from the command line, Windows creates a window with the following message: python.exe stopped working A problem caused the program to stop wor...
Why python.exe stopped working?
I try to use OpenCV for Python. I have just two lines of the code: import cv capture = cv.CreateFileCapture('test.avi') If I run this code from the command line, Windows creates a window with the following message: python.exe stopped working A problem caused the program to stop working correctly. Windows will close th...
[ "Python on opencv has changed, see here make sure you have the latest opencv install - you might also need numpy\n" ]
[ 0 ]
[]
[]
[ "opencv", "python", "windows" ]
stackoverflow_0005103093_opencv_python_windows.txt
Q: py2app ends with error related to libgfortran.3.dylib py2app ends with following error: /usr/bin/strip: the __LINKEDIT segment does not cover the end of the file (can't be processed) in: test.app/Contents/Frameworks/libgfortran.3.dylib stripping saved 1222348 bytes (88617336 / 89839684) this last line of console...
py2app ends with error related to libgfortran.3.dylib
py2app ends with following error: /usr/bin/strip: the __LINKEDIT segment does not cover the end of the file (can't be processed) in: test.app/Contents/Frameworks/libgfortran.3.dylib stripping saved 1222348 bytes (88617336 / 89839684) this last line of console output: ../Frameworks/libgfortran.3.dylib: mach-o, but wro...
[ "First decide what architectures and OS versions you plan to build for.\nThen make sure libgfortran and your other dependencies are compiled for these architecture(s). (You can use lipo -info or file to print the architectures contained in a Mach-O binary).\nFinally, if the architectures are a subset of those for ...
[ 0 ]
[]
[]
[ "py2app", "python" ]
stackoverflow_0005283931_py2app_python.txt
Q: In python, how do I get timing information like os.times() for a specific child process? I can use os.times or resource.getrlimit to get user time of the current process, all the children processes, or both. How do I get timing information for a specific child process? A: I don't know if you can do this in gener...
In python, how do I get timing information like os.times() for a specific child process?
I can use os.times or resource.getrlimit to get user time of the current process, all the children processes, or both. How do I get timing information for a specific child process?
[ "I don't know if you can do this in general, but on Linux you can just parse /proc/<PID>/stat to find the first four values that you would get from os.times for any process. For example:\nimport sys\nimport os\n\nif not len(sys.argv) == 2:\n print >> sys.stderr, \"Usage: %s <PID>\" % (sys.argv[0])\n sys.exit...
[ 2, 0 ]
[]
[]
[ "python", "system" ]
stackoverflow_0005283890_python_system.txt
Q: setattr() not setting I have a class (bot), which has an attribute "health"; since there are a lot of parameters to this class, and I wished for the user to input a lot of them, I chose to loop through a dict of {param:explanation}, and for each param, input a value to set. attr_array = ["health",...] attr_dict = ...
setattr() not setting
I have a class (bot), which has an attribute "health"; since there are a lot of parameters to this class, and I wished for the user to input a lot of them, I chose to loop through a dict of {param:explanation}, and for each param, input a value to set. attr_array = ["health",...] attr_dict = {} attr_dict["health"] = "y...
[ "From the question comments: Why are you doing\n setattr(tmp_bot, attr_dict[attr], tmp_attr)\n\nand not\n setattr(tmp_bot, attr, tmp_attr)\n\n? I guess the real question is, why do you expect those two print lines to output the same when one accesses property \"your bot's health\" and the other is accessing propert...
[ 1 ]
[]
[]
[ "python", "setattr" ]
stackoverflow_0005281297_python_setattr.txt
Q: PHP's form bracket trick is to Django's ___? In PHP you can create form elements with names like: category[1] category[2] or even category[junk] category[test] When the form is posted, category is automatically turned into a nice dictionary like: category[1] => "the input value", category[2] => "the other input ...
PHP's form bracket trick is to Django's ___?
In PHP you can create form elements with names like: category[1] category[2] or even category[junk] category[test] When the form is posted, category is automatically turned into a nice dictionary like: category[1] => "the input value", category[2] => "the other input value" Is there a way to do that in Django? reque...
[ "You could use django.utils.datastructures.DotExpandedDict with inputs named category.1, category.2 etc. to do something similar, but I don't really see why you would if you ever have to validate and redisplay the information you're receiving, when using a django.forms.Form will do everything for you - appropriate ...
[ 2, 1, 0, 0, 0, 0, 0 ]
[]
[]
[ "django", "php", "python" ]
stackoverflow_0002527476_django_php_python.txt
Q: Python: How to install mysqldb on windows 7 x64? Im trying install Mysql-python on windows x64. I installed python x64, setuptools (checked on the leaf lib, successfully installed) but i can't install mysqldb. I trying to execute C:\Users\Fedcomp\Desktop\leaf-0.4\MySQL-python-1.2.3>python setup.py install but...
Python: How to install mysqldb on windows 7 x64?
Im trying install Mysql-python on windows x64. I installed python x64, setuptools (checked on the leaf lib, successfully installed) but i can't install mysqldb. I trying to execute C:\Users\Fedcomp\Desktop\leaf-0.4\MySQL-python-1.2.3>python setup.py install but catch this In file included from _mysql.c:34: D:\serv...
[ "EDIT: mysqlclient has binary packages for both 32bit and 64bit on PyPI. It's a fork of MySQL-python, which hasn't seen a release since 2014.\nOriginal answer left for posterity:\nYou can find binary installers here (Python 2.6-3.2), here (2.7) or here (2.6). Note that you don't have to use 64bit Python on Windows ...
[ 35, 2, 1 ]
[]
[]
[ "64_bit", "mysql", "python", "windows_7" ]
stackoverflow_0005284186_64_bit_mysql_python_windows_7.txt
Q: Need help creating a TCP relay between two sockets I have the following situation: SomeServer(S) <-> (C)MyApp(S) <-> (C)User (S) represents a server socket (C) represents a client socket Essentially, MyApp initiates communication with SomeServer (SomeServer(S) <-> (C)MyApp) and once some authentication routines ...
Need help creating a TCP relay between two sockets
I have the following situation: SomeServer(S) <-> (C)MyApp(S) <-> (C)User (S) represents a server socket (C) represents a client socket Essentially, MyApp initiates communication with SomeServer (SomeServer(S) <-> (C)MyApp) and once some authentication routines are successful MyApp(S) starts waiting for (C)User to co...
[ "The code is a bit hard to follow, and I'm sure there are a few bugs. For\nexample in handle_read() you're passing MyAppClient's raw socket self.socket to\nRelayServer. You end up with both MyAppClient and RelayConnection working on the same socket.\nRather than attempt to suggest bug fixes to the original code I ...
[ 4 ]
[]
[]
[ "asynchronous", "asyncore", "python", "sockets" ]
stackoverflow_0005279641_asynchronous_asyncore_python_sockets.txt
Q: Is it pythonic to use interfaces / abstract base classes? I cannot find much advantage in them besides kind of documentation purpose. Python will warn me if I forget to implement a method I defined in a ABC but since I do not reference my objects by their interfaces I can forget to declare methods in their interfa...
Is it pythonic to use interfaces / abstract base classes?
I cannot find much advantage in them besides kind of documentation purpose. Python will warn me if I forget to implement a method I defined in a ABC but since I do not reference my objects by their interfaces I can forget to declare methods in their interfaces and I won't event notice it. Is it common practice to use A...
[ "Personally, I find abstract classes to be most useful when writing libraries or other code which interfaces between one developer and another.\nOne of the advantages of statically-typed languages is that when you use the wrong type, it fails early (often, as early as compile time). ABCs allow Python to gain this ...
[ 6, 1 ]
[]
[]
[ "abstract_class", "interface", "python" ]
stackoverflow_0005283995_abstract_class_interface_python.txt
Q: unable to use pip with Python 3.2 using distribute After installing python3.2 from src, I tried running: curl -O http://python-distribute.org/distribute_setup.py sudo python3.2 distribute_setup.py sudo python3.2 -m easy_install pip sudo python3.2 -m pip lxml This gives: Traceback (most recent call last): File "...
unable to use pip with Python 3.2 using distribute
After installing python3.2 from src, I tried running: curl -O http://python-distribute.org/distribute_setup.py sudo python3.2 distribute_setup.py sudo python3.2 -m easy_install pip sudo python3.2 -m pip lxml This gives: Traceback (most recent call last): File "/usr/local/lib/python3.2/runpy.py", line 140, in _run_mo...
[ "There is version of pip working with Python 3.\nSee my answer to Python 3, easy_install, pip and pypi question.\n", "print dist is invalid in Python3. It should be print(dist).\nHowever, with this error it is very likely that pip is not compatible with Python3. According to http://pypi.python.org/pypi/pip it als...
[ 2, 1 ]
[]
[]
[ "distribute", "easy_install", "pip", "python", "python_3.x" ]
stackoverflow_0005123945_distribute_easy_install_pip_python_python_3.x.txt
Q: How to create a plugin for chrome so that it can read the web page's text and send it to python program? I have a program written for text simplification in python language, I need this program to be run on a browser as a plugin... If you click the plugin it should take the webpage's text as input and pass this i...
How to create a plugin for chrome so that it can read the web page's text and send it to python program?
I have a program written for text simplification in python language, I need this program to be run on a browser as a plugin... If you click the plugin it should take the webpage's text as input and pass this input to my text simplification program and the output of the program should be again displayed in another web p...
[ "You would need to use NPAPI plugins in Chrome Extension:\nhttp://code.google.com/chrome/extensions/npapi.html\nThen you use Content Scripts to get the webpage text, you pass it to the Background Page via Messaging. Then your NPAPI plugin will call python (do it however you like since its all in C++), and from the ...
[ 2, 2 ]
[]
[]
[ "google_chrome_extension", "python" ]
stackoverflow_0005284145_google_chrome_extension_python.txt
Q: qooxdoo and debian lenny Hy, Trying to use qooxdoo with debian lenny. qooxdoo sdk 1.2 create-application.py ok but I've got a problem with generate.py : /demo/qooxdoo/hello1$ ./generate.py source-all Traceback (most recent call last): File "/demo/qooxdoo-1.2-sdk/tool/bin/generator.py", line 26, in <module> f...
qooxdoo and debian lenny
Hy, Trying to use qooxdoo with debian lenny. qooxdoo sdk 1.2 create-application.py ok but I've got a problem with generate.py : /demo/qooxdoo/hello1$ ./generate.py source-all Traceback (most recent call last): File "/demo/qooxdoo-1.2-sdk/tool/bin/generator.py", line 26, in <module> from generator.Generator import...
[ "This stack trace is a tad weird. For a basic thing, the referenced code line (Generator.py:31) imports from \"generator.code.Class\", and the ImportError indicates that it doesn't find the \"code\" subpackage under \"generator\". But the \"#import warnings\" line is actually generator.py line 31, as if it would be...
[ 2, 2, 2 ]
[]
[]
[ "debian", "lenny", "python", "qooxdoo" ]
stackoverflow_0003808265_debian_lenny_python_qooxdoo.txt
Q: Textmate Execute line/selection for Python broken I've been using textmate for python for a couple of weeks now, everything seems to be working fine apart from the command "Execute line/selection as Python". It does not work at all. Trying to test even print "Hello World" I get Traceback (most recent call last): ...
Textmate Execute line/selection for Python broken
I've been using textmate for python for a couple of weeks now, everything seems to be working fine apart from the command "Execute line/selection as Python". It does not work at all. Trying to test even print "Hello World" I get Traceback (most recent call last): File "/tmp/temp_textmate.QrxfR3", line 19, in <module...
[ "There are two things going on here. The first is that the command \"Execute line/selection as Python\" is broken. The exception you're seeing is a consequence of a bug in the implementation of \"Execute line/selection as Python\" when trying to retrieve the call stack. Why this is happening is something of a poser...
[ 0 ]
[]
[]
[ "python", "textmate" ]
stackoverflow_0005282567_python_textmate.txt
Q: pygame vs wxpython I am trying to implement a game of tetris in python and am wondering which of wxpython or pygame is better to go with. Any ideas would be appreciated. A: wxpython is primarily used for developing window-based user interfaces. Putting a game together using it would be pretty hackish, I think. P...
pygame vs wxpython
I am trying to implement a game of tetris in python and am wondering which of wxpython or pygame is better to go with. Any ideas would be appreciated.
[ "wxpython is primarily used for developing window-based user interfaces. Putting a game together using it would be pretty hackish, I think. Pygame is, of course, specifically made for game creation, so it will be a better bet.\nSome other projects you might want to look into are: http://arcticpaint.com/projects/rab...
[ 3 ]
[]
[]
[ "pygame", "python", "wxpython" ]
stackoverflow_0005284748_pygame_python_wxpython.txt
Q: how to set the admin user with GAE dev app server? I want to create an Admin-only page for my GAE application. But I found there's no way to set a Admin user, so I cannot log on the page I created and test the function. I tried the local Admin console, but no luck. How can I do this? A: Google App Engine provide...
how to set the admin user with GAE dev app server?
I want to create an Admin-only page for my GAE application. But I found there's no way to set a Admin user, so I cannot log on the page I created and test the function. I tried the local Admin console, but no luck. How can I do this?
[ "Google App Engine provides a pretty straightforward way to create a private admin section of your web application.\n1.\nIn your app.yaml, any URL handler can have a login setting to restrict visitors to only those users who have signed in, or just those users who are administrators for the application.\nIf the set...
[ 7, 0, 0 ]
[]
[]
[ "google_app_engine", "python" ]
stackoverflow_0005283506_google_app_engine_python.txt
Q: Python: strptime not matching format ValueError: time data '03-10-2011 04:35 PM' does not match format '%m-%d-%Y %I:M %p' That looks like it matches to me? datetime = datestr + " " + timestr date_struct = time.strptime(datetime, "%m-%d-%Y %I:M %p") A: You are missing a % right before the M: date_struct =...
Python: strptime not matching format
ValueError: time data '03-10-2011 04:35 PM' does not match format '%m-%d-%Y %I:M %p' That looks like it matches to me? datetime = datestr + " " + timestr date_struct = time.strptime(datetime, "%m-%d-%Y %I:M %p")
[ "You are missing a % right before the M:\n date_struct = time.strptime(datetime, \"%m-%d-%Y %I:%M %p\")\n\n", "Those datetime format strings work both ways, so you can easily check hypotheses such as \"looks like it matches\":\n>>> import datetime\n>>> fmt = \"%m-%d-%Y %I:M %p\"\n>>> dt = datetime.datetime(2011, ...
[ 8, 4 ]
[]
[]
[ "python", "strptime", "time" ]
stackoverflow_0005284341_python_strptime_time.txt
Q: List Python Operation I got this list: input = [[1,2,3,4],[5,6,7,8],[9,10,11,12]] I want to make new lists with each index item: i.e. output = [[1,5,9],[2,6,10],[3,7,11],[4,8,12]] A: This is a canonical example of when to use zip: In [6]: inlist = [[1,2,3,4],[5,6,7,8],[9,10,11,12]] In [7]: out=zip(*inlist) ...
List Python Operation
I got this list: input = [[1,2,3,4],[5,6,7,8],[9,10,11,12]] I want to make new lists with each index item: i.e. output = [[1,5,9],[2,6,10],[3,7,11],[4,8,12]]
[ "This is a canonical example of when to use zip:\nIn [6]: inlist = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]\n\nIn [7]: out=zip(*inlist)\n\nIn [8]: out\nOut[8]: [(1, 5, 9), (2, 6, 10), (3, 7, 11), (4, 8, 12)]\n\nOr, to get a list of lists (rather than list of tuples):\nIn [9]: out=[list(group) for group in zip(*inlist)]\n...
[ 8, 4 ]
[]
[]
[ "list", "python" ]
stackoverflow_0005285053_list_python.txt
Q: Sharing database data for plug-ins in python I'm writing a program to run certain tests involving data from two databases. The idea is that such tests be implemented as plug-ins (I'm currently using the Yapsy plug-in framework). One test can be, for example, to check if some fields in one table row in the first da...
Sharing database data for plug-ins in python
I'm writing a program to run certain tests involving data from two databases. The idea is that such tests be implemented as plug-ins (I'm currently using the Yapsy plug-in framework). One test can be, for example, to check if some fields in one table row in the first database are equal to other fields in one table row ...
[ "If you're going to retrieve the data and then process it, and the structure of the data is known beforehand, you could make each plugin declare the data that it uses: tables or tables/columns. \nThen you could create a dictionary of tables => plugins, and pass each plugin the data that it needs when you load its t...
[ 0 ]
[]
[]
[ "data_sharing", "plugins", "python" ]
stackoverflow_0005284312_data_sharing_plugins_python.txt
Q: Python 2.4 OAuth compatibilty I have installed python oauth on my python2.4 platform, however making the python twitter package work requires some tweaks in oauth.. I am quite new to python but I assume I cannot alter the egg.. how do I install a non-egg version and how do I remove the egg safely ? A: Python egg...
Python 2.4 OAuth compatibilty
I have installed python oauth on my python2.4 platform, however making the python twitter package work requires some tweaks in oauth.. I am quite new to python but I assume I cannot alter the egg.. how do I install a non-egg version and how do I remove the egg safely ?
[ "Python eggs (like java jar files) use the zip format. So to answer your question on how to make your tweaks:\n\nFind the file location \nNavigate to location, make a backup copy\nIf the file is stored as oauth.egg, unzip it\nStart modifying!\n\nFind the egg location\nOpen up a python interpreter and run the follo...
[ 0 ]
[]
[]
[ "django", "oauth", "python" ]
stackoverflow_0005277326_django_oauth_python.txt
Q: Strange behavior of MySQL SELECT When the variable NUMBER_OF_ITERATIONS is set to 1, everything works fine...but when I change it to any value greater than 1 I get some problems. First of all, in this case when i print the value of res i get an huge number (like 18446744073709551615). Second, but most important, i...
Strange behavior of MySQL SELECT
When the variable NUMBER_OF_ITERATIONS is set to 1, everything works fine...but when I change it to any value greater than 1 I get some problems. First of all, in this case when i print the value of res i get an huge number (like 18446744073709551615). Second, but most important, in this case the script can't process d...
[ "I was unable to reproduce the problem using the following code. Can you modify it to demonstrate the error?\nimport config\nimport MySQLdb\nimport multiprocessing as mp\nimport random\nimport string\nimport time\n\ndef random_string(n):\n return ''.join(random.choice(string.letters) for _ in range(n))\n\ndef ge...
[ 2 ]
[]
[]
[ "mysql", "python" ]
stackoverflow_0005284475_mysql_python.txt
Q: Trying to execute an 'advanced' query in SQLAlchemy but I'm stuck The query I'm trying to execute is this one. I've pasted it below: SELECT p.id, p.title, p.time_submitted, SUM(v.score) as num_votes FROM posts p, votes v WHERE v.postid = p.id GROUP BY p.id ORDER BY (SUM(v.score) - 1) / POW(TIMESTAMPDIFF(HOUR,...
Trying to execute an 'advanced' query in SQLAlchemy but I'm stuck
The query I'm trying to execute is this one. I've pasted it below: SELECT p.id, p.title, p.time_submitted, SUM(v.score) as num_votes FROM posts p, votes v WHERE v.postid = p.id GROUP BY p.id ORDER BY (SUM(v.score) - 1) / POW(TIMESTAMPDIFF(HOUR,p.time_submitted,NOW()) + INTERVAL 2 HOUR, 1.8) DESC LIMIT 100 I was g...
[ "As you've already stated, there are functions in your query that are unsupported in sqlite (e.g., \"pow\"). Using the SA expression functions to construct your query will not help you in this case, as the resulting query will still contain the \"pow\" function that sqlite does not support.\nOf course, besides the ...
[ 0 ]
[]
[]
[ "orm", "python", "sql", "sqlalchemy" ]
stackoverflow_0005281535_orm_python_sql_sqlalchemy.txt
Q: Python: appengine urllib2 headers from a 302 A normal urllib2 works fine: >>> import urllib2 >>> r = urllib2.urlopen(u"http://bit.ly/4ovTZw") >>> r.geturl() 'http://www.writing.com/main/handler/action/show_document/item_id/933413.mp3' >>> r.headers.get("Content-Type") 'audio/mpeg' But in appengine, the same code ...
Python: appengine urllib2 headers from a 302
A normal urllib2 works fine: >>> import urllib2 >>> r = urllib2.urlopen(u"http://bit.ly/4ovTZw") >>> r.geturl() 'http://www.writing.com/main/handler/action/show_document/item_id/933413.mp3' >>> r.headers.get("Content-Type") 'audio/mpeg' But in appengine, the same code shows text/html. def get(self): r = urllib2.ur...
[ "I know for a fact that AppEngine blacklists some addresses - check your response body for a hint. \nIt might also be the other way around - some services blacklist AppEngine... I am not sure. I remember in the early days of GAE, accessing Delicious was not possible through AppEngine.\n", "I have just tried to ...
[ 0, 0 ]
[]
[]
[ "google_app_engine", "header", "python", "urllib2" ]
stackoverflow_0001698487_google_app_engine_header_python_urllib2.txt
Q: Adding data to a nested list in Python I have a nested list e.g.: nlist = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], ] Before I insert this list into a database, I would like to add a "column" to it with the same value in each row of the new column e.g: nlist = [ [a, 1, 2,...
Adding data to a nested list in Python
I have a nested list e.g.: nlist = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], ] Before I insert this list into a database, I would like to add a "column" to it with the same value in each row of the new column e.g: nlist = [ [a, 1, 2, 3], [a, 4, 5, 6], ...
[ "Why not change the original list (if that is all you want to do):\nfor row in nlist:\n row.insert(0, a)\n\n", "If you are looking to create a new list then this will work as well...\nnlistnew = [[a]+row for row in nlist]\n\nEDIT: Fixed code as per Felix Kling's comment. Thanks!\n", "Iterate over your outer ...
[ 7, 2, 0 ]
[]
[]
[ "nested_lists", "python" ]
stackoverflow_0005285521_nested_lists_python.txt
Q: How to solve this "NotImplementedError" urllib2 / gevent error on windows? I'm trying to open an url with urllib2 patched with gevent on Windows XP: from gevent import monkey monkey.patch_all() import urllib2 opener = urllib2.build_opener() request = urllib2.Request("http://www.google.com") response = opener.open...
How to solve this "NotImplementedError" urllib2 / gevent error on windows?
I'm trying to open an url with urllib2 patched with gevent on Windows XP: from gevent import monkey monkey.patch_all() import urllib2 opener = urllib2.build_opener() request = urllib2.Request("http://www.google.com") response = opener.open(request) And I get this exception during the opener.open call: File "C:\Python...
[ "Try making your request to http://ipv4.google.com/ instead.\n" ]
[ 2 ]
[]
[]
[ "gevent", "ipv6", "python", "urllib2", "windows" ]
stackoverflow_0005285326_gevent_ipv6_python_urllib2_windows.txt
Q: I want to get the class of a subclass Can I, in a class that is meant to be subclassed, get the class variable for an instance of its children? Something like this: class A: ... def doStuff(self): c = getChildClass(self) setattr(c, 'anAttribute', value) There is some interesting memoizati...
I want to get the class of a subclass
Can I, in a class that is meant to be subclassed, get the class variable for an instance of its children? Something like this: class A: ... def doStuff(self): c = getChildClass(self) setattr(c, 'anAttribute', value) There is some interesting memoization I want to do, and this would make the ta...
[ "If you mean the class of the instance itself, use self.__class__.\n", "In [1]: class A(object):\n ...: def doStuff(self):\n ...: c = self.__class__\n ...: print c, c.__name__\n ...: setattr(c, 'moo', 'meow')\n\nIn [2]: class B(A):\n ...: pass\n ...:\n\nIn [3]: B().doSt...
[ 4, 1 ]
[]
[]
[ "python" ]
stackoverflow_0005285825_python.txt
Q: Unicode issue, correctly decoding/encoding string in python I'm using BeautifulSoup, and I get back a string like this: u'Dassault Myst\xe8re' It's a unicode, but what I want is to make it look like: 'Dassault Mystère' I have tried name = name.encode('utf-8'), decode(), unicode() The error I keep getting is: U...
Unicode issue, correctly decoding/encoding string in python
I'm using BeautifulSoup, and I get back a string like this: u'Dassault Myst\xe8re' It's a unicode, but what I want is to make it look like: 'Dassault Mystère' I have tried name = name.encode('utf-8'), decode(), unicode() The error I keep getting is: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' ...
[ "I do not know how and where you get this message, but look at this exmple:\n$ python\nPython 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) \n[GCC 4.2.1 (Apple Inc. build 5646)] on darwin\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> txt = u'Dassault Myst\\xe8re'\n>>> txt\nu'Dassa...
[ 1 ]
[]
[]
[ "ascii", "python", "unicode", "utf_8" ]
stackoverflow_0005285896_ascii_python_unicode_utf_8.txt
Q: Python: Suppress exponential format (i.e. 9e-10) in float to string conversion? I want to use python to write code for another language which doesn't understand exponentially formatted floats. Is there an easy way to get python to, when converting floats to strings, use long-form notation (I.E. 0.000000009 instead...
Python: Suppress exponential format (i.e. 9e-10) in float to string conversion?
I want to use python to write code for another language which doesn't understand exponentially formatted floats. Is there an easy way to get python to, when converting floats to strings, use long-form notation (I.E. 0.000000009 instead of 9e-9)? I tried '%(foo)f', but it cuts the decimal short (0.00000).
[ "Try something like\n\"%.16f\" % f\n\nThis will still use exponential format if the number is too small, so you have to treat this case separately, for example\n\"%.16f\" % f if f >= 1e-16 else \"0.0\"\n\n", "Use a specific format specifier, e.g.:\n>>> f=9*(10**-9)\n>>> str(f)\n'9e-09'\n>>> \"%.23f\" % f\n'0.0000...
[ 2, 0 ]
[]
[]
[ "floating_point", "python", "string_formatting" ]
stackoverflow_0005286022_floating_point_python_string_formatting.txt
Q: Using document length in the Naive Bayes Classifier of NLTK Python I am building a spam filter using the NLTK in Python. I now check for the occurances of words and use the NaiveBayesClassifier resulting in an accuracy of .98 and F measure for spam of .92 and for non-spam: 0.98. However when checking the documents...
Using document length in the Naive Bayes Classifier of NLTK Python
I am building a spam filter using the NLTK in Python. I now check for the occurances of words and use the NaiveBayesClassifier resulting in an accuracy of .98 and F measure for spam of .92 and for non-spam: 0.98. However when checking the documents in which my program errors I notice that a lot of spam that is classifi...
[ "There are MultiNomial NaiveBayes algorithms that can handle range values, but not implemented in NLTK. For the NLTK NaiveBayesClassifier, you could try having a couple different length thresholds as binary features. I'd also suggest trying a Maxent Classifier to see how it handles smaller text.\n", "NLTK's imple...
[ 3, 3 ]
[]
[]
[ "feature_detection", "nltk", "python", "spam_prevention" ]
stackoverflow_0005248100_feature_detection_nltk_python_spam_prevention.txt
Q: How to Show DB Query Response in Tkinter I'm a really rookie to Tkinter so excuse my lack of vision here. What I'm trying to accomplish is the following: give the user 3 text fields that are queryable fields, a submit button to execute the query, and a way to display the results. As far as the DB query goes, I'm t...
How to Show DB Query Response in Tkinter
I'm a really rookie to Tkinter so excuse my lack of vision here. What I'm trying to accomplish is the following: give the user 3 text fields that are queryable fields, a submit button to execute the query, and a way to display the results. As far as the DB query goes, I'm totally fine with SQL and Python. The hard part...
[ "Assuming each record is one line, create a tag for each line (from line_num.0 to line_num.end). For each tag, use text.tag_bind and bind your tag to '<Button-1>' to detect mouse click. Use a lambda in the callback to return your row number to the event handler.\nHere's a toy example that does just that:\nfrom T...
[ 2, 2 ]
[]
[]
[ "python", "record", "sql", "text", "tkinter" ]
stackoverflow_0005285058_python_record_sql_text_tkinter.txt
Q: Setting Property via a String I'm trying to set a Python class property outside of the class via the setattr(self, item, value) function. class MyClass: def getMyProperty(self): return self.__my_property def setMyProperty(self, value): if value is None: value = '' self....
Setting Property via a String
I'm trying to set a Python class property outside of the class via the setattr(self, item, value) function. class MyClass: def getMyProperty(self): return self.__my_property def setMyProperty(self, value): if value is None: value = '' self.__my_property = value my_prope...
[ "Works for me:\n>>> class MyClass(object):\n... def get(self): return 10\n... def setprop(self, val): raise ValueError(\"hax%s\"%str(val))\n... prop = property(get, setprop)\n...\n>>> i = MyClass()\n>>> i.prop =4\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\n File \"<stdin>\",...
[ 4 ]
[]
[]
[ "properties", "python", "setattr" ]
stackoverflow_0005286083_properties_python_setattr.txt
Q: Read lists and dicts from file without exec Currently I have this code, which reads from a file containing something similar to [{'1': {'Score': '2', 'Class': '3'}}] and assigns it to a variable: exec('assigns = ' + open(r'D:\Dropbox\Dev\Output\dict', 'r').read()) However, I have been told that using exec is dang...
Read lists and dicts from file without exec
Currently I have this code, which reads from a file containing something similar to [{'1': {'Score': '2', 'Class': '3'}}] and assigns it to a variable: exec('assigns = ' + open(r'D:\Dropbox\Dev\Output\dict', 'r').read()) However, I have been told that using exec is dangerous. How can I write the same code without usin...
[ "Use ast.literal_eval():\nassigns = ast.literal_eval(open(r'D:\\Dropbox\\Dev\\Output\\dict', 'r').read())\n\nIt will only evaluate literals, no function calls or operators.\n", ">>> data = \"\"\"[{'1': {'Score': '2', 'Class': '3'}}]\"\"\" # example; get this from file\n>>> import ast\n>>> x = ast.literal_eval(dat...
[ 7, 1 ]
[]
[]
[ "exec", "io", "python", "unsafe" ]
stackoverflow_0005286128_exec_io_python_unsafe.txt
Q: Handle Form Failure when uploading to Appengine Blobstore I'm using @wkornewald 's django-nonrel and django-filetransfer on Google App Engine. I'm able to upload files just fine, but only when the entire form is valid. If the form fails validation for any field, it completely blows up instead of returning to the u...
Handle Form Failure when uploading to Appengine Blobstore
I'm using @wkornewald 's django-nonrel and django-filetransfer on Google App Engine. I'm able to upload files just fine, but only when the entire form is valid. If the form fails validation for any field, it completely blows up instead of returning to the user to fix the changes. error message is: INFO 2011-03-10...
[ "The blobstore api requires the upload handler view to return a redirect. \nas the error log posted above states:\n\nOnly 301, 302 and 303 statuses are permitted and it may not have a content body.\n\nTo work around this, I modified the add_view and change_view methods of the ModelAdmin to return a redirect on a fo...
[ 2 ]
[]
[]
[ "django", "django_forms", "django_nonrel", "google_app_engine", "python" ]
stackoverflow_0005272827_django_django_forms_django_nonrel_google_app_engine_python.txt
Q: Why are my threaded MySQLdb queries in Python slower than the same non-threaded queries? I am building a threaded class to run MySQL queries using Python and MySQLdb. I don't understand why running these queries threaded is slower than running them non-threaded. Here's my code to show what I'm doing. First, he...
Why are my threaded MySQLdb queries in Python slower than the same non-threaded queries?
I am building a threaded class to run MySQL queries using Python and MySQLdb. I don't understand why running these queries threaded is slower than running them non-threaded. Here's my code to show what I'm doing. First, here's the non-threaded function. def testQueryDo(query_list): db = MySQLdb.connect('localh...
[ "You're starting N threads, each of which creates its own connection to MySQL, and you're using a synchronous queue to deliver the queries to the threads. Each thread is blocking on queue.get() (acquiring an exclusive lock) to get a query, then creating a connection to the database, and then calling task_done() whi...
[ 0 ]
[]
[]
[ "multithreading", "mysql", "python" ]
stackoverflow_0005286100_multithreading_mysql_python.txt