content stringlengths 85 101k | title stringlengths 0 150 | question stringlengths 15 48k | answers list | answers_scores list | non_answers list | non_answers_scores list | tags list | name stringlengths 35 137 |
|---|---|---|---|---|---|---|---|---|
Q:
How to access the session object in Django Syndication framework code
Quick question. In my syndication feed framework code,
http://docs.djangoproject.com/en/dev/ref/contrib/syndication/
what is the best way to get access to the session? I don't have
access to the request, and I can't use
from django.contrib... | How to access the session object in Django Syndication framework code | Quick question. In my syndication feed framework code,
http://docs.djangoproject.com/en/dev/ref/contrib/syndication/
what is the best way to get access to the session? I don't have
access to the request, and I can't use
from django.contrib.sessions.backends.db import SessionStore
as I don't know the session ID,... | [
"It seems like a design flaw to be trying to access session data in the LatestPhoto's class. I would assume that if your syndication feed depended on a session variable, then the items you're syndicating (LatestPhotos) should be constructed with that variable?\nCan you make the logic flow decision before you const... | [
2,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0000972267_django_python.txt |
Q:
Python and reading lines
When i run an .exe file it prints stuff out to the screen. I don't know the specific line of where i want printed out but is there a way I can get python to print the next line after one that says "Summary" ? I know that is in there when it prints and I need the info right after. Thanks!
... | Python and reading lines | When i run an .exe file it prints stuff out to the screen. I don't know the specific line of where i want printed out but is there a way I can get python to print the next line after one that says "Summary" ? I know that is in there when it prints and I need the info right after. Thanks!
| [
"Really simple Python solution:\ndef getSummary(s):\n return s[s.find('\\nSummary'):]\n\nThis returns everything after the first instance of Summary\nIf you need to be more specific, I'd recommend regular expressions.\n",
"actually \nprogram.exe | grep -A 1 Summary \n\nwould do your job.\n",
"If the exe prin... | [
3,
2,
1
] | [] | [] | [
"command_prompt",
"printing",
"python"
] | stackoverflow_0000970975_command_prompt_printing_python.txt |
Q:
Why is Logging going in an infinite Loop?
I have the following code:
#!/usr/bin/env python
import logging
import sys
import copy
class Wrapper:
def write(self, s):
#sys.__stdout__.write(s)
loggy = logging.getLogger('foobar')
loggy.info(s)
def blah():
logger = logging.getLogger('fo... | Why is Logging going in an infinite Loop? | I have the following code:
#!/usr/bin/env python
import logging
import sys
import copy
class Wrapper:
def write(self, s):
#sys.__stdout__.write(s)
loggy = logging.getLogger('foobar')
loggy.info(s)
def blah():
logger = logging.getLogger('foobar')
logger.setLevel(logging.DEBUG)
s... | [
"The infinite loop is happening because your logger's StreamHandler is set to write its log messages to sys.stdout, but sys.stdout is in turn wrapped and writes back to the very logger that just sent it a write message.\nDepending on your goals, you're probably better having the Wrapper actually perform output, rat... | [
6
] | [] | [] | [
"logging",
"python"
] | stackoverflow_0000975456_logging_python.txt |
Q:
What is the proper way to compute the fully expanded width of wx.TreeCtrl
The preferred size of the wx.TreeCtrl seems to be the minimum size into which all elements will fit when the tree is completely collapsed. Is there a good (ie cross-platform compatible) way to compute the width of the tree with everything e... | What is the proper way to compute the fully expanded width of wx.TreeCtrl | The preferred size of the wx.TreeCtrl seems to be the minimum size into which all elements will fit when the tree is completely collapsed. Is there a good (ie cross-platform compatible) way to compute the width of the tree with everything expanded? My current solution is this:
def max_width(self):
dc = wx.ScreenD... | [
"I find that the GetBestSize seems to consider the collapsed items. For example, with the wxTreeCtrl in the demo (using Ubuntu, and wxPython 2.8.7.1), when I change the length of the inner text string (line 74 in my version of the demo) the return value of self.tree.GetBestSize() does take this new length of the i... | [
1,
0
] | [] | [] | [
"python",
"size",
"wxpython"
] | stackoverflow_0000960489_python_size_wxpython.txt |
Q:
Distributing Ruby/Python desktop apps
Is there any way besides Shoes to develop and distribute cross-platform GUI desktop applications written in Ruby?
I come to believe that general bugginess of _why's applications is exceptionally crippling in case of Shoes, and anything more complex than a two-button form is a ... | Distributing Ruby/Python desktop apps | Is there any way besides Shoes to develop and distribute cross-platform GUI desktop applications written in Ruby?
I come to believe that general bugginess of _why's applications is exceptionally crippling in case of Shoes, and anything more complex than a two-button form is a pain to maintain.
RubyGTK, wxRuby, etc seem... | [
"I don't know about ruby2exe, but py2exe works perfeclty fine. Even with librairies like wxWidgets. Edit: you don't even have to ask the user to install wxWidgets, it's bundled with the app (same goes for py2app)\nI use it for my very small project here.\nFor the Mac crowd, py2app works fine too with wxWidgets.\n",... | [
11,
8,
6,
2,
1,
0
] | [
"I've read about (but not used) Seattlerb's Wilson, which describes itself as a pure x86 assembler, but it doesn't sound like it'd be cross-platform or GUI.\n"
] | [
-2
] | [
"desktop",
"python",
"ruby",
"software_distribution",
"user_interface"
] | stackoverflow_0000940149_desktop_python_ruby_software_distribution_user_interface.txt |
Q:
redirecting sys.stdout to python logging
So right now we have a lot of python scripts and we are trying to consolidate them and fix and redundancies. One of the things we are trying to do, is to ensure that all sys.stdout/sys.stderr goes into the python logging module.
Now the main thing is, we want the following ... | redirecting sys.stdout to python logging | So right now we have a lot of python scripts and we are trying to consolidate them and fix and redundancies. One of the things we are trying to do, is to ensure that all sys.stdout/sys.stderr goes into the python logging module.
Now the main thing is, we want the following printed out:
[<ERROR LEVEL>] | <TIME> | <WHER... | [
"The problem is that the logging module is looking a single layer up the call stack to find who called it, but now your function is an intermediate layer at that point (Though I'd have expected it to report cleanMsg, not __init__, as that's where you're calling into log()). Instead, you need it to go up two level... | [
6,
2
] | [] | [] | [
"logging",
"python"
] | stackoverflow_0000975248_logging_python.txt |
Q:
Perl and CopSSH
I'm trying to automate a process on a remote machine using a python script. The machine is a windows machine and I've installed CopSSH on it in order to SSH into it to run commands. I'm having trouble getting perl scripts to run from the CopSSH terminal. I get a command not found error. Is there a ... | Perl and CopSSH | I'm trying to automate a process on a remote machine using a python script. The machine is a windows machine and I've installed CopSSH on it in order to SSH into it to run commands. I'm having trouble getting perl scripts to run from the CopSSH terminal. I get a command not found error. Is there a special way that I ha... | [
"I suspect CopSSH is giving you different environment vars to a normal GUI login. I'd suggest you type 'set' and see if perl is in the path with any other environment vars it might need. \nHere is some explanation of setting up the CopSSH user environment. It may be of use.\n",
"I just realized CopSSH is based on... | [
4,
3,
2
] | [] | [] | [
"openssh",
"perl",
"python",
"ssh"
] | stackoverflow_0000975785_openssh_perl_python_ssh.txt |
Q:
cx_Oracle And User Defined Types
Does anyone know an easier way to work with user defined types in Oracle using cx_Oracle?
For example, if I have these two types:
CREATE type my_type as object(
component varchar2(30)
,key varchar2(100)
,value varchar2(4000))
/
CREATE type my_type_tab as table of my_type
/
... | cx_Oracle And User Defined Types | Does anyone know an easier way to work with user defined types in Oracle using cx_Oracle?
For example, if I have these two types:
CREATE type my_type as object(
component varchar2(30)
,key varchar2(100)
,value varchar2(4000))
/
CREATE type my_type_tab as table of my_type
/
And then a procedure in package my_pac... | [
"While cx_Oracle can select user defined types, it does not to my knowledge support passing in user defined types as bind variables. So for example the following will work:\ncursor.execute(\"select my_type('foo', 'bar', 'hello') from dual\")\nval, = cursor.fetchone()\nprint val.COMPONENT, val.KEY, val.VALUE\n\nHow... | [
3,
0
] | [
"I'm not quite sure what you mean by hard-coded, but you can build a dynamic array like this:\nSQL> desc my_procedure\nParameter Type Mode Default? \n--------- ----------- ---- -------- \nP_IN MY_TYPE_TAB IN \n\nSQL> declare\n 2 l_tab my_type_tab;\n 3 begin\n 4 select my_type(owner, table_... | [
-1
] | [
"cx_oracle",
"oracle",
"python"
] | stackoverflow_0000971250_cx_oracle_oracle_python.txt |
Q:
Eclipse + local CVS + PyDev
I tried several Python IDEs (on Windows platform) but finally I found only Eclipse + PyDev meeting my needs. This set of tools is really comfortable and easy to use. I'm currently working on a quite bigger project. I'd like to have a possibility to use CVS or any other version control s... | Eclipse + local CVS + PyDev | I tried several Python IDEs (on Windows platform) but finally I found only Eclipse + PyDev meeting my needs. This set of tools is really comfortable and easy to use. I'm currently working on a quite bigger project. I'd like to have a possibility to use CVS or any other version control system which would be installed on... | [
"Last time I tried this, Eclipse did not support direct access to local repositories in the same way that command line cvs does because command line cvs has both client and server functionality whereas Eclipse only has client functionality and needs to go through (e.g.) pserver, so you would probably need to have a... | [
4,
1,
1,
1,
1,
0,
0,
0
] | [] | [] | [
"cvs",
"eclipse",
"pydev",
"python"
] | stackoverflow_0000969121_cvs_eclipse_pydev_python.txt |
Q:
Can Python adodbapi be used to connect to a paradox db?
Can Python adodbapi be used to connect to a paradox db? If yes what would the connection string look like?
A:
Yes, that depends on the Paradox ADODB driver you have installed in your windows.
Examples:
For Paradox 5.x, using Microsoft Jet OLEDB 4.0 driver:
... | Can Python adodbapi be used to connect to a paradox db? | Can Python adodbapi be used to connect to a paradox db? If yes what would the connection string look like?
| [
"Yes, that depends on the Paradox ADODB driver you have installed in your windows.\nExamples:\nFor Paradox 5.x, using Microsoft Jet OLEDB 4.0 driver:\nr\"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\myDb;\nExtended Properties=Paradox 5.x;\"\n\nFor Paradox 5.x, using Microsoft's Paradox ODBC Driver:\nr\"Driver={... | [
0
] | [] | [] | [
"paradox",
"python"
] | stackoverflow_0000976324_paradox_python.txt |
Q:
How can I make lxml's parser preserve whitespace outside of the root element?
I am using lxml to manipulate some existing XML documents, and I want to introduce as little diff noise as possible. Unfortunately by default lxml.etree.XMLParser doesn't preserve whitespace before or after the root element of a document... | How can I make lxml's parser preserve whitespace outside of the root element? | I am using lxml to manipulate some existing XML documents, and I want to introduce as little diff noise as possible. Unfortunately by default lxml.etree.XMLParser doesn't preserve whitespace before or after the root element of a document:
>>> xml = '\n <etaoin>shrdlu</etaoin>\n'
>>> lxml.etree.tostring(lxml.etree.fr... | [
"I don't know of any XML library that will do it for you. But using a regex sounds like a decent idea if you really need to do this.\n>>> xml = '\\n <etaoin>shrdlu</etaoin>\\n'\n>>> head, tail = re.findall(r\"^\\s*|\\s*$\", xml)[:2]\n>>> root = etree.fromstring(xml)\n>>> out = head + etree.tostring(root) + tail\... | [
1,
0
] | [] | [] | [
"lxml",
"python",
"whitespace",
"xml"
] | stackoverflow_0000973079_lxml_python_whitespace_xml.txt |
Q:
Can I make Python 2.5 exit on ctrl-D in Windows instead of ctrl-Z?
I'm used to ending the python interactive interpreter using Ctrl-d using Linux and OS X. On windows though, you have to use CTRL+Z and then enter. Is there any way to use CTRL+D?
A:
You can't use CTRL+D on windows.
CTRL+Z is a windows-specific... | Can I make Python 2.5 exit on ctrl-D in Windows instead of ctrl-Z? | I'm used to ending the python interactive interpreter using Ctrl-d using Linux and OS X. On windows though, you have to use CTRL+Z and then enter. Is there any way to use CTRL+D?
| [
"You can't use CTRL+D on windows. \nCTRL+Z is a windows-specific control char that prints EOF. On *nix, it is typically CTRL+D. That's the reason for the difference.\nYou can, however, train yourself to use exit(), which is cross-platform.\n",
"Ctrl-d works to exit from IPython \n(installed by python(x,y) package... | [
9,
6,
0,
0
] | [] | [] | [
"python",
"python_2.5",
"windows"
] | stackoverflow_0000976796_python_python_2.5_windows.txt |
Q:
static stylesheets gets reloaded with each post request
Every time there is a post from page the entire bunch of css gets reloaded. Is it possible to tell them not to come in again and again. There is a series of GET that get fired. Can we optimize in some way or is it normal behavior?
The environment is google ap... | static stylesheets gets reloaded with each post request | Every time there is a post from page the entire bunch of css gets reloaded. Is it possible to tell them not to come in again and again. There is a series of GET that get fired. Can we optimize in some way or is it normal behavior?
The environment is google apps in python.
| [
"Check out Using Static Files and Handlers for Static Files. Since the latter link refer to cache duration of static files, I believe the the caching functionality is possible.\n\nUnlike a traditional web hosting\n environment, Google App Engine does\n not serve files directly out of your\n application's source ... | [
2,
1,
0
] | [] | [] | [
"css",
"get",
"google_app_engine",
"post",
"python"
] | stackoverflow_0000976898_css_get_google_app_engine_post_python.txt |
Q:
How to expose client_address to all methods, using xmlrpclib?
I create little SimpleXMLRPCServer for check ip of client.
I try this:
Server
import xmlrpclib
from SimpleXMLRPCServer import SimpleXMLRPCServer
server = SimpleXMLRPCServer(("localhost", 8000))
def MyIp():
return "Your ip is: %s" % server.socket.get... | How to expose client_address to all methods, using xmlrpclib? | I create little SimpleXMLRPCServer for check ip of client.
I try this:
Server
import xmlrpclib
from SimpleXMLRPCServer import SimpleXMLRPCServer
server = SimpleXMLRPCServer(("localhost", 8000))
def MyIp():
return "Your ip is: %s" % server.socket.getpeername()
server.register_function(MyIp)
server.serve_forever()
Cl... | [
"If you want for example to pass client_address as the first argument to every function, you could subclass SimpleXMLRPCRequestHandler (pass your subclass as the handler when you instantiate SimpleXMLRPCServer) and override _dispatch (to prepend self.client_address to the params tuple and then delegate the rest to ... | [
3
] | [] | [] | [
"python",
"xmlrpclib"
] | stackoverflow_0000978784_python_xmlrpclib.txt |
Q:
Is it more efficient to parse external XML or to hit the database?
I was wondering when dealing with a web service API that returns XML, whether it's better (faster) to just call the external service each time and parse the XML (using ElementTree) for display on your site or to save the records into the database (... | Is it more efficient to parse external XML or to hit the database? | I was wondering when dealing with a web service API that returns XML, whether it's better (faster) to just call the external service each time and parse the XML (using ElementTree) for display on your site or to save the records into the database (after parsing it once or however many times you need to each day) and ma... | [
"First off -- measure. Don't just assume that one is better or worse than the other.\nSecond, if you really don't want to measure, I'd guess the database is a bit faster (assuming the database is relatively local compared to the web service). Network latency usually is more than parse time unless we're talking a ... | [
6,
4,
3,
1,
1,
0,
0,
0
] | [
"It sounds like you essentially want to cache results, and are wondering if it's worth it. But if so, I would NOT use a database (I assume you are thinking of a relational DB): RDBMSs are not good for caching; even though many use them. You don't need persistence nor ACID.\nIf choice was between Oracle/MySQL and ex... | [
-1
] | [
"django",
"mysql",
"parsing",
"python",
"xml"
] | stackoverflow_0000978581_django_mysql_parsing_python_xml.txt |
Q:
Thinking in AppEngine
I'm looking for resources to help migrate my design skills from traditional RDBMS data store over to AppEngine DataStore (ie: 'Soft Schema' style). I've seen several presentations and all touch on the the overarching themes and some specific techniques.
I'm wondering if there's a place we co... | Thinking in AppEngine | I'm looking for resources to help migrate my design skills from traditional RDBMS data store over to AppEngine DataStore (ie: 'Soft Schema' style). I've seen several presentations and all touch on the the overarching themes and some specific techniques.
I'm wondering if there's a place we could pool knowledge from exp... | [
"\nI'm wondering if there's a place we could pool knowledge from experience\n\nVarious Google Groups are good for that, though I don't know if any are directly applicable to Java-GAE yet -- my GAE experience so far is all-Python (I'm kind of proud to say that Guido van Rossum, inventor of Python and now working at ... | [
5,
1,
1,
1
] | [] | [] | [
"data_modeling",
"google_app_engine",
"java",
"python"
] | stackoverflow_0000976639_data_modeling_google_app_engine_java_python.txt |
Q:
Extracting IP from request in Python
I have a Pythonic HTTP server that is supposed to determine client's IP. How do I do that in Python? Is there any way to get the request headers and extract it from there?
PS: I'm using WebPy.
A:
Use web.ctx:
class example:
def GET(self):
print web.ctx.ip
More in... | Extracting IP from request in Python | I have a Pythonic HTTP server that is supposed to determine client's IP. How do I do that in Python? Is there any way to get the request headers and extract it from there?
PS: I'm using WebPy.
| [
"Use web.ctx:\nclass example:\n def GET(self):\n print web.ctx.ip\n\nMore info here\n",
"web.env.get('REMOTE_ADDR')\n"
] | [
4,
3
] | [] | [] | [
"header",
"http",
"ip",
"python",
"request"
] | stackoverflow_0000979599_header_http_ip_python_request.txt |
Q:
Sending email using google apps SMTP server in Python 2.4
I'm having difficulty getting python 2.4 to connect to gmail's smtp server. My below script doesn't ever get past "connection". I realise there is an SMTP_SSL class in later versions of python and it seems to work fine, but the production environment I have... | Sending email using google apps SMTP server in Python 2.4 | I'm having difficulty getting python 2.4 to connect to gmail's smtp server. My below script doesn't ever get past "connection". I realise there is an SMTP_SSL class in later versions of python and it seems to work fine, but the production environment I have to deal with only has - and likely will only ever have - pytho... | [
"When I tried setting something similar up for Django apps, I could never get it to work on port 465. Using port 587, which is the other port listed in the GMail docs seemed to work.\n",
"Yes I used 587 as the port for my vb.net app too. 465 did not work for me too.\n",
"try\nserver.ehlo('user.name@gmail.com')\... | [
3,
1,
1
] | [] | [] | [
"python",
"python_2.4"
] | stackoverflow_0000975065_python_python_2.4.txt |
Q:
Trying to create a Python Server
I am looking at trying to create a python server, which allows me to run root commands on a Centos Server remotely, I would also like the server to be able to respond with the result's of the command.
I have found another question on here which has a basic python server, however it... | Trying to create a Python Server | I am looking at trying to create a python server, which allows me to run root commands on a Centos Server remotely, I would also like the server to be able to respond with the result's of the command.
I have found another question on here which has a basic python server, however it throws a error, the code is:
#!/usr/b... | [
"you need to keep indentation at the same level for each nested statement throughout your code.\n",
"On a different note: why not using TwistedMatrix?\n"
] | [
2,
2
] | [] | [] | [
"python",
"syntax_error"
] | stackoverflow_0000981033_python_syntax_error.txt |
Q:
Send output from a python server back to client
I now have a small java script server working correctly, called by:
<?php
$handle = fsockopen("udp://78.129.148.16",12345);
fwrite($handle,"vzctlrestart110");
fclose($handle);
?>
On a remote server the following python server is running and executing the coman... | Send output from a python server back to client | I now have a small java script server working correctly, called by:
<?php
$handle = fsockopen("udp://78.129.148.16",12345);
fwrite($handle,"vzctlrestart110");
fclose($handle);
?>
On a remote server the following python server is running and executing the comand's
#!/usr/bin/python
import os
import socket
print "... | [
"Yes, you can read the output of the command. For this I would recommend the Python subprocess module. Then you can just s.write() it back.\nNaturally this has some implications, you would probably have to let your PHP script run for a while longer since the process may be running slow.\n# The pipe behaves like a f... | [
1,
0
] | [] | [] | [
"python",
"sockets"
] | stackoverflow_0000981348_python_sockets.txt |
Q:
Can Windows drivers be written in Python?
Can Windows drivers be written in Python?
A:
Yes. You cannot create the "classic" kernel-mode drivers. However, starting with XP, Windows offers a User-Mode Driver Framework. They can't do everything, obviously - any driver used in booting the OS obviously has to be kern... | Can Windows drivers be written in Python? | Can Windows drivers be written in Python?
| [
"Yes. You cannot create the \"classic\" kernel-mode drivers. However, starting with XP, Windows offers a User-Mode Driver Framework. They can't do everything, obviously - any driver used in booting the OS obviously has to be kernel-mode. But with UMDF, you only need to implement COM components. \nBesides boot-time ... | [
18,
3,
3,
1,
1,
0,
0
] | [] | [] | [
"drivers",
"python",
"windows"
] | stackoverflow_0000981200_drivers_python_windows.txt |
Q:
Python QuickBase API Help
Hey, I'm having some trouble using the QuickBase API from Python. From the QuickBase guide, there are two methods of hitting the API: POST and GET. I can handle the GET calls, but some API methods require XML to be sent over POST. The link to the documentation is here: http://member.d... | Python QuickBase API Help | Hey, I'm having some trouble using the QuickBase API from Python. From the QuickBase guide, there are two methods of hitting the API: POST and GET. I can handle the GET calls, but some API methods require XML to be sent over POST. The link to the documentation is here: http://member.developer.intuit.com/MyIDN/techn... | [
"Got it. For some reason The data I was sending in my POST needed to have a .strip() placed after it.\n"
] | [
1
] | [] | [] | [
"api",
"post",
"python",
"quickbase",
"xml"
] | stackoverflow_0000980932_api_post_python_quickbase_xml.txt |
Q:
Get original path from django filefield
My django app accepts two files (in this case a jad and jar combo). Is there a way I can preserve the folders they came from?
I need this so I can check later that they came from the same path.
(And later on accept a whole load of files and be able to work out which came fr... | Get original path from django filefield | My django app accepts two files (in this case a jad and jar combo). Is there a way I can preserve the folders they came from?
I need this so I can check later that they came from the same path.
(And later on accept a whole load of files and be able to work out which came from the same folder).
| [
"I think that is not possible, most browsers at least firefox3.0 do not allow fullpath to be seen, so even from JavaScript side you can not get full path\nIf you could get full path you can send it to server, but I think you will have to be satisfied with file name\n"
] | [
2
] | [] | [] | [
"django",
"field",
"file",
"forms",
"python"
] | stackoverflow_0000981371_django_field_file_forms_python.txt |
Q:
windows command line and Python
I have a python script that i want to run from the command line but unsure how to run it. Thanks :)
A:
I do it this way:
C:\path\to\folder> yourscript.py
A:
python myscript.py
A:
See Basic Hints for Windows Command Line Programming.
If your python installation directory is inc... | windows command line and Python | I have a python script that i want to run from the command line but unsure how to run it. Thanks :)
| [
"I do it this way:\nC:\\path\\to\\folder> yourscript.py\n\n",
"python myscript.py\n",
"See Basic Hints for Windows Command Line Programming.\nIf your python installation directory is included in %PATH% -\nC:\\> python myscript.py\n\nIf you know the installation path:\nC:\\> C:\\python26\\python myscript.py\n\nA... | [
4,
3,
3,
2,
1,
0
] | [] | [] | [
"command_line",
"python",
"windows"
] | stackoverflow_0000981691_command_line_python_windows.txt |
Q:
Using a Django custom model method property in order_by()
I'm currently learning Django and some of my models have custom methods to get values formatted in a specific way. Is it possible to use the value of one of these custom methods that I've defined as a property in a model with order_by()?
Here is an example ... | Using a Django custom model method property in order_by() | I'm currently learning Django and some of my models have custom methods to get values formatted in a specific way. Is it possible to use the value of one of these custom methods that I've defined as a property in a model with order_by()?
Here is an example that demonstrates how the property is implemented.
class Author... | [
"No, you can't do that. order_by is applied at the database level, but the database can't know anything about your custom Python methods.\nYou can either use the separate fields to order:\nAuthor.objects.order_by('first_name', 'last_name')\n\nor do the ordering in Python:\nsorted(Author.objects.all(), key=lambda a:... | [
80
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0000981375_django_django_models_python.txt |
Q:
python recursive class inclusion & instantiation
I would like to import
classes located into a folder named
some-dir/
and named class*.py
and finally instantiate them.
Wich is the best way to look inside the folder, import classes
and instantiate them?
A:
Try:
import os
#get files
files = os.listdir("some-dir/... | python recursive class inclusion & instantiation | I would like to import
classes located into a folder named
some-dir/
and named class*.py
and finally instantiate them.
Wich is the best way to look inside the folder, import classes
and instantiate them?
| [
"Try:\nimport os\n#get files\nfiles = os.listdir(\"some-dir/\")\nclasses = []\nfor f in files:\n #find python modules in file listing\n if(f.find(\".py\") != -1):\n #remove file extenstion\n f = f.rstrip(\".py\")\n #create string to add module to global namespace, import it and instantiate\n ... | [
0
] | [] | [] | [
"python"
] | stackoverflow_0000982038_python.txt |
Q:
Executing shell commands as given UID in Python
I need a way to execute the os.system() module as different UID's. It would need to behave similar to the following BASH code (note these are not the exact commands I am executing):
su user1
ls ~
mv file1
su user2
ls ~
mv file1
The target platform is GNU Linux Gener... | Executing shell commands as given UID in Python | I need a way to execute the os.system() module as different UID's. It would need to behave similar to the following BASH code (note these are not the exact commands I am executing):
su user1
ls ~
mv file1
su user2
ls ~
mv file1
The target platform is GNU Linux Generic.
Of course I could just pass these to the os.syst... | [
"I think that's not trivial: you can do that with a shell because each command is launched into its own process, which has its own id. But with python, everything will have the uid of the python interpreted process (of course, assuming you don't launch subprocesses using the subprocess module and co). I don't know ... | [
3,
2,
1,
1
] | [] | [] | [
"linux",
"os.system",
"permissions",
"python"
] | stackoverflow_0000981052_linux_os.system_permissions_python.txt |
Q:
How to tractably solve the assignment optimisation task
I'm working on a script that takes the elements from companies and pairs them up with the elements of people. The goal is to optimize the pairings such that the sum of all pair values is maximized (the value of each individual pairing is precomputed and stor... | How to tractably solve the assignment optimisation task | I'm working on a script that takes the elements from companies and pairs them up with the elements of people. The goal is to optimize the pairings such that the sum of all pair values is maximized (the value of each individual pairing is precomputed and stored in the dictionary ctrPairs).
They're all paired in a 1:1... | [
"To all those who wonder about the use of learning theory, this question is a good illustration. The right question is not about a \"fast way to bounce between lists and tuples in python\" — the reason for the slowness is something deeper.\nWhat you're trying to solve here is known as the assignment problem: given ... | [
20,
1,
0,
0
] | [] | [] | [
"algorithm",
"dynamic_programming",
"optimization",
"python"
] | stackoverflow_0000982127_algorithm_dynamic_programming_optimization_python.txt |
Q:
How can I search and replace in XML with Python?
I am in the middle of making a script for doing translation of xml documents. It's actually pretty cool, the idea is (and it is working) to take an xml file (or a folder of xml files) and open it, parse the xml, get whatever is in between some tags and using the goo... | How can I search and replace in XML with Python? | I am in the middle of making a script for doing translation of xml documents. It's actually pretty cool, the idea is (and it is working) to take an xml file (or a folder of xml files) and open it, parse the xml, get whatever is in between some tags and using the google translate api's translate it and replace the conte... | [
"Don't try to parse XML using regular expressions! XML is not regular and therefore regular expressions are not suited to doing this kind of task.\nUse an actual XML parser. Many of these are readily available for Python. A quick search has lead me to this SO question which covers how to use XPath in Python.\n",
... | [
7,
5
] | [] | [] | [
"python",
"regex",
"xml"
] | stackoverflow_0000982414_python_regex_xml.txt |
Q:
Threads in Java and Python
i have few questions about threads in Python and Java...
Is it possible to give priorities to Python threads, as it is in Java?
How can I kill, stop, suspend and interrupt thread in Python?
Thread groups - what are they really for? Does Python support them too?
Synchronization - in Java... | Threads in Java and Python | i have few questions about threads in Python and Java...
Is it possible to give priorities to Python threads, as it is in Java?
How can I kill, stop, suspend and interrupt thread in Python?
Thread groups - what are they really for? Does Python support them too?
Synchronization - in Java we use simply keyword synchorin... | [
"Assuming we're talking about the classic (CPython) implementation:\n\nno, no priorities in Python's threads\nyou can't do any of these things to a thread in Python\nno thread groups in Python\nyou can use many approaches, such as locks, but the recommended approach is generally to use the Queue module from the sta... | [
12,
1,
1,
1,
0,
0
] | [] | [] | [
"java",
"multithreading",
"python"
] | stackoverflow_0000970909_java_multithreading_python.txt |
Q:
Django/Python EnvironmentError?
I am getting an error when I try to use syncdb:
python manage.py syncdb
Error message:
File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 83, in __init__
raise EnvironmentError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?... | Django/Python EnvironmentError? | I am getting an error when I try to use syncdb:
python manage.py syncdb
Error message:
File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 83, in __init__
raise EnvironmentError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
En... | [
"Your trace states:\nImport by filename is not supported.\n\nWhich might indicate that you try to import (or maybe set the DJANGO_SETTINGS_MODULE) to the full python filename, where it should be a module path: your.module.settings\nYou could also try to specify your DJANGO_SETTINGS_MODULE directly from command line... | [
12,
1,
1
] | [] | [] | [
"django",
"django_syncdb",
"python"
] | stackoverflow_0000911085_django_django_syncdb_python.txt |
Q:
Using sphinx/miktex to generate pdf files that displays UTF8 Japanese (CJK) text in windows
I have documentation in ReSt (UTF8) and I'm using sphinx to generate HTML and latex files.
(No issues with html conversion)
I then want to convert the resulting latex file to PDf. Currently I'm using MiKTeX
2.7's pdflatex... | Using sphinx/miktex to generate pdf files that displays UTF8 Japanese (CJK) text in windows | I have documentation in ReSt (UTF8) and I'm using sphinx to generate HTML and latex files.
(No issues with html conversion)
I then want to convert the resulting latex file to PDf. Currently I'm using MiKTeX
2.7's pdflatex.exe command to perfom this conversion. (Converting a source file without Japanese characters pro... | [
"I would use xelatex (available in MikTeX since 2.7) instead of pdflatex and an OpenType Kanji font. The file text.tex consisting of\n\n\\documentclass{article}\n\\usepackage{fontspec}\n\\setmainfont{Sazanami Gothic}\n\n\\begin{document}\nこんにちは 世界\n\\end{document}\n\ncompiles with \"xelatex text\" to a PDF with thi... | [
3
] | [] | [] | [
"miktex",
"pdflatex",
"python",
"python_sphinx",
"windows"
] | stackoverflow_0000758693_miktex_pdflatex_python_python_sphinx_windows.txt |
Q:
python and sys.argv
if len(sys.argv) < 2:
sys.stderr.write('Usage: sys.argv[0] ')
sys.exit(1)
if not os.path.exists(sys.argv[1]):
sys.stderr.write('ERROR: Database sys.argv[1] was not found!')
sys.exit(1)
This is a portion of code I'm working on. The first part I'm trying to say if the user doesn... | python and sys.argv | if len(sys.argv) < 2:
sys.stderr.write('Usage: sys.argv[0] ')
sys.exit(1)
if not os.path.exists(sys.argv[1]):
sys.stderr.write('ERROR: Database sys.argv[1] was not found!')
sys.exit(1)
This is a portion of code I'm working on. The first part I'm trying to say if the user doesn't type python programna... | [
"BTW you can pass the error message directly to sys.exit:\nif len(sys.argv) < 2:\n sys.exit('Usage: %s database-name' % sys.argv[0])\n\nif not os.path.exists(sys.argv[1]):\n sys.exit('ERROR: Database %s was not found!' % sys.argv[1])\n\n",
"In Python, you can't just embed arbitrary Python expressions into l... | [
99,
34,
32
] | [] | [] | [
"python"
] | stackoverflow_0000983201_python.txt |
Q:
How to do a non-blocking URL fetch in Python
I am writing a GUI app in Pyglet that has to display tens to hundreds of thumbnails from the Internet. Right now, I am using urllib.urlretrieve to grab them, but this blocks each time until they are finished, and only grabs one at a time.
I would prefer to download them... | How to do a non-blocking URL fetch in Python | I am writing a GUI app in Pyglet that has to display tens to hundreds of thumbnails from the Internet. Right now, I am using urllib.urlretrieve to grab them, but this blocks each time until they are finished, and only grabs one at a time.
I would prefer to download them in parallel and have each one display as soon as ... | [
"You'll probably benefit from threading or multiprocessing modules. You don't actually need to create all those Thread-based classes by yourself, there is a simpler method using Pool.map:\nfrom multiprocessing import Pool\n\ndef fetch_url(url):\n # Fetch the URL contents and save it anywhere you need and\n # ... | [
3,
2,
2,
2,
1,
0
] | [] | [] | [
"blocking",
"multithreading",
"pyglet",
"python"
] | stackoverflow_0000983144_blocking_multithreading_pyglet_python.txt |
Q:
Python JSON encoding
I'm trying to encode data to JSON in Python and I been having a quite a bit of trouble. I believe the problem is simply a misunderstanding.
I'm relatively new to Python and never really got familiar with the various Python data types, so that's most likely what's messing me up.
Currently I a... | Python JSON encoding | I'm trying to encode data to JSON in Python and I been having a quite a bit of trouble. I believe the problem is simply a misunderstanding.
I'm relatively new to Python and never really got familiar with the various Python data types, so that's most likely what's messing me up.
Currently I am declaring a list, loopin... | [
"Python lists translate to JSON arrays. What it is giving you is a perfectly valid JSON string that could be used in a Javascript application. To get what you expected, you would need to use a dict:\n>>> json.dumps({'apple': 'cat', 'banana':'dog', 'pear':'fish'})\n'{\"pear\": \"fish\", \"apple\": \"cat\", \"banana\... | [
78,
27,
18,
4,
3,
3,
3
] | [] | [] | [
"encoding",
"json",
"python",
"simplejson",
"types"
] | stackoverflow_0000983855_encoding_json_python_simplejson_types.txt |
Q:
Call flatpage from with a view
Can I call a Flatpage from with a view. Say I have some code like:
def myview(request):
if request.subdomain != "www":
return HttpResponseRedirect("http://"+request.subdomain+".mydomain/login/")
else:
call the flatpage here...
A:
You sure can. Just make sure you have... | Call flatpage from with a view | Can I call a Flatpage from with a view. Say I have some code like:
def myview(request):
if request.subdomain != "www":
return HttpResponseRedirect("http://"+request.subdomain+".mydomain/login/")
else:
call the flatpage here...
| [
"You sure can. Just make sure you have the flatpage function included in your view code:\nfrom django.contrib.flatpages.views import flatpage\n\nAnd stick the following in your else:\nreturn flatpage(request, '/path/to/your/flatpage/')\n\nOr if you'd like to configure the flatpage to use the same URL being called, ... | [
4
] | [] | [] | [
"django",
"python"
] | stackoverflow_0000983722_django_python.txt |
Q:
How to recreate this PHP code in Python?
I've found a PHP script that lets me do what I asked in this SO question. I can use this just fine, but out of curiosity I'd like to recreate the following code in Python.
I can of course use urllib2 to get the page, but I'm at a loss on how to handle the cookies since m... | How to recreate this PHP code in Python? | I've found a PHP script that lets me do what I asked in this SO question. I can use this just fine, but out of curiosity I'd like to recreate the following code in Python.
I can of course use urllib2 to get the page, but I'm at a loss on how to handle the cookies since mechanize (tested with Python 2.5 and 2.6 on Wi... | [
"Similar to monkut's answer, but a little more concise.\nimport urllib, urllib2\n\ndef steam_login(username,password):\n data = urllib.urlencode({\n 'action': 'doLogin',\n 'goto': '',\n 'steamAccountName': username,\n 'steamPassword': password,\n })\n request = urllib2.Request('https://... | [
6,
5
] | [] | [] | [
"automation",
"forms",
"http",
"php",
"python"
] | stackoverflow_0000984244_automation_forms_http_php_python.txt |
Q:
Formatting date times provided as strings in Django
In my Django application I get times from a webservice, provided as a string, that I use in my templates:
{{date.string}}
This provides me with a date such as:
2009-06-11 17:02:09+0000
These are obviously a bit ugly, and I'd like to present them in a nice forma... | Formatting date times provided as strings in Django | In my Django application I get times from a webservice, provided as a string, that I use in my templates:
{{date.string}}
This provides me with a date such as:
2009-06-11 17:02:09+0000
These are obviously a bit ugly, and I'd like to present them in a nice format to my users. Django has a great built in date formatter... | [
"You're probably better off parsing the string received from the webservice in your view code, and then passing the datetime.date (or string) to the template for display. The spirit of Django templates is that very little coding work should be done there; they are for presentation only, and that's why they go out o... | [
11,
0
] | [] | [] | [
"date",
"django",
"python",
"strptime",
"time"
] | stackoverflow_0000984412_date_django_python_strptime_time.txt |
Q:
How would I go about parsing the following log?
I need to parse a log in the following format:
===== Item 5483/14800 =====
This is the item title
Info: some note
===== Item 5483/14800 (Update 1/3) =====
This is the item title
Info: some other note
===== Item 5483/14800 (Update 2/3) =====
This is the item title
In... | How would I go about parsing the following log? | I need to parse a log in the following format:
===== Item 5483/14800 =====
This is the item title
Info: some note
===== Item 5483/14800 (Update 1/3) =====
This is the item title
Info: some other note
===== Item 5483/14800 (Update 2/3) =====
This is the item title
Info: some more notes
===== Item 5483/14800 (Update 3/3... | [
"1) Loop through every line in the log\n\n a)If line matches appropriate Regex:\n\n Display/Store Next Line as the item title.\n Look for the next line containing \"Result \n XXXX.\" and parse out that result for \n including in the result set.\n\nEDIT: added a bit more now that I see the res... | [
5,
5,
1,
1,
1,
1,
0,
0
] | [
"Here's some not so good looking perl code that does the job. Perhaps you can find it useful in some way. Quick hack, there are other ways of doing it (I feel that this code needs defending).\n#!/usr/bin/perl -w\n#\n# $Id$\n#\n\nuse strict;\nuse warnings;\n\nmy @ITEMS;\nmy $item;\nmy $state = 0;\n\nopen(FD, \"< dat... | [
-1
] | [
"parsing",
"python"
] | stackoverflow_0000977458_parsing_python.txt |
Q:
PythonCard - Can I launch a CustomDialog Stand Alone?
I have a CustomDialog I made to let the user configure settings. Normally I want this to be launched from a menu item within the main application which works fine.
But during the install, I want to launch just the dialog to let the user configure the settings.... | PythonCard - Can I launch a CustomDialog Stand Alone? | I have a CustomDialog I made to let the user configure settings. Normally I want this to be launched from a menu item within the main application which works fine.
But during the install, I want to launch just the dialog to let the user configure the settings. Is there a way I can have both?
| [
"With a little supporting code you can -- see e.g. wizard.py which launches an almost-stand-alone custom dialog subclass \"wizard\".\n"
] | [
1
] | [] | [] | [
"pycard",
"python",
"pythoncard",
"user_interface",
"wxpython"
] | stackoverflow_0000984506_pycard_python_pythoncard_user_interface_wxpython.txt |
Q:
How to use standard toolbar icons with WxPython?
I'm designing a simple text editor using WxPython, and I want to put the platform's native icons in the toolbar. It seems that the only way to make toolbars is with custom images, which are not good for portability. Is there some kind of (e.g.) GetSaveIcon()?
A:
... | How to use standard toolbar icons with WxPython? | I'm designing a simple text editor using WxPython, and I want to put the platform's native icons in the toolbar. It seems that the only way to make toolbars is with custom images, which are not good for portability. Is there some kind of (e.g.) GetSaveIcon()?
| [
"I don't think wxPython provides native images on each platform\nbut just for consistency sake you can use wx.ArtProvider\ne.g.\nwx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN)\n"
] | [
4
] | [] | [] | [
"icons",
"python",
"wxpython"
] | stackoverflow_0000984816_icons_python_wxpython.txt |
Q:
Facebook, Django, and Google App Engine
I'm experimenting with app-engine-patch (Django for GAE) on Google App Engine. And I would like to write a Facebook application. Is it possible to use PyFacebook and its middleware? Or is there some other solution?
A:
I run a system on for social networks and facebook on G... | Facebook, Django, and Google App Engine | I'm experimenting with app-engine-patch (Django for GAE) on Google App Engine. And I would like to write a Facebook application. Is it possible to use PyFacebook and its middleware? Or is there some other solution?
| [
"I run a system on for social networks and facebook on GAE with back-end in Python, front end in Javascript and Flash. I use mostly client side js libraries to pass data back to the server side datastore. This library for facebook to be exact: http://code.google.com/p/facebookjsapi/ \nThere is a reason for this. M... | [
8,
6,
0
] | [] | [] | [
"django",
"facebook",
"google_app_engine",
"python"
] | stackoverflow_0000984071_django_facebook_google_app_engine_python.txt |
Q:
During a subprocess call, catch critical windows errors in Python instead of letting the OS handle it by showing nasty error pop-ups
"The application failed to initialize properly ... Click on OK,to terminate the application." is the message from the error pop-up. What is the way to catch these errors in Python co... | During a subprocess call, catch critical windows errors in Python instead of letting the OS handle it by showing nasty error pop-ups | "The application failed to initialize properly ... Click on OK,to terminate the application." is the message from the error pop-up. What is the way to catch these errors in Python code?
| [
"Sounds familiar? This will block your subprocess.Popen forever.. until you click the 'OK' button. Add the following code to your module initialization to workaround this issue:\nimport win32api, win32con\nwin32api.SetErrorMode(win32con.SEM_FAILCRITICALERRORS |\n win32con.SEM_NOOPENFILEERRORBOX... | [
4
] | [] | [] | [
"python",
"subprocess",
"windows"
] | stackoverflow_0000977275_python_subprocess_windows.txt |
Q:
How to specify native library search path for python
I have installed lxml which was built using a standalone version of libxml2. Reason for this was that the lxml needed a later version of libxml2 than what was currently installed.
When I use the lxml module how do I tell it (python) where to find the correct ver... | How to specify native library search path for python | I have installed lxml which was built using a standalone version of libxml2. Reason for this was that the lxml needed a later version of libxml2 than what was currently installed.
When I use the lxml module how do I tell it (python) where to find the correct version of the libxml2 shared library?
| [
"Assuming you're talking about a .so file, it's not up to Python to find it -- it's up to the operating system's dynamic library loaded. For Linux, for example, LD_LIBRARY_PATH is the environment variable you need to set.\n"
] | [
5
] | [] | [] | [
"python"
] | stackoverflow_0000985155_python.txt |
Q:
disable a block in django
I want to disable a block in development and use it in deployment in google apps in python development. What changes do i need to make in template or main script?
A:
If you've got the middleware django.core.content_processors.debug then you can just do this in your template:
{% block my... | disable a block in django | I want to disable a block in development and use it in deployment in google apps in python development. What changes do i need to make in template or main script?
| [
"If you've got the middleware django.core.content_processors.debug then you can just do this in your template:\n{% block mydebugonly %}\n {% if debug %}\n <p>Something that will only appear if the DEBUG setting is True.</p>\n {% endif %}\n{% endblock %}\n\n"
] | [
3
] | [] | [] | [
"django",
"google_app_engine",
"python"
] | stackoverflow_0000985224_django_google_app_engine_python.txt |
Q:
Format an array of tuples in a nice "table"
Say I have an array of tuples which look like that:
[('url#id1', 'url#predicate1', 'value1'),
('url#id1', 'url#predicate2', 'value2'),
('url#id1', 'url#predicate3', 'value3'),
('url#id2', 'url#predicate1', 'value4'),
('url#id2', 'url#predicate2', 'value5')]
I would like... | Format an array of tuples in a nice "table" | Say I have an array of tuples which look like that:
[('url#id1', 'url#predicate1', 'value1'),
('url#id1', 'url#predicate2', 'value2'),
('url#id1', 'url#predicate3', 'value3'),
('url#id2', 'url#predicate1', 'value4'),
('url#id2', 'url#predicate2', 'value5')]
I would like be able to return a nice 2D array to be able to ... | [
"Your dict of dict is probably on the right track. While you create that dict of dict, you could also maintain a list of ids and a list of predicates. That way, you can remember the ordering and build the table by looping through those lists.\nusing the zip function on your initial array wil give you three lists: t... | [
0,
0
] | [] | [] | [
"algorithm",
"django",
"python"
] | stackoverflow_0000980000_algorithm_django_python.txt |
Q:
Is the pickling process deterministic?
Does Pickle always produce the same output for a certain input value? I suppose there could be a gotcha when pickling dictionaries that have the same contents but different insert/delete histories. My goal is to create a "signature" of function arguments, using Pickle and SHA... | Is the pickling process deterministic? | Does Pickle always produce the same output for a certain input value? I suppose there could be a gotcha when pickling dictionaries that have the same contents but different insert/delete histories. My goal is to create a "signature" of function arguments, using Pickle and SHA1, for a memoize implementation.
| [
"\nI suppose there could be a gotcha when pickling dictionaries that have the same contents but different insert/delete histories.\n\nRight:\n>>> pickle.dumps({1: 0, 9: 0}) == pickle.dumps({9: 0, 1: 0})\nFalse\n\nSee also: pickle.dumps not suitable for hashing\n\nMy goal is to create a \"signature\" of function arg... | [
9,
0
] | [] | [] | [
"memoization",
"pickle",
"python"
] | stackoverflow_0000985294_memoization_pickle_python.txt |
Q:
Convert a value into row, column and char
My data structure is initialized as follows:
[[0,0,0,0,0,0,0,0] for x in range(8)]
8 characters, 8 rows, each row has 5 bits for columns, so each integer can be in the range between 0 and 31 inclusive.
I have to convert the number 177 (can be between 0 and 319) into char,... | Convert a value into row, column and char | My data structure is initialized as follows:
[[0,0,0,0,0,0,0,0] for x in range(8)]
8 characters, 8 rows, each row has 5 bits for columns, so each integer can be in the range between 0 and 31 inclusive.
I have to convert the number 177 (can be between 0 and 319) into char, row, and column.
Let me try again, this time w... | [
"Okay, this looks as if you're working with a 1x8 LCD display, where each character is 8 rows of 5 pixels.\nSo, you have a total of 8 * (8 * 5) = 320 pixels, and you want to map the index of a pixel to a position in the \"framebuffer\" decribing the display's contents.\nI assume pixels are distributed like this (sh... | [
2,
1
] | [] | [] | [
"math",
"python"
] | stackoverflow_0000984888_math_python.txt |
Q:
Django: How can I change a ModelForm's Many2ManyField (select tag) choices verbose values?
For example:
I have the follow model
class Categories(models.Model):
name = models.CharField(max_length=100,verbose_name="Category Name")
parent_cat = models.ForeignKey('self',verbose_name="Parent Category",null=True... | Django: How can I change a ModelForm's Many2ManyField (select tag) choices verbose values? | For example:
I have the follow model
class Categories(models.Model):
name = models.CharField(max_length=100,verbose_name="Category Name")
parent_cat = models.ForeignKey('self',verbose_name="Parent Category",null=True,blank=True,related_name="child_cat")
description = models.TextField(verbose_name="Category ... | [
"I'm not sure if this is the best way, but you could edit the Categories model so it looks like this:\nclass Categories(models.Model):\n name = models.CharField(max_length=100,verbose_name=\"Category Name\")\n parent_cat = models.ForeignKey('self',verbose_name=\"Parent Category\",null=True,blank=True,related_... | [
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0000985543_django_python.txt |
Q:
Dynamic Language Features and Meta-Programming Used in Django
Any good summary articles of the dynamic language and meta-programming features of Python that get utilized by Django? Or can we build that out here? Setting this up as a wiki-style entry.
A:
Marty Alchin (Gulopine) has a few articles on various bits ... | Dynamic Language Features and Meta-Programming Used in Django | Any good summary articles of the dynamic language and meta-programming features of Python that get utilized by Django? Or can we build that out here? Setting this up as a wiki-style entry.
| [
"Marty Alchin (Gulopine) has a few articles on various bits of Django internals - including metaclasses and descriptors - on his blog:\nhttp://martyalchin.com/categories/django/\n"
] | [
2
] | [] | [] | [
"django",
"dynamic_languages",
"metaprogramming",
"python"
] | stackoverflow_0000984272_django_dynamic_languages_metaprogramming_python.txt |
Q:
Correct way of handling exceptions in Python?
I have searched for other posts, as I felt this is a rather common problem, but all other Python exception questions I have found didn't reflect my problem.
I will try to be as specific here as I can, so I will give a direct example. And pleeeeease do not post any work... | Correct way of handling exceptions in Python? | I have searched for other posts, as I felt this is a rather common problem, but all other Python exception questions I have found didn't reflect my problem.
I will try to be as specific here as I can, so I will give a direct example. And pleeeeease do not post any workarounds for this specific problem. I am not specifi... | [
"Instead of using the try/except's else block, you could simply return when it errors:\ndef send_message(addr, to, msg):\n ## Connect to host\n try:\n server = smtplib.SMTP(host) #can throw an exception\n except smtplib.socket.gaierror:\n return False\n\n ## Login\n try:\n server... | [
26,
12,
3,
1,
1,
0,
0
] | [] | [] | [
"exception",
"python"
] | stackoverflow_0000984526_exception_python.txt |
Q:
Python and Collective Intelligence
I'm currently reading a great book called 'Programming Collective Intelligence' by Toby Segaran (which i highly recommend)
The code examples are all written in Python, and as I have already learnt one new language this year (graduating from VB.net to C#) i'm not keen to jump on a... | Python and Collective Intelligence | I'm currently reading a great book called 'Programming Collective Intelligence' by Toby Segaran (which i highly recommend)
The code examples are all written in Python, and as I have already learnt one new language this year (graduating from VB.net to C#) i'm not keen to jump on another learning curve.
This leaves my wi... | [
"One challenge you'll find is that not only are the algorithms implemented in Python, but the book makes extensive use of Python libraries like BeautifulSoup, Numpy, PIL, and others (see appendix A).\nI doubt there are any specifics of the algorithms that you couldn't port to another language, but you'll have troub... | [
20,
2,
2,
1,
1,
0
] | [] | [] | [
"collective_intelligence",
"python"
] | stackoverflow_0000863253_collective_intelligence_python.txt |
Q:
What does this line mean in Python?
Which CPU information this code is trying to retrieve. This code is part of a larger package. I am not a Python programmer, and I want to convert this code to C#.
from ctypes import c_uint, create_string_buffer, CFUNCTYPE, addressof
CPUID = create_string_buffer("\x53\x31\xc0\x40... | What does this line mean in Python? | Which CPU information this code is trying to retrieve. This code is part of a larger package. I am not a Python programmer, and I want to convert this code to C#.
from ctypes import c_uint, create_string_buffer, CFUNCTYPE, addressof
CPUID = create_string_buffer("\x53\x31\xc0\x40\x0f\xa2\x5b\xc3")
cpuinfo = CFUNCTYPE(c_... | [
"It executes the following machine code:\npush bx\nxor ax, ax\ninc ax\ncpuid\npop bx\nretn\n\nBasically it calls CPUID instruction of the CPU in order to get information about the CPU. Since EAX=1 it gets the processor info and feature bits. The result 32-bit integer is then displayed on the screen, see the wikiped... | [
24,
6
] | [] | [] | [
"c#",
"cpu",
"cpuid",
"python",
"windows"
] | stackoverflow_0000986087_c#_cpu_cpuid_python_windows.txt |
Q:
I need a beginners guide to setting up windows for python development
I currently work with .NET exclusively and would like to have a go at python. To this end I need to set up a python development environment. I guide to this would be handy. I guess I would be doing web development so will need a web server and p... | I need a beginners guide to setting up windows for python development | I currently work with .NET exclusively and would like to have a go at python. To this end I need to set up a python development environment. I guide to this would be handy. I guess I would be doing web development so will need a web server and probably a database. I also need pointers to popular ORM's, an MVC framework... | [
"It's not that hard to set up a Python environment, and I've never had it muck up my .NET work. Basically, install Python --- I'd use 2.6 rather than 3.0, which is not yet broadly accepted --- and add it to your PATH, and you're ready to go with the language. I wouldn't recommend using a Ubuntu VM as your develop... | [
5,
3,
3,
3,
2,
2,
1,
1,
0,
0
] | [] | [] | [
"development_environment",
"python",
"windows"
] | stackoverflow_0000959479_development_environment_python_windows.txt |
Q:
Finding PI digits using Monte Carlo
I have tried many algorithms for finding π using Monte Carlo.
One of the solutions (in Python) is this:
def calc_PI():
n_points = 1000000
hits = 0
for i in range(1, n_points):
x, y = uniform(0.0, 1.0), uniform(0.0, 1.0)
if (x**2 + y**2) <= 1.0:
... | Finding PI digits using Monte Carlo | I have tried many algorithms for finding π using Monte Carlo.
One of the solutions (in Python) is this:
def calc_PI():
n_points = 1000000
hits = 0
for i in range(1, n_points):
x, y = uniform(0.0, 1.0), uniform(0.0, 1.0)
if (x**2 + y**2) <= 1.0:
hits += 1
print "Calc2: PI r... | [
"This is a classic example of Monte Carlo. But if you're trying to break the calculation of pi into parallel parts, why not just use an infinite series and let each core take a range, then sum the results as you go?\nhttp://mathworld.wolfram.com/PiFormulas.html\n",
"Your fractional error goes by sqrt(N)/N = 1/sqr... | [
14,
8,
4
] | [] | [] | [
"montecarlo",
"pi",
"python",
"statistics"
] | stackoverflow_0000982381_montecarlo_pi_python_statistics.txt |
Q:
Page isn't always rendered
In Google App Engine, I have the following code which shows a simple HTML page.
import os
from google.appengine.ext.webapp import template
from google.appengine.ext import webapp
class IndexHandler(webapp.RequestHandler):
def get(self):
template_values = { }
path = os.path.j... | Page isn't always rendered | In Google App Engine, I have the following code which shows a simple HTML page.
import os
from google.appengine.ext.webapp import template
from google.appengine.ext import webapp
class IndexHandler(webapp.RequestHandler):
def get(self):
template_values = { }
path = os.path.join(os.path.dirname(__file__), '... | [
"Your handler script (the one referenced by app.yaml) has a main() function, but needs this stanza at the end:\nif __name__ == '__main__':\n main()\n\nWhat's happening is that the first time your script is run in a given interpreter, it interprets your main script, which does nothing (thus returning a blank respon... | [
3,
0
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0000985017_google_app_engine_python.txt |
Q:
Python shortcuts
Python is filled with little neat shortcuts.
For example:
self.data = map(lambda x: list(x), data)
and (although not so pretty)
tuple(t[0] for t in self.result if t[0] != 'mysql' and t[0] != 'information_schema')
among countless others.
In the irc channel, they said "too many to know them all". ... | Python shortcuts | Python is filled with little neat shortcuts.
For example:
self.data = map(lambda x: list(x), data)
and (although not so pretty)
tuple(t[0] for t in self.result if t[0] != 'mysql' and t[0] != 'information_schema')
among countless others.
In the irc channel, they said "too many to know them all".
I think we should lis... | [
"self.data = map(lambda x: list(x), data)\n\nis dreck -- use\nself.data = map(list, data)\n\nif you're a map fanatic (list comprehensions are generally preferred these days). More generally, lambda x: somecallable(x) can always be productively changed to just somecallable, in every context, with nothing but good ef... | [
11,
3,
3,
1
] | [] | [] | [
"python",
"refactoring",
"shortcut"
] | stackoverflow_0000985026_python_refactoring_shortcut.txt |
Q:
Stomp Broadcast with Rabbitmq and Python
Im trying to move a system from using morbid to rabbitmq, but I cannot seem to get the same broadcast behaviour morbid supplied by default. By broadcast I mean that when a message is added to the queue, every consumer recieves it. With rabbit, when a message is added they a... | Stomp Broadcast with Rabbitmq and Python | Im trying to move a system from using morbid to rabbitmq, but I cannot seem to get the same broadcast behaviour morbid supplied by default. By broadcast I mean that when a message is added to the queue, every consumer recieves it. With rabbit, when a message is added they are distributed round robin style to every list... | [
"Apparently you can't do with directly with STOMP; there is a mailing list thread that shows all the hoops you have to jump through to get broadcast working with stomp (it involves some lower-level AMPQ stuff).\n",
"I finally figured out how to do it by creating an exchange for each \"recieving group\", im not su... | [
3,
3
] | [] | [] | [
"broadcast",
"python",
"rabbitmq",
"stomp"
] | stackoverflow_0000981291_broadcast_python_rabbitmq_stomp.txt |
Q:
How to make a singleton class with Python Flup fastcgi server?
I use flup as fastcgi server for Django.
Please explain to me how can I use singleton?
I'm not sure I understand threading models for Flup well.
A:
If you use a forked server, you will not be able to have a singleton at all (at least no singleton tha... | How to make a singleton class with Python Flup fastcgi server? | I use flup as fastcgi server for Django.
Please explain to me how can I use singleton?
I'm not sure I understand threading models for Flup well.
| [
"If you use a forked server, you will not be able to have a singleton at all (at least no singleton that lifes longer than your actual context).\nWith a threaded server, it should be possibe (but I am not so much in Django and Web servers!).\nHave you tried such a code (as an additional module):\n# Singleton module... | [
0
] | [] | [] | [
"django",
"flup",
"python"
] | stackoverflow_0000650518_django_flup_python.txt |
Q:
Python thread exit code
Is there a way to tell if a thread has exited normally or because of an exception?
A:
As mentioned, a wrapper around the Thread class could catch that state. Here's an example.
>>> from threading import Thread
>>> class MyThread(Thread):
def run(self):
try:
Thread... | Python thread exit code | Is there a way to tell if a thread has exited normally or because of an exception?
| [
"As mentioned, a wrapper around the Thread class could catch that state. Here's an example.\n>>> from threading import Thread\n>>> class MyThread(Thread):\n def run(self):\n try:\n Thread.run(self)\n except Exception as err:\n self.err = err\n pass # or raise err\n... | [
20,
0,
0
] | [] | [] | [
"exit_code",
"multithreading",
"python"
] | stackoverflow_0000986616_exit_code_multithreading_python.txt |
Q:
adding a **kwarg to a class
class StatusForm(ModelForm):
bases = forms.ModelMultipleChoiceField(
queryset=Base.objects.all(), #this should get overwritten
widget=forms.SelectMultiple,
)
class Meta:
model = HiringStatus
exclude = ('company', 'date')
de... | adding a **kwarg to a class | class StatusForm(ModelForm):
bases = forms.ModelMultipleChoiceField(
queryset=Base.objects.all(), #this should get overwritten
widget=forms.SelectMultiple,
)
class Meta:
model = HiringStatus
exclude = ('company', 'date')
def __init__(self, *args, **kwargs)... | [
"That's because you're unpacking kwargs to the super constructor.\nTry to put this before calling super:\nif kwargs.has_key('bases_queryset'):\n bases_queryset = kwargs['bases_queryset']\n del kwargs['bases_queryset']\n\nbut it's not an ideal solution...\n",
"As @Keeper indicates, you must not pass your \"n... | [
11,
11
] | [] | [] | [
"django",
"python"
] | stackoverflow_0000987237_django_python.txt |
Q:
Django : Timestamp string custom field
I'm trying to create a custom timestamp field.
class TimestampKey(models.CharField):
__metaclass__ = models.SubfieldBase
def __init__(self, *args, **kwargs):
import time
kwargs['unique'] = True
kwargs['max_length'] = 20
kwargs['auto_c... | Django : Timestamp string custom field | I'm trying to create a custom timestamp field.
class TimestampKey(models.CharField):
__metaclass__ = models.SubfieldBase
def __init__(self, *args, **kwargs):
import time
kwargs['unique'] = True
kwargs['max_length'] = 20
kwargs['auto_created'] = True
kwargs['editable']=F... | [
"Is it wise to use a timestamp as your primary key? If your database uses ISO 8601 or really any time format in which second is the smallest time interval... Well, anyway, my point is that you have no guarantee, especially if this is going to be a web-facing application that two entries are going to resolve withi... | [
3,
1
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0000984460_django_django_models_python.txt |
Q:
How do I get a value node moved up to be an attribute of its parent node?
What do I need to change so the Name node under FieldRef is an attribute of FieldRef, and not a child node?
Suds currently generates the following soap:
<ns0:query>
<ns0:Where>
<ns0:Eq>
<ns0:FieldRef>
<ns0:Name>_ows_ID</n... | How do I get a value node moved up to be an attribute of its parent node? | What do I need to change so the Name node under FieldRef is an attribute of FieldRef, and not a child node?
Suds currently generates the following soap:
<ns0:query>
<ns0:Where>
<ns0:Eq>
<ns0:FieldRef>
<ns0:Name>_ows_ID</ns0:Name>
</ns0:FieldRef>
<ns0:Value>66</ns0:Value>
</ns0:Eq>
... | [
"from suds.sax.element import Element\n#create the nodes\nq = Element('query')\nwhere=Element('Where')\neq=Element('Eq')\nfieldref=Element('FieldRef')\nfieldref.set('Name', '_ows_ID')\nvalue=Element('Value')\nvalue.setText('66')\n\n#append them\neq.append(fieldref)\neq.append(value)\nwhere.append(eq)\nq.append(wher... | [
0
] | [] | [] | [
"python",
"soap",
"suds"
] | stackoverflow_0000986925_python_soap_suds.txt |
Q:
One stop resource for : Will it play in App Engine/Python?
Information on frameworks, languages, and libraries for GAE/J is maintained at
: http://groups.google.com/group/google-appengine-java/web/will-it-play-in-app-engine
Is there a similar page for GAE/Py?
A:
From http://code.google.com/appengine/docs/python... | One stop resource for : Will it play in App Engine/Python? | Information on frameworks, languages, and libraries for GAE/J is maintained at
: http://groups.google.com/group/google-appengine-java/web/will-it-play-in-app-engine
Is there a similar page for GAE/Py?
| [
"From http://code.google.com/appengine/docs/python/overview.html\nThe Python runtime environment uses Python 2.5.2.\nAll code for the Python runtime environment must be pure Python, and not include any C extensions or other code that must be compiled.\nThe environment includes the Python standard library. Some modu... | [
4
] | [] | [] | [
"frameworks",
"google_app_engine",
"python"
] | stackoverflow_0000986516_frameworks_google_app_engine_python.txt |
Q:
How can I change a user agent string programmatically?
I want to write a program that changes the HTTP headers in my requests that are sent by my web-browser. I believe it can be done with a proxy server. So, I'd like to write a proxy server.
How can I do this in Python?
A:
Why not use an existing proxy such as... | How can I change a user agent string programmatically? | I want to write a program that changes the HTTP headers in my requests that are sent by my web-browser. I believe it can be done with a proxy server. So, I'd like to write a proxy server.
How can I do this in Python?
| [
"Why not use an existing proxy such as Charles HTTP Proxy? It has the ability to rewrite headers and do all sorts of cool stuff to requests and responses.\n",
"This is a list of HTTP proxies in python.\n"
] | [
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0000987802_python.txt |
Q:
orbited twisted installation problems
i am geting folloing error when i am trying to start orbited server
C:\Python26\Scripts>orbited
Traceback (most recent call last):
File "C:\Python26\Scripts\orbited-script.py", line 8, in <module>
load_entry_point('orbited==0.7.9', 'console_scripts', 'orbited')()
File ... | orbited twisted installation problems | i am geting folloing error when i am trying to start orbited server
C:\Python26\Scripts>orbited
Traceback (most recent call last):
File "C:\Python26\Scripts\orbited-script.py", line 8, in <module>
load_entry_point('orbited==0.7.9', 'console_scripts', 'orbited')()
File "C:\Python26\lib\site-packages\orbited-0.7.... | [
"I'd start by installing the win32 extensions. If you have done so already, this is probably a path issue.\n"
] | [
2
] | [] | [] | [
"python",
"twisted"
] | stackoverflow_0000987632_python_twisted.txt |
Q:
How do I operate on the actual object, not a copy, in a python for loop?
let's say I have a list
a = [1,2,3]
I'd like to increment every item of that list in place. I want to do something as syntactically easy as
for item in a:
item += 1
but in that example python uses just the value of item, not its actual... | How do I operate on the actual object, not a copy, in a python for loop? | let's say I have a list
a = [1,2,3]
I'd like to increment every item of that list in place. I want to do something as syntactically easy as
for item in a:
item += 1
but in that example python uses just the value of item, not its actual reference, so when I'm finished with that loop a still returns [1,2,3] instea... | [
"Here ya go:\n# Your for loop should be rewritten as follows:\nfor index in xrange(len(a)):\n a[index] += 1\n\nIncidentally, item IS a reference to the item in a, but of course you can't assign a new value to an integer. For any mutable type, your code would work just fine:\n>>> a = [[1], [2], [3], [4]]\n>>> for... | [
26,
17,
9
] | [] | [] | [
"python"
] | stackoverflow_0000988155_python.txt |
Q:
Efficient Tuple List Comparisons
I am kind of hitting a wall on this problem and I was wondering if some fresh brains could help me out.
I have a large list of four element tuples in the format:
(ID number, Type, Start Index, End Index)
Previously in the code, I have searched through thousands of blocks of text f... | Efficient Tuple List Comparisons | I am kind of hitting a wall on this problem and I was wondering if some fresh brains could help me out.
I have a large list of four element tuples in the format:
(ID number, Type, Start Index, End Index)
Previously in the code, I have searched through thousands of blocks of text for two specific types of substrings. T... | [
"Solution:\nresult = [(l1 + l2[1:]) \n for l1 in list1 \n for l2 in list2 \n if (l1[0] == l2[0] and l1[3] < l2[2])\n ]\n\n... with test code:\nlist1 = [(1, 'Type1', 20, 30,),\n (2, 'Type1', 20, 30,),\n (3, 'Type1', 20, 30,),\n (4, 'Type1', 20, 30,),\n ... | [
1,
1,
1,
0,
0
] | [] | [] | [
"algorithm",
"list",
"python",
"tuples"
] | stackoverflow_0000988346_algorithm_list_python_tuples.txt |
Q:
Python string find
I want to find a certain substring inside a string. The string is stored in a list of strings. How can i do it?
A:
So you're searching for all the strings in a list of strings that contain a certain substring? This will do it:
DATA = ['Hello', 'Python', 'World']
SEARCH_STRING = 'n'
print [s ... | Python string find | I want to find a certain substring inside a string. The string is stored in a list of strings. How can i do it?
| [
"So you're searching for all the strings in a list of strings that contain a certain substring? This will do it:\nDATA = ['Hello', 'Python', 'World']\nSEARCH_STRING = 'n'\nprint [s for s in DATA if SEARCH_STRING in s]\n# Prints ['Python']\n\nEdit at Andrew's suggestion: You should read that list comprehension as \... | [
4,
0
] | [] | [] | [
"python"
] | stackoverflow_0000989170_python.txt |
Q:
What's the point of os.error?
Why does Python's os module contain error, an alias for OSError?
Is there a reason to ever spell it os.error? OSError certainly seems more consistent with all the other built-in exceptions.
I hoped os.py would shed some light, but it uses error sometimes and OSError others.
It seems g... | What's the point of os.error? | Why does Python's os module contain error, an alias for OSError?
Is there a reason to ever spell it os.error? OSError certainly seems more consistent with all the other built-in exceptions.
I hoped os.py would shed some light, but it uses error sometimes and OSError others.
It seems goofy to have an extra name for one ... | [
"The documentation for OSError says that it was added in version 1.5.2. My guess is that error predates this a little and in an effort to remain backwards-compatible to code written for Python before 1.5.2 error was made an alias for OSError.\n"
] | [
6
] | [] | [] | [
"python"
] | stackoverflow_0000989259_python.txt |
Q:
Pythonic way to implement three similar integer range operators?
I am working on a circular problem. In this problem, we have objects that are put on a ring of size MAX, and are assigned IDs from (0 to MAX-1).
I have three simple functions to test for range inclusions. inRange(i,j,k) tests if i is in the circular ... | Pythonic way to implement three similar integer range operators? | I am working on a circular problem. In this problem, we have objects that are put on a ring of size MAX, and are assigned IDs from (0 to MAX-1).
I have three simple functions to test for range inclusions. inRange(i,j,k) tests if i is in the circular interval [j,k[ (Mnemonic is i inRange(j,k)). And I have the same for r... | [
"Two Zen of Python principles leap to mind:\n\nSimple is better than complex.\nThere should be one—and preferably only one—obvious way to do it.\n\nrange\nThe Python built-in function range(start, end) generates a list from start to end.1 The first element of that list is start, and the last element is end - 1.\nTh... | [
7,
5,
4,
2,
2,
1,
1
] | [] | [] | [
"operators",
"python"
] | stackoverflow_0000985309_operators_python.txt |
Q:
Getting the first and last item in a python for loop
Is there an elegant and pythonic way to trap the first and last item in a for loop which is iterating over a generator?
from calendar import Calendar
cal = Calendar(6)
month_dates = cal.itermonthdates(year, month)
for date in month_dates:
if (is first item)... | Getting the first and last item in a python for loop | Is there an elegant and pythonic way to trap the first and last item in a for loop which is iterating over a generator?
from calendar import Calendar
cal = Calendar(6)
month_dates = cal.itermonthdates(year, month)
for date in month_dates:
if (is first item): # this is fake
month_start = date
if (is... | [
"I would just force it into a list at the beginning:\nfrom calendar import Calendar, SUNDAY\n\ncal = Calendar(SUNDAY)\nmonth_dates = list(cal.itermonthdates(year, month))\n\nmonth_start = month_dates[0]\nmonth_end = month_dates[-1]\n\nSince there can only be 42 days (counting leading and tailing context), this has ... | [
11,
11,
10,
2
] | [] | [] | [
"for_loop",
"python"
] | stackoverflow_0000989665_for_loop_python.txt |
Q:
Automated Python to Java translation
Is there a tool out there that can automatically convert Python to Java?
Can Jython do this?
A:
Actually, this may or may not be much help but you could write a script which created a Java class for each Python class, including method stubs, placing the Python implementation... | Automated Python to Java translation | Is there a tool out there that can automatically convert Python to Java?
Can Jython do this?
| [
"Actually, this may or may not be much help but you could write a script which created a Java class for each Python class, including method stubs, placing the Python implementation of the method inside the Javadoc\nIn fact, this is probably pretty easy to knock up in Python.\nI worked for a company which undertook ... | [
15,
8,
4,
1
] | [] | [] | [
"code_translation",
"java",
"jython",
"python"
] | stackoverflow_0000153491_code_translation_java_jython_python.txt |
Q:
python string input problem with whitespace!
my input is something like this
23 + 45 = astart
for the exact input when i take it as raw_input() and then try to split it , it gives me an error like this
SyntaxError: invalid syntax
the code is this
k=raw_input()
a,b=(str(i) for i in k.split(' + '))
b,c=(str(i)... | python string input problem with whitespace! | my input is something like this
23 + 45 = astart
for the exact input when i take it as raw_input() and then try to split it , it gives me an error like this
SyntaxError: invalid syntax
the code is this
k=raw_input()
a,b=(str(i) for i in k.split(' + '))
b,c=(str(i) for i in b.split(' = '))
its always number + ... | [
"Testing with Python 2.5.2, your code ran OK as long as I only had the same spacing\non either side of the + and = in the code and input.\nYou appear to have two spaces on either side of them in the code, but only one on either\nside in the input. Also - you do not have to use the str(i) in a generator. You can d... | [
2,
1,
1,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0000989276_python.txt |
Q:
Python and psycopg2 - raw sql select from table with integer criteria
It should be simple, bit I've spent the last hour searching for the answer. This is using psycopg2 on python 2.6.
I need something like this:
special_id = 5
sql = """
select count(*) as ct,
from some_table tbl
... | Python and psycopg2 - raw sql select from table with integer criteria | It should be simple, bit I've spent the last hour searching for the answer. This is using psycopg2 on python 2.6.
I need something like this:
special_id = 5
sql = """
select count(*) as ct,
from some_table tbl
where tbl.id = %(the_id)
"""
cursor = connection.cursor()
curs... | [
"Per PEP 249, since in psycopg2 paramstyle is pyformat, you need to use %(the_id)s even for non-strings -- trust it to do the right thing.\nBTW, internet searches will work better if you use the correct spelling (no h there), but even if you mis-spelled, I'm surprised you didn't get a \"did you mean\" hint (I did w... | [
2
] | [] | [] | [
"python"
] | stackoverflow_0000989833_python.txt |
Q:
Weird program behaviour in Python
When running the following code, which is an easy problem, the Python interpreter works weirdly:
n = input()
for i in range(n):
testcase = raw_input()
#print i
print testcase[2:(int(testcase[0])+1)]+testcase[(int(testcase[0])+2):]
The problem consists in taking n stri... | Weird program behaviour in Python | When running the following code, which is an easy problem, the Python interpreter works weirdly:
n = input()
for i in range(n):
testcase = raw_input()
#print i
print testcase[2:(int(testcase[0])+1)]+testcase[(int(testcase[0])+2):]
The problem consists in taking n strings and deleting a single character fro... | [
"Are you sure that the problem is the print i statement? The code works as\nexpected when I uncomment that statement and run it. However, if I forget to\nenter a value for the first input() call, and just enter \"4 PYTHON\" right off\nthe bat, then I get:\n\"SyntaxError: unexpected EOF while parsing\"\n\nThis hap... | [
4,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0000982970_python.txt |
Q:
How do I draw out specific data from an opened url in Python using urllib2?
I'm new to Python and am playing around with making a very basic web crawler. For instance, I have made a simple function to load a page that shows the high scores for an online game. So I am able to get the source code of the html page, b... | How do I draw out specific data from an opened url in Python using urllib2? | I'm new to Python and am playing around with making a very basic web crawler. For instance, I have made a simple function to load a page that shows the high scores for an online game. So I am able to get the source code of the html page, but I need to draw specific numbers from that page. For instance, the webpage look... | [
"As another poster mentioned, BeautifulSoup is a wonderful tool for this job. \nHere's the entire, ostentatiously-commented program. It could use a lot of error tolerance, but as long as you enter a valid username, it will pull all the scores from the corresponding web page. \nI tried to comment as well as I could... | [
11,
3
] | [] | [] | [
"python",
"urllib2"
] | stackoverflow_0000989872_python_urllib2.txt |
Q:
Curious about differences in vtkMassProperties for VTK 5.04 and VTK 5.4.2
I have a small python VTK function that calculates the volume and surface area of an object embedded in a stack of TIFF images. To read the TIFF's into VTK, I have used vtkTIFFReader and processed the result using vtkImageThreshold. I then... | Curious about differences in vtkMassProperties for VTK 5.04 and VTK 5.4.2 | I have a small python VTK function that calculates the volume and surface area of an object embedded in a stack of TIFF images. To read the TIFF's into VTK, I have used vtkTIFFReader and processed the result using vtkImageThreshold. I then use vtkMassProperties to extract the volume and surface area of the object ide... | [
"I have never heard of VTK before, but here it goes.\nGood thing about opensource software is that you can check the source code directly. Better yet, if there's web-based version control browser, we can talk about it online like this.\nLet's see vtkMassProperties in question. 5.0.4 uses r1.28 and 5.4.2 uses r1.30.... | [
5
] | [] | [] | [
"3d",
"python",
"vtk"
] | stackoverflow_0000967468_3d_python_vtk.txt |
Q:
Trie (Prefix Tree) in Python
I don't know if this is the place to ask about algorithms. But let's see if I get any answers ... :)
If anything is unclear I'm very happy to clarify things.
I just implemented a Trie in python. However, one bit seemed to be more complicated than it ought to (as someone who loves simpl... | Trie (Prefix Tree) in Python | I don't know if this is the place to ask about algorithms. But let's see if I get any answers ... :)
If anything is unclear I'm very happy to clarify things.
I just implemented a Trie in python. However, one bit seemed to be more complicated than it ought to (as someone who loves simplicity). Perhaps someone has had a ... | [
"At a glance, it sounds like you've implemented a Patricia Trie. This approach also is called path compression in some of the literature. There should be copies of that paper that aren't behind the ACM paywall, which will include an insertion algorithm.\nThere's also another compression method you may want to look ... | [
19,
2,
2,
2,
1
] | [] | [] | [
"algorithm",
"python",
"trie"
] | stackoverflow_0000960963_algorithm_python_trie.txt |
Q:
Experiences of creating Social Network site in Django
I plan to sneak in some Python/Django to my workdays and a possible social network site project seems like a good possibility.
Django itself seems excellent, but I am skeptical about the quality of large amount of Django apps that seem to be available.
I would ... | Experiences of creating Social Network site in Django | I plan to sneak in some Python/Django to my workdays and a possible social network site project seems like a good possibility.
Django itself seems excellent, but I am skeptical about the quality of large amount of Django apps that seem to be available.
I would like to hear what kind of experiences you may have had with... | [
"If you're interested in creating a social-network site in Django, you should definitely investigate Pinax. This is a project that integrates a number of apps that are useful for creating this sort of site - friends, messaging, invitations, registration, etc. They're mostly very high quality.\n"
] | [
27
] | [
"Are you saying that a random survey of some posted Django apps (not Django itself) reveals that some people post code that doesn't meet your standards of quality?\nIsn't that universally true of all code posted everywhere on the internet?\nA random survey of any code in any language for any framework will turn up ... | [
-1
] | [
"django",
"python"
] | stackoverflow_0000986594_django_python.txt |
Q:
how to take a matrix in python?
i want to create a matrix of size 1234*5678 with it being filled with 1 to 5678 in row major order?>..!!
A:
I think you will need to use numpy to hold such a big matrix efficiently , not just computation. You have ~5e6 items of 4/8 bytes means 20/40 Mb in pure C already, several ... | how to take a matrix in python? | i want to create a matrix of size 1234*5678 with it being filled with 1 to 5678 in row major order?>..!!
| [
"I think you will need to use numpy to hold such a big matrix efficiently , not just computation. You have ~5e6 items of 4/8 bytes means 20/40 Mb in pure C already, several times of that in python without an efficient data structure (a list of rows, each row a list).\nNow, concerning your question:\nimport numpy as... | [
6,
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0000990469_python.txt |
Q:
Using doctest "result parser" within unit-tests in Python?
I recently faced a problem about combining unit tests and doctests in Python. I worked around this problem in other way, but I still have question about it.
Python's doctest module parses docstrings in a module and run commands following ">>> " at the begi... | Using doctest "result parser" within unit-tests in Python? | I recently faced a problem about combining unit tests and doctests in Python. I worked around this problem in other way, but I still have question about it.
Python's doctest module parses docstrings in a module and run commands following ">>> " at the beginning of each line and compare the output of it and those in doc... | [
"See doctest.OutputChecker.check_output()\n"
] | [
2
] | [] | [] | [
"doctest",
"documentation",
"python",
"testing",
"unit_testing"
] | stackoverflow_0000990500_doctest_documentation_python_testing_unit_testing.txt |
Q:
How to write a proxy server in Python?
I want to write a program that changes the HTTP headers in my requests that are sent by my web-browser. I believe it can be done with a proxy server. So, I'd like to write a proxy server.
I study programming. How can I do this in Python?
A:
Good example below on how to do... | How to write a proxy server in Python? | I want to write a program that changes the HTTP headers in my requests that are sent by my web-browser. I believe it can be done with a proxy server. So, I'd like to write a proxy server.
I study programming. How can I do this in Python?
| [
"Good example below on how to do this without the overhead of a framework.\nhttp://www.warriorhut.org/whatwg/websocket-proxy.py\n",
"Look at the Twisted framework, particularly Twisted Web. It's all freely available under MIT, so you can build off and/or modify it.\nSee also Python Twisted Examples.\n",
"While... | [
14,
13,
7,
5,
3,
2
] | [] | [] | [
"http_headers",
"proxy",
"python"
] | stackoverflow_0000989739_http_headers_proxy_python.txt |
Q:
How to find out the arity of a method in Python
I'd like to find out the arity of a method in Python (the number of parameters that it receives).
Right now I'm doing this:
def arity(obj, method):
return getattr(obj.__class__, method).func_code.co_argcount - 1 # remove self
class Foo:
def bar(self, bla):
p... | How to find out the arity of a method in Python | I'd like to find out the arity of a method in Python (the number of parameters that it receives).
Right now I'm doing this:
def arity(obj, method):
return getattr(obj.__class__, method).func_code.co_argcount - 1 # remove self
class Foo:
def bar(self, bla):
pass
arity(Foo(), "bar") # => 1
I'd like to be abl... | [
"Module inspect from Python's standard library is your friend -- see the online docs! inspect.getargspec(func) returns a tuple with four items, args, varargs, varkw, defaults: len(args) is the \"primary arity\", but arity can be anything from that to infinity if you have varargs and/or varkw not None, and some arg... | [
51,
6,
2,
2,
0
] | [] | [] | [
"metaprogramming",
"python"
] | stackoverflow_0000990016_metaprogramming_python.txt |
Q:
String reversal in Python
I have taken an integer input and tried to reverse it in Python but in vain! I changed it into a string but still I am not able to. Is there any way to reverse it ? Is there any built-in function?
I am not able to convert the integer into a list so not able to apply the reverse function.
... | String reversal in Python | I have taken an integer input and tried to reverse it in Python but in vain! I changed it into a string but still I am not able to. Is there any way to reverse it ? Is there any built-in function?
I am not able to convert the integer into a list so not able to apply the reverse function.
| [
"You can use the slicing operator to reverse a string:\ns = \"hello, world\"\ns = s[::-1]\nprint s # prints \"dlrow ,olleh\"\n\nTo convert an integer to a string, reverse it, and convert it back to an integer, you can do:\nx = 314159\nx = int(str(x)[::-1])\nprint x # prints 951413\n\n",
"Code:\n>>> n = 1234\n>>... | [
30,
4,
2
] | [] | [] | [
"python"
] | stackoverflow_0000990934_python.txt |
Q:
"Pythonic" equivalent for handling switch and multiple string compares
Alright, so my title sucked. An example works better:
input = 'check yahoo.com'
I want to parse input, using the first word as the "command", and the rest of the string as a parameter. Here's the simple version of how my non-Pythonic mind is... | "Pythonic" equivalent for handling switch and multiple string compares | Alright, so my title sucked. An example works better:
input = 'check yahoo.com'
I want to parse input, using the first word as the "command", and the rest of the string as a parameter. Here's the simple version of how my non-Pythonic mind is coding it:
if len(input) > 0:
a = input.split(' ')
if a[0] == 'chec... | [
"dispatch = {\n 'check': do_check,\n 'search': do_search,\n}\ncmd, _, arg = input.partition(' ')\nif cmd in dispatch:\n dispatch[cmd](arg)\nelse:\n do_default(cmd, arg)\n\n",
"\nI am fairly sure there's a much better way to do these things... some way more pythonic.\n\nNot really. You code is simple, cle... | [
31,
4,
3,
0,
0,
0
] | [] | [] | [
"conditional",
"python"
] | stackoverflow_0000641469_conditional_python.txt |
Q:
Deleting files by type in Python on Windows
I know how to delete single files, however I am lost in my implementation of how to delete all files in a directory of one type.
Say the directory is \myfolder
I want to delete all files that are .config files, but nothing to the other ones.
How would I do this?
Thanks K... | Deleting files by type in Python on Windows | I know how to delete single files, however I am lost in my implementation of how to delete all files in a directory of one type.
Say the directory is \myfolder
I want to delete all files that are .config files, but nothing to the other ones.
How would I do this?
Thanks Kindly
| [
"Use the glob module:\nimport os\nfrom glob import glob\n\nfor f in glob ('myfolder/*.config'):\n os.unlink (f)\n\n",
"I would do something like the following:\nimport os\nfiles = os.listdir(\"myfolder\")\nfor f in files:\n if not os.path.isdir(f) and \".config\" in f:\n os.remove(f)\n\nIt lists the files i... | [
17,
5,
1
] | [] | [] | [
"file",
"python"
] | stackoverflow_0000991279_file_python.txt |
Q:
re.search() breaks for key in form.keys() loop
Perhaps I am just crazy or missing something really basic. Why would this happen?
If I use this url
index.cgi?mode=pos&pos_mode=checkout&0_name=Shampoo&0_type=Product&0_price=4.50&0_qty=1&0_total=4.50
which runs this code
form = cgi.FieldStorage()
for key in form.ke... | re.search() breaks for key in form.keys() loop | Perhaps I am just crazy or missing something really basic. Why would this happen?
If I use this url
index.cgi?mode=pos&pos_mode=checkout&0_name=Shampoo&0_type=Product&0_price=4.50&0_qty=1&0_total=4.50
which runs this code
form = cgi.FieldStorage()
for key in form.keys()
print key
if re.search("name", key):
... | [
"Are you getting an exception? Check your server logs. Have you done:\nimport re\n\nat the top of the script? Try wrapping the code in try / except.\n",
"Perhaps you get an error? Try checking types of all keys or anything you suspect could be wrong.\n"
] | [
3,
1
] | [] | [] | [
"python"
] | stackoverflow_0000991351_python.txt |
Q:
an error in taking an input in python
111111111111111111111111111111111111111111111111111111111111
when i take this as input , it appends an L at the end like this
111111111111111111111111111111111111111111111111111111111111L
thus affecting my calculations on it .. how can i remove it?
import math
t=raw_input()
l... | an error in taking an input in python | 111111111111111111111111111111111111111111111111111111111111
when i take this as input , it appends an L at the end like this
111111111111111111111111111111111111111111111111111111111111L
thus affecting my calculations on it .. how can i remove it?
import math
t=raw_input()
l1=[]
a=0
while (str(t)!="" and int(t)!= 0):... | [
"It's being input as a Long Integer, which should behave just like any other number in terms of doing calculations. It's only when you display it using repr (or something that invokes repr, like printing a list) that it gets the 'L'.\nWhat exactly is going wrong?\nEdit: Thanks for the code. As far as I can see, g... | [
3,
3,
2,
2,
0
] | [] | [] | [
"python"
] | stackoverflow_0000991220_python.txt |
Q:
How to programatically combine two aac files into one?
I'm looking for a cat for aac music files (the stuff iTunes uses).
Use Case: My father in law will not touch computers except for audiobooks he downloads to his iPod. I have taught him some iTunes (Windows) basics, but his library is a mess. It turns out, that... | How to programatically combine two aac files into one? | I'm looking for a cat for aac music files (the stuff iTunes uses).
Use Case: My father in law will not touch computers except for audiobooks he downloads to his iPod. I have taught him some iTunes (Windows) basics, but his library is a mess. It turns out, that iTunes is optimized for listening to podcasts and random so... | [
"I created a freeware program called \"Chapter and Verse\" to concatenate m4a (AAC) files into a single m4b audiobook file with chapter marks and metadata.\nIf you have already ripped the CD's to AAC using itunes (which you say you have) then the rest is easy with my software. I wrote it for this exact reason and ... | [
5,
2,
1,
0
] | [] | [] | [
"aac",
"itunes",
"python",
"scripting",
"windows"
] | stackoverflow_0000836842_aac_itunes_python_scripting_windows.txt |
Q:
Very simple Python script, puzzling behaviour
first of all, I'm not a programmer, so the answer to this might be completely obvious to someone more experienced.
I was playing around with python(2.5) to solve some probability puzzle, however I kept getting results which were way off from the mark I thought they sho... | Very simple Python script, puzzling behaviour | first of all, I'm not a programmer, so the answer to this might be completely obvious to someone more experienced.
I was playing around with python(2.5) to solve some probability puzzle, however I kept getting results which were way off from the mark I thought they should be. So after some experimenting, I managed to i... | [
"BTW, for the best way to \"generate 3 different randomly distributed integers between 0 and 9 included\", I heartily recommend a, b, c = random.sample(xrange(10), 3) [[s/xrange/range/ in Python 3.0]] rather than the while loops you're using.\n",
"The result depends on whether line 13:\nsub[random.randint(0,9)] =... | [
5,
3
] | [] | [] | [
"python"
] | stackoverflow_0000991784_python.txt |
Q:
Changing brightness of the Macbook(Pro) keyboard backlight
Programaticly, how can I modify the brightness of the backlit keyboard on a Macbook or Macbook Pro using Python?
A:
Amit Singh discusses these undocumented APIs in this online bonus chapter, but does so using C -- I'm not sure if a Python extension exist... | Changing brightness of the Macbook(Pro) keyboard backlight | Programaticly, how can I modify the brightness of the backlit keyboard on a Macbook or Macbook Pro using Python?
| [
"Amit Singh discusses these undocumented APIs in this online bonus chapter, but does so using C -- I'm not sure if a Python extension exists to do the same work from Python, perhaps as part of PyObjC (otherwise, such an extension would have to be written -- or ctypes used to access the shared C libraries directly f... | [
9
] | [] | [] | [
"hardware",
"macos",
"python"
] | stackoverflow_0000991813_hardware_macos_python.txt |
Q:
What is this function doing in Python involving urllib2 and BeautifulSoup?
So I asked a question earlier about retrieving high scores form an html page and another user gave me the following code to help. I am new to python and beautifulsoup so I'm trying to go through some other codes piece by piece. I understand... | What is this function doing in Python involving urllib2 and BeautifulSoup? | So I asked a question earlier about retrieving high scores form an html page and another user gave me the following code to help. I am new to python and beautifulsoup so I'm trying to go through some other codes piece by piece. I understand most of it but I dont get what this piece of code is and what its function is:
... | [
"el.findAll(text=True) returns all the text contained within an element and its sub-elements. By text I mean everything not inside a tag; so in <b>hello</b> then \"hello\" would be the text but <b> and </b> would not.\nThat function therefore joins together all text found beneath the given element and strips white... | [
3
] | [] | [] | [
"python",
"urllib2"
] | stackoverflow_0000991967_python_urllib2.txt |
Q:
Why are 008 and 009 invalid keys for Python dicts?
Why is it that I can't have 008 or 009 be keys for a Python dict, but 001-007 are fine?
Example:
some_dict = {
001: "spam",
002: "eggs",
003: "foo",
004: "bar",
008: "anything", # Throws a SyntaxError
009: "nothing" # Throws a SyntaxError... | Why are 008 and 009 invalid keys for Python dicts? | Why is it that I can't have 008 or 009 be keys for a Python dict, but 001-007 are fine?
Example:
some_dict = {
001: "spam",
002: "eggs",
003: "foo",
004: "bar",
008: "anything", # Throws a SyntaxError
009: "nothing" # Throws a SyntaxError
}
Update: Problem solved. I wasn't aware that star... | [
"In python and some other languages, if you start a number with a 0, the number is interpreted as being in octal (base 8), where only 0-7 are valid digits. You'll have to change your code to this:\nsome_dict = { \n 1: \"spam\",\n 2: \"eggs\",\n 3: \"foo\",\n 4: \"bar\",\n 8: \"anything\",\n 9: \"... | [
28,
10,
8,
7,
2
] | [] | [] | [
"dictionary",
"python",
"python_2.x"
] | stackoverflow_0000991978_dictionary_python_python_2.x.txt |
Q:
Why am I getting "'ResultSet' has no attribute 'findAll'" using BeautifulSoup in Python?
So I am learning Python slowly, and am trying to make a simple function that will draw data from the high scores page of an online game. This is someone else's code that i rewrote into one function (which might be the problem)... | Why am I getting "'ResultSet' has no attribute 'findAll'" using BeautifulSoup in Python? | So I am learning Python slowly, and am trying to make a simple function that will draw data from the high scores page of an online game. This is someone else's code that i rewrote into one function (which might be the problem), but I am getting this error. Here is the code:
>>> from urllib2 import urlopen
>>> from Beau... | [
"Wow. Triptych provided a great answer to a related question.\nWe can see, from BeautifulSoup's source code, that ResultSet subclasses list.\nIn your example, get_rows is an instance of BS's ResultSet class, \nand since BS's ResultSet subclasses list, that means get_rows is a list.\nget_rows, as an instance of Res... | [
19
] | [] | [] | [
"beautifulsoup",
"python",
"urllib2"
] | stackoverflow_0000992183_beautifulsoup_python_urllib2.txt |
Q:
django for loop counter break
This is hopefully a quick/easy one. I know a way to work around this via a custom template tag, but I was curious if there were other methods I was over looking. I've created a gallery function of sorts for my blog, and I have a gallery list page that paginates all my galleries. Now, ... | django for loop counter break | This is hopefully a quick/easy one. I know a way to work around this via a custom template tag, but I was curious if there were other methods I was over looking. I've created a gallery function of sorts for my blog, and I have a gallery list page that paginates all my galleries. Now, I don't want to show all the photos... | [
"Use:\n{% for photos in gallery.photo_set|slice:\":3\" %}\n\n",
"This is better done in the gallery.photo_set collection. The hard-coded \"3\" in the template is a bad idea in the long run.\nclass Gallery( object ):\n def photo_subset( self ):\n return Photo.objects.filter( gallery_id = self.id )[:3]\n\n... | [
85,
1
] | [] | [] | [
"django",
"for_loop",
"python"
] | stackoverflow_0000992230_django_for_loop_python.txt |
Q:
How to setup twill for python 2.6 on Windows?
I have already downloaded twill 0.9. Also, I have installed easy_install for python 2.6. Now I'm stuck with twill installation. Could you help me to settle the problem?
A:
Something like:
easy_install twill
It assumes you have easy_install in your PATH, which is th... | How to setup twill for python 2.6 on Windows? | I have already downloaded twill 0.9. Also, I have installed easy_install for python 2.6. Now I'm stuck with twill installation. Could you help me to settle the problem?
| [
"Something like:\neasy_install twill\n\nIt assumes you have easy_install in your PATH, which is the case on unix, but not on windows. On windows, the easy_install script can be found in C:\\Python25\\Scripts\n",
"easiest way is to just unzip the twill and keep it somewhere in PYTHONPATH e.g. in your project and j... | [
3,
1
] | [] | [] | [
"python"
] | stackoverflow_0000992638_python.txt |
Q:
Python LDAP Authentication from remote web server
I have a django application hosted on webfaction which now has a static/private ip.
Our network in the office is obviously behind a firewall and the AD server is running behind this firewall. From inside the network i can authenticate using python-ldap with the AD'... | Python LDAP Authentication from remote web server | I have a django application hosted on webfaction which now has a static/private ip.
Our network in the office is obviously behind a firewall and the AD server is running behind this firewall. From inside the network i can authenticate using python-ldap with the AD's internal IP address and the port 389 and all works we... | [
"I would recommend against opening the port on the firewall directly to LDAP. Instead I would suggest making an SSH tunnel. This will put the necessary encryptionn around the LDAP traffic. Here is an example.\nssh -N -p 22 username@ldapserver -L 2222/localhost/389\n\nThis assumes that the ssh server is running on p... | [
3,
0
] | [] | [] | [
"active_directory",
"ldap",
"python",
"webserver"
] | stackoverflow_0000990459_active_directory_ldap_python_webserver.txt |
Q:
Does running separate python processes avoid the GIL?
I'm curious in how the Global Interpreter Lock in python actually works. If I have a c++ application launch four separate instances of a python script will they run in parallel on separate cores, or does the GIL go even deeper then just the single process that ... | Does running separate python processes avoid the GIL? | I'm curious in how the Global Interpreter Lock in python actually works. If I have a c++ application launch four separate instances of a python script will they run in parallel on separate cores, or does the GIL go even deeper then just the single process that was launched and control all python process's regardless of... | [
"The GIL only affects threads within a single process. The multiprocessing module is in fact an alternative to threading that lets Python programs use multiple cores &c. Your scenario will easily allow use of multiple cores, too.\n",
"As Alex Martelli points out you can indeed avoid the GIL by running multiple ... | [
33,
2
] | [] | [] | [
"python"
] | stackoverflow_0000992136_python.txt |
Q:
Python disable/redirect keyboard input
I'm writing a macro generator/ keyboard remapper in python, for xubuntu.
I've figured out how to intercept and record keystrokes, and send keystrokes I want to record, but I haven't figured out how to block keystrokes. I need to disable keyboard input to remap a key. For exam... | Python disable/redirect keyboard input | I'm writing a macro generator/ keyboard remapper in python, for xubuntu.
I've figured out how to intercept and record keystrokes, and send keystrokes I want to record, but I haven't figured out how to block keystrokes. I need to disable keyboard input to remap a key. For example, if I wanted to send 'a' when I press th... | [
"I think it's going to depend heavily on the environment: curses & the activestate recipe are good for command line, but if you want it to run in a DE, you'll need some hooks to that DE. You might look at Qt or GTK bindings for python, or there's a python-xlib library that might let you tie right into the X system.... | [
1,
0
] | [] | [] | [
"keyboard",
"python"
] | stackoverflow_0000958491_keyboard_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.