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:
Searching and capturing a character using regular expressions Python
While going through one of the problems in Python Challenge, I am trying to solve it as follows:
Read the input in a text file with characters as follows:
DQheAbsaMLjTmAOKmNsLziVMenFxQdATQIjItwtyCHyeMwQTNxbbLXWZnGmDqHhXnLHfEyvzxMhSXzd
BEBaxeaPgQP... | Searching and capturing a character using regular expressions Python | While going through one of the problems in Python Challenge, I am trying to solve it as follows:
Read the input in a text file with characters as follows:
DQheAbsaMLjTmAOKmNsLziVMenFxQdATQIjItwtyCHyeMwQTNxbbLXWZnGmDqHhXnLHfEyvzxMhSXzd
BEBaxeaPgQPttvqRvxHPEOUtIsttPDeeuGFgmDkKQcEYjuSuiGROGfYpzkQgvcCDBKrcYwHFlvPzDMEk
MyuP... | [
"I'd suggest using lookaround:\n(?<=[A-Z]{3})(?<![A-Z].{3})([a-z])(?=[A-Z]{3})(?!.{3}[A-Z])\n\nThis will have no problem with overlapping matches.\nExplanation:\n(?<=[A-Z]{3}) # assert that there are 3 uppercase letters before the current position\n(?<![A-Z].{3}) # assert that there is no uppercase letter 4 charac... | [
2,
2,
1
] | [] | [] | [
"python",
"regex",
"search",
"text_files"
] | stackoverflow_0004186249_python_regex_search_text_files.txt |
Q:
Invoke python callable with an arg list
Simple question: How can I pass an arbitrary list of args to a python callable?
Let's say I want to invoke a function from the command line, like so:
my_script.py foo hello world
with the following script:
import myfuncs
f = getattr(myfuncs, sys.args[1])
if f and callable(f... | Invoke python callable with an arg list | Simple question: How can I pass an arbitrary list of args to a python callable?
Let's say I want to invoke a function from the command line, like so:
my_script.py foo hello world
with the following script:
import myfuncs
f = getattr(myfuncs, sys.args[1])
if f and callable(f):
# This is the bit I don't know. I effe... | [
"You are looking for sequence unpacking. I.e. f(*sys.argv[2:])\n",
"Yep, check out the section Unpacking argument lists in the docs.\nFor your particular use, it could be something like this\ndef f(a, b, c): \n print a, b, c\n\nstuff = ['f',2,3,4]\n\nf(*stuff[1:]) ### equivalent to f(2,3,4)\n\n"
] | [
7,
4
] | [] | [] | [
"callable",
"python"
] | stackoverflow_0004186679_callable_python.txt |
Q:
How to display database query results of 100,000 rows or more with HTML?
We're rewriting a website used by one of our clients. The user traffic on it is very low, less than 100 unique visitors a week. It's basically just a nice interface to their data in our databases. It allows them to query and filter on differe... | How to display database query results of 100,000 rows or more with HTML? | We're rewriting a website used by one of our clients. The user traffic on it is very low, less than 100 unique visitors a week. It's basically just a nice interface to their data in our databases. It allows them to query and filter on different sets of data of theirs.
We're rewriting the site in Python, re-using the sa... | [
"I have done just what you are describing using the following (which works very well):\njQuery Datatables\nIt enables you to do 'fetch as you scroll' pagination, so you can disable the pagination arrows in favor of a 'forever' scroll.\n",
"Give a try with Jquery scroll.\nInstead of image scroll , you need to have... | [
8,
3,
2,
1,
1,
1
] | [] | [] | [
"coldfusion",
"html",
"oracle",
"python"
] | stackoverflow_0004186384_coldfusion_html_oracle_python.txt |
Q:
Django running wrong version
Although running "python" from the shell runs Python v2.7, Django is loading files for python2.4, as shown in the error when I load a django site:
Mod_python error: "PythonHandler django.core.handlers.modpython"
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages... | Django running wrong version | Although running "python" from the shell runs Python v2.7, Django is loading files for python2.4, as shown in the error when I load a django site:
Mod_python error: "PythonHandler django.core.handlers.modpython"
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 287, ... | [
"mod_python is built for 2.4, but Django is installed for 2.7. Either build mod_python for 2.7, install Django under 2.4, or put a local copy of Django with your project so that the version of Python doesn't matter.\n"
] | [
2
] | [] | [] | [
"django",
"mediatemple",
"python"
] | stackoverflow_0004186099_django_mediatemple_python.txt |
Q:
Problems with variable referenced before assignment when using os.path.walk
OK. I have some background in Matlab and I'm now switching to Python.
I have this bit of code under Pythnon 2.6.5 on 64-bit Linux which scrolls through directories, finds files named 'GeneralData.dat', retrieves some data from them and sti... | Problems with variable referenced before assignment when using os.path.walk | OK. I have some background in Matlab and I'm now switching to Python.
I have this bit of code under Pythnon 2.6.5 on 64-bit Linux which scrolls through directories, finds files named 'GeneralData.dat', retrieves some data from them and stitches them into a new data set:
import pylab as p
import os, re
import linecache ... | [
"I would say this condition is not passing:\nif filepath == os.path.join(dirname,'GeneralData.dat'):\nwhich means you are not getting GeneralData.dat before ModelParams.dat. Maybe you need to sort alphabetically or the file is not there.\n",
"I see one issue with the code and the solution that you have provided.\... | [
0,
0,
0
] | [] | [] | [
"function",
"global_variables",
"python",
"variable_assignment"
] | stackoverflow_0004186764_function_global_variables_python_variable_assignment.txt |
Q:
python vlc.py or vlcwidget.py unable to open the MRL
I am encountering the following error. The mpg file is in the same directory where vlcwidget.py is located. Could some one point it out the issue or share thier experience?
C:\workspace\python-HEAD\python>vlcwidget.py trn_anaglyph_adj.mpg
libdvdnav: Using dvdna... | python vlc.py or vlcwidget.py unable to open the MRL | I am encountering the following error. The mpg file is in the same directory where vlcwidget.py is located. Could some one point it out the issue or share thier experience?
C:\workspace\python-HEAD\python>vlcwidget.py trn_anaglyph_adj.mpg
libdvdnav: Using dvdnav version 4.1.4
libdvdread: Using libdvdcss version 1.2.10... | [
"use full path? (maybe libvlc is running from wherever libvlc.dll is located or what not)...\n"
] | [
0
] | [] | [] | [
"python",
"vlc"
] | stackoverflow_0003887972_python_vlc.txt |
Q:
Python+ubuntu error
Am trying to run the following python program
import re
regex=re.compile("http...imgs.xkcd.com.comics.[\\S]*.[jpg|png]")
f=open('out.txt')
for a in f:
print regex.findall(a)
print '\n'
when I type the code into the interpreter manually, it works as expected
but when i save it as a file... | Python+ubuntu error | Am trying to run the following python program
import re
regex=re.compile("http...imgs.xkcd.com.comics.[\\S]*.[jpg|png]")
f=open('out.txt')
for a in f:
print regex.findall(a)
print '\n'
when I type the code into the interpreter manually, it works as expected
but when i save it as a file and try to run it , it g... | [
"Your file should start with shebang. You should include the path to the python interpreter\n#!/usr/bin/env python\nimport re\nregex=re.compile(\"http...imgs.xkcd.com.comics.[\\\\S]*.[jpg|png]\")\n\nCheck out : http://en.wikipedia.org/wiki/Shebang_(Unix)\n",
"This is probably executing as a bash script instead of... | [
3,
2,
1,
0
] | [] | [] | [
"python",
"ubuntu"
] | stackoverflow_0004187470_python_ubuntu.txt |
Q:
How can I check if my python object is a number?
In Java the numeric types all descend from Number so I would use
(x instanceof Number).
What is the python equivalent?
A:
Test if your variable is an instance of numbers.Number:
>>> import numbers
>>> import decimal
>>> [isinstance(x, numbers.Number) for x in (0,... | How can I check if my python object is a number? | In Java the numeric types all descend from Number so I would use
(x instanceof Number).
What is the python equivalent?
| [
"Test if your variable is an instance of numbers.Number:\n>>> import numbers\n>>> import decimal\n>>> [isinstance(x, numbers.Number) for x in (0, 0.0, 0j, decimal.Decimal(0))]\n[True, True, True, True]\n\nThis uses ABCs and will work for all built-in number-like classes, and also for all third-party classes if they... | [
322,
223,
60,
0
] | [
"That's not really how python works. Just use it like you would a number, and if someone passes you something that's not a number, fail. It's the programmer's responsibility to pass in the correct types.\n"
] | [
-7
] | [
"numbers",
"python",
"types"
] | stackoverflow_0004187185_numbers_python_types.txt |
Q:
How to handle button states efficiently in Tkinter
I've done a few searches but I couldn't find anything about this topic. Perhaps because it is common programmer knowledge (I'm not a programmer, I've learned from necessity), or because I'm going about it the wrong way.
I would like ideas/suggestions on how to ma... | How to handle button states efficiently in Tkinter | I've done a few searches but I couldn't find anything about this topic. Perhaps because it is common programmer knowledge (I'm not a programmer, I've learned from necessity), or because I'm going about it the wrong way.
I would like ideas/suggestions on how to manage button states for a GUI. For example, if I have a p... | [
"You are only changing button states based on events, right? There is no reason to 'poll' to see if a button state has changed. What you can do is build a function which does all of the calling for you, then call it with something like disable_buttons([okButton, graphButton, printButton]). When an event takes plac... | [
1
] | [] | [] | [
"button",
"python",
"state",
"tkinter"
] | stackoverflow_0004172426_button_python_state_tkinter.txt |
Q:
How to use refresh_access_token in the Yahoo Social Python SDK
I'm trying to use the Yahoo Social Python SDK to get a users contacts through oAuth. This is for a webapp running on App Engine. SO, I have everything set up to run through the oAuth dance, exchanging consumer keys and verifiers and all that jazz. I st... | How to use refresh_access_token in the Yahoo Social Python SDK | I'm trying to use the Yahoo Social Python SDK to get a users contacts through oAuth. This is for a webapp running on App Engine. SO, I have everything set up to run through the oAuth dance, exchanging consumer keys and verifiers and all that jazz. I store the token and can reuse it to retrieve a users contacts until th... | [
"Looks like something wrong with passing params. Try to debug oauth_token variable.\n",
"Solved. For reasons I can't understand, the above code now just works. It might have been a problem on yahoo's end, but I really can't be sure. It's been running fine for two weeks.\n"
] | [
0,
0
] | [] | [] | [
"google_app_engine",
"oauth",
"python",
"yahoo_api"
] | stackoverflow_0003946093_google_app_engine_oauth_python_yahoo_api.txt |
Q:
Streaming pipes in Python
I'm trying to convert the output of vmstat into a CSV file using Python, so I use something like this to convert to CSV and add the date and time as coloumns:
vmstat 5 | python myscript.py >> vmstat.log
The problem I'm having is it blocks while trying to iterate sys.stdin. It seems like ... | Streaming pipes in Python | I'm trying to convert the output of vmstat into a CSV file using Python, so I use something like this to convert to CSV and add the date and time as coloumns:
vmstat 5 | python myscript.py >> vmstat.log
The problem I'm having is it blocks while trying to iterate sys.stdin. It seems like the input buffer doesn't get fl... | [
"VMstat 5,does not close the stdout, so the python buffer is still waiting for more data.\nUse this instead:\nfor line in iter(sys.stdin.readline, \"\"):\n print line\n\n"
] | [
7
] | [] | [] | [
"python"
] | stackoverflow_0004187785_python.txt |
Q:
How to find total amount of memory used by python process/object in windows
I have some script that loads a lot of data to memory.
I want to know how efficient the data stored in memory.
So, I want to be able to know how many memory was used by python before I loaded data, and after I loaded data.
Also I wonderin... | How to find total amount of memory used by python process/object in windows | I have some script that loads a lot of data to memory.
I want to know how efficient the data stored in memory.
So, I want to be able to know how many memory was used by python before I loaded data, and after I loaded data.
Also I wondering, if it is some way to check memory usage of complex object.
Let say i have nest... | [
"As far as I know there is no easy way to see what the memory consumption of a certain object is. It would be a non-trivial thing to do because references could be shared among objects.\nHere are my two favourite workarounds:\n\nUse the process manager. Have the program pause for before allocation. Write down the m... | [
5,
2,
2,
0
] | [] | [] | [
"memory_management",
"python",
"windows"
] | stackoverflow_0004155126_memory_management_python_windows.txt |
Q:
How can I inspect a linux process to determine how/when a process dies/terminates?
I have a python irc bot which I start up as root by doing /etc/init.d/phenny start. Sometimes it dies, though and it seems to happen overnight.
What can I do to inspect it and see the status of the process in a text file?
A:
If yo... | How can I inspect a linux process to determine how/when a process dies/terminates? | I have a python irc bot which I start up as root by doing /etc/init.d/phenny start. Sometimes it dies, though and it seems to happen overnight.
What can I do to inspect it and see the status of the process in a text file?
| [
"If you're interested in really low level process activity, you can run the python interpreter under strace with standard error redirected to a file.\nIf you're only interested in inspecting the python code when your bot crashes, and you have the location in the source where the crash happens, you can wrap that loc... | [
1,
1,
0,
0,
0
] | [] | [] | [
"linux",
"process",
"python"
] | stackoverflow_0004070369_linux_process_python.txt |
Q:
Connecting and Saving Data With Redis Inside Celery Task
I have an object that saves data to Redis. It needs to block as less as possible, so I've decided to use Celery to offload the task. When I try to .save() the object outside of celery, it connects to Redis and stores the data just fine. However, when I try t... | Connecting and Saving Data With Redis Inside Celery Task | I have an object that saves data to Redis. It needs to block as less as possible, so I've decided to use Celery to offload the task. When I try to .save() the object outside of celery, it connects to Redis and stores the data just fine. However, when I try to do the exact same thing from a Celery task, it looks like it... | [
"The problem was being caused by a misconfiguration in the celeryconfig.py. CELERY_IMPORTS needed to include the task module. This is resolved. \n"
] | [
0
] | [] | [] | [
"celery",
"python",
"redis"
] | stackoverflow_0004188350_celery_python_redis.txt |
Q:
Plotting 3D scatter with python?
Is there any module that could aid me in producing something like this?
A:
Like this, say?
(source: sourceforge.net)
The matplotlib examples gallery is a wonderful thing to behold.
Code copied from the linked example.
import numpy as np
from mpl_toolkits.mplot3d import Axes3D... | Plotting 3D scatter with python? |
Is there any module that could aid me in producing something like this?
| [
"Like this, say?\n\n(source: sourceforge.net) \nThe matplotlib examples gallery is a wonderful thing to behold.\n\nCode copied from the linked example.\nimport numpy as np\nfrom mpl_toolkits.mplot3d import Axes3D\nimport matplotlib.pyplot as plt\n\ndef randrange(n, vmin, vmax):\n return (vmax-vmin)*np.random.ran... | [
6,
3,
1
] | [] | [] | [
"3d",
"python"
] | stackoverflow_0004188482_3d_python.txt |
Q:
Force locale for one function to be UK/English in just one function so that datetime.strftime always returns an English format
I need to write a very simple python function which accepts a date in Excel format (an integer of days elapsed since 1st Jan 1900). I convert that to a python datetime.date object, and fin... | Force locale for one function to be UK/English in just one function so that datetime.strftime always returns an English format | I need to write a very simple python function which accepts a date in Excel format (an integer of days elapsed since 1st Jan 1900). I convert that to a python datetime.date object, and finally I'd like to format that as a shortened string date (e.g. "Jan10" or "Mar11") - basically the date in MmmYY format.
dt.strftime(... | [
"If you need fixed strings then it's probably best to create a mapping of month number to month name and just use that.\nmonths = {1: 'Jan', 2: 'Feb', ...}\n\nprintf '%s%02d' % (months[somedt.month], somedt.year % 100)\n\n",
"Yes, this is possible to do. I've had this same problem when implementing a web server.... | [
0,
0
] | [] | [] | [
"internationalization",
"python",
"windows"
] | stackoverflow_0004186023_internationalization_python_windows.txt |
Q:
Problem running compiled Python script
So I have compiled a python script with py2exe according to this answer. There were no errors during compilation, everything went fine.
When I run the script from a cmd like this:
C:\Users\Richard\Dist\backprop3.exe 60
This is the output I get:
C:\Users\Richard>C:\Users\Rich... | Problem running compiled Python script | So I have compiled a python script with py2exe according to this answer. There were no errors during compilation, everything went fine.
When I run the script from a cmd like this:
C:\Users\Richard\Dist\backprop3.exe 60
This is the output I get:
C:\Users\Richard>C:\Users\Richard\Dist\backprop3.exe 60
Traceback (most re... | [
"__file__ will not work within py2exe. This is because the module is inside the .exe and thus there is nothing to set __file__ to which will give you the python file.\nSee http://www.py2exe.org/index.cgi/WhereAmI for techniques of dealing with this.\n"
] | [
8
] | [] | [] | [
"python"
] | stackoverflow_0004188708_python.txt |
Q:
How can I force urllib2 to time out?
I want to to test my application's handling of timeouts when grabbing data via urllib2, and I want to have some way to force the request to timeout.
Short of finding a very very slow internet connection, what method can I use?
I seem to remember an interesting application/sui... | How can I force urllib2 to time out? | I want to to test my application's handling of timeouts when grabbing data via urllib2, and I want to have some way to force the request to timeout.
Short of finding a very very slow internet connection, what method can I use?
I seem to remember an interesting application/suite for simulating these sorts of things. M... | [
"I usually use netcat to listen on port 80 of my local machine:\nnc -l 80\n\nThen I use http://localhost/ as the request URL in my application. Netcat will answer at the http port but won't ever give a response, so the request is guaranteed to time out provided that you have specified a timeout in your urllib2.url... | [
10,
6,
3,
0,
0
] | [] | [] | [
"python",
"urllib2"
] | stackoverflow_0004188723_python_urllib2.txt |
Q:
multiple layouts/layout transitions in a python plasmoid
I'm doing a little python plasmoid that deals with remote resources.
Here's the code : glpoid
It offers a view of tickets (the default one), a view that let the user filling and sending a new ticket, and a last one to see a ticket detail...
My problem is tha... | multiple layouts/layout transitions in a python plasmoid | I'm doing a little python plasmoid that deals with remote resources.
Here's the code : glpoid
It offers a view of tickets (the default one), a view that let the user filling and sending a new ticket, and a last one to see a ticket detail...
My problem is that i don't know how to "close" the current layout when i'm pass... | [
"You could use a Plasma.TabBar with hidden tabs and switch between them, as mentioned on IRC. Connect the clicked signals to slots that switch among tabs and everything should be fine.\nAlso, a note on style: you should use the new signal/slot API whenever possible:\nself.connect(self.refresh, SIGNAL('clicked()'), ... | [
1
] | [] | [] | [
"kde_plasma",
"plasmoid",
"python"
] | stackoverflow_0004173771_kde_plasma_plasmoid_python.txt |
Q:
Parsing HTML Tables with BeautifulSoup
I have used BeautifulSoup in the past but I am up against something new; incredibly generic/minimal HTML table markup... My goal is to grab each value and it's label (each in there own td) and print them out... They can be merged, I don't care, I just want to make sure each l... | Parsing HTML Tables with BeautifulSoup | I have used BeautifulSoup in the past but I am up against something new; incredibly generic/minimal HTML table markup... My goal is to grab each value and it's label (each in there own td) and print them out... They can be merged, I don't care, I just want to make sure each label is applied to the correct value. Here i... | [
"I'm not a BeautifulSoup expert, but you could try something like this:\nfor label in soup.findAll('table')[0].findAll('td', attrs={'class' : 'labels'}):\n data_sibs = label.findNextSiblings(attrs={'class' : 'site_data'})\n if len(data_sibs) > 0:\n print label.renderContents().strip() + \" \" + data_sibs[0].re... | [
2,
2
] | [] | [] | [
"beautifulsoup",
"html_table",
"python"
] | stackoverflow_0004188950_beautifulsoup_html_table_python.txt |
Q:
Admin search not working for my fields - Django
I have a model with an encrypted field.
So fields are encrypted and decrypted as they enter and leave the database.
The problem:
within the admin panel
?q='item' does not seem to find any rows
?field_name='item' does find them all!!
Any ideas? :)
A:
If I under... | Admin search not working for my fields - Django | I have a model with an encrypted field.
So fields are encrypted and decrypted as they enter and leave the database.
The problem:
within the admin panel
?q='item' does not seem to find any rows
?field_name='item' does find them all!!
Any ideas? :)
| [
"If I understand your question correctly you would have to encrypt the search term as well to fit to the entries in the database. This will most probably fail with the standard admin functionality, since all the fields specified as search fields will be handled in the same fashion. You would have to create your own... | [
1
] | [] | [] | [
"django",
"django_admin",
"django_models",
"django_queryset",
"python"
] | stackoverflow_0004187576_django_django_admin_django_models_django_queryset_python.txt |
Q:
bisect and lists of user defined objects (python 3)
Before python 3, I used bisect to insert user-defined objects into a list. bisect was happy with this because my user-defined object had a def __cmp__ that defined how to compare the objects. I've read the rationale for not supporting cmp in python 3 and I'm fi... | bisect and lists of user defined objects (python 3) | Before python 3, I used bisect to insert user-defined objects into a list. bisect was happy with this because my user-defined object had a def __cmp__ that defined how to compare the objects. I've read the rationale for not supporting cmp in python 3 and I'm fine with that. I thought a fix for my old code would be t... | [
"You need to add an __lt__ method; this is now what is used for comparisons instead of __cmp__\n"
] | [
17
] | [] | [] | [
"bisect",
"cmp",
"python",
"python_3.x"
] | stackoverflow_0004189505_bisect_cmp_python_python_3.x.txt |
Q:
Python subprocess produced output or not
This question is in relation to:
python, subprocess: reading output from subprocess
If P is a subprocess started with a command along the lines of
import subprocess
P = subprocess.Popen ("command", stdout=subprocess.PIPE)
we can read the output P produces by P.stdout.read... | Python subprocess produced output or not | This question is in relation to:
python, subprocess: reading output from subprocess
If P is a subprocess started with a command along the lines of
import subprocess
P = subprocess.Popen ("command", stdout=subprocess.PIPE)
we can read the output P produces by P.stdout.readline (). This is a blocking read though. How... | [
"If you are using *nix, then you can use the select module to poll the stdout file descriptor\nimport subprocess\nimport select\npoller = select.epoll()\n\nP = subprocess.Popen (\"command\", stdout=subprocess.PIPE)\npoller.register(P.stdout, select.EPOLLHUP)\n\nwhile True:\n #block indefinitely: timeout = -1\n ... | [
0
] | [] | [] | [
"communication",
"python",
"subprocess"
] | stackoverflow_0004189551_communication_python_subprocess.txt |
Q:
How to find the set of entities more recent than the last one with children
I have two SQLAlchemy model objects designated thus:
class SpecInstance(Base):
spec_id = Column(Integer, ForeignKey('spec.spec_id'))
details = Column(String)
class Spec(Base):
spec_id = Column(Integer)
spec_date = Column(D... | How to find the set of entities more recent than the last one with children | I have two SQLAlchemy model objects designated thus:
class SpecInstance(Base):
spec_id = Column(Integer, ForeignKey('spec.spec_id'))
details = Column(String)
class Spec(Base):
spec_id = Column(Integer)
spec_date = Column(DateTime)
instances = relationship(SpecInstance, backref="spec", cascade="all,... | [
"I'm not testing this code since I'm pretty sure it will work and setting up the env is an overhead.\nIn plain SQL, one will do this with a subquery. In sqlalchemy, subqueries are created in this manner:\nsq = session.query(Spec.spec_date.label('most_recent'))\\\n .join((SpecInstance, SpecInstance.spec_i... | [
0
] | [] | [] | [
"orm",
"python",
"sqlalchemy"
] | stackoverflow_0004188312_orm_python_sqlalchemy.txt |
Q:
Why is save not working in Django?
I'm using manage.py shell and run something like this:
d=Document.objects.get(pk=1)
d.scores
{1:0,2:0,3:0}
d.scores[1]=5
d.scores
{1:5,2:0,3:0}
d.save()
But viewing d in the database reveals that it hasn't been updated. What am I doing wrong?? I checked out what's here, but... | Why is save not working in Django? | I'm using manage.py shell and run something like this:
d=Document.objects.get(pk=1)
d.scores
{1:0,2:0,3:0}
d.scores[1]=5
d.scores
{1:5,2:0,3:0}
d.save()
But viewing d in the database reveals that it hasn't been updated. What am I doing wrong?? I checked out what's here, but d is definitely a Document instance.
If... | [
"Your 'scores' class variable isn't an instance of any of Django's *Field classes. I would imagine the 'scores' field isn't even on the table in the DB, since the field classes are what defines all of that, and what gets saved to the DB, among other things.\n"
] | [
6
] | [] | [] | [
"django",
"python"
] | stackoverflow_0004189700_django_python.txt |
Q:
Python: RE vs. Query
I am building a website using Django, and this website uses blocks which are enabled for a certain page.
Right now I use a textfield containing paths were a block is enabled. When a page is requested, Django retrieves all blocks from database and does re.search on the TextField.
However, I was... | Python: RE vs. Query | I am building a website using Django, and this website uses blocks which are enabled for a certain page.
Right now I use a textfield containing paths were a block is enabled. When a page is requested, Django retrieves all blocks from database and does re.search on the TextField.
However, I was wondering if it is not a ... | [
"A seperate DB table is definitely the \"right\" way to do it, because mysql has to send all the data from your TEXT fields every time you query. As you add more rows and the TEXT fields get bigger, you'll start to notice performance issues and eventually crash the server. Also, you'll be able to use VARCHAR and ad... | [
2,
1
] | [] | [] | [
"django",
"mysql",
"python"
] | stackoverflow_0004183554_django_mysql_python.txt |
Q:
Python SQL DB string literals and escaping
Anyone know if the MySQLdb will automatically escape string literals for SQL statements?
For instance I am trying to execute the following:
cursor.execute("""SELECT * FROM `accounts` WHERE `account_name` = 'Blah'""")
Will this escape the account name automatically? Or wi... | Python SQL DB string literals and escaping | Anyone know if the MySQLdb will automatically escape string literals for SQL statements?
For instance I am trying to execute the following:
cursor.execute("""SELECT * FROM `accounts` WHERE `account_name` = 'Blah'""")
Will this escape the account name automatically? Or will it only escape if I do the following?:
x = 'B... | [
"There is no escaping in the first example, it is a raw SQL query. It's valid, it'll work, but obviously it only makes sense if you always want to search for account Blah.\nWhen you need to get an account from a name in a variable, you will need the parameterised version. However your example may not work as expect... | [
2,
1
] | [] | [] | [
"literals",
"mysql",
"python",
"sql",
"string"
] | stackoverflow_0004189808_literals_mysql_python_sql_string.txt |
Q:
What does [:] do?
return self.var[:]
What will that return?
A:
Python permits you to "slice" various container types; this is a shorthand notation for taking some subcollection of an ordered collection. For instance, if you have a list
foo = [1,2,3,4,5]
and you want the second, third, and fourth elements, you ... | What does [:] do? | return self.var[:]
What will that return?
| [
"Python permits you to \"slice\" various container types; this is a shorthand notation for taking some subcollection of an ordered collection. For instance, if you have a list\nfoo = [1,2,3,4,5]\n\nand you want the second, third, and fourth elements, you can do:\nfoo[1:4]\n\nIf you omit one of the numbers in the sl... | [
9,
5,
2,
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0004189446_python.txt |
Q:
Python script opening a bash prompt terminating the script
I want to write a chroot wrapper in python. The script will be copying some files, setting up some other stuff and then executing chroot and should land me in a chroot shell.
The tricky part is that I want no python processes running after I am in the chro... | Python script opening a bash prompt terminating the script | I want to write a chroot wrapper in python. The script will be copying some files, setting up some other stuff and then executing chroot and should land me in a chroot shell.
The tricky part is that I want no python processes running after I am in the chroot.
In other words, python should do the setup work, call chroot... | [
"My first thought would be to use one of the os.exec* functions. These will replace the Python process with the chroot process (or whatever you decide to run with exec*).\n# ... do setup work\nos.execl('/bin/chroot', '/bin/chroot', directory_name, shell_path)\n\n(or something like that)\n",
"Alternatively, you ca... | [
2,
0
] | [] | [] | [
"bash",
"chroot",
"process",
"python",
"terminate"
] | stackoverflow_0004189878_bash_chroot_process_python_terminate.txt |
Q:
Why does Sqlite tell me no such column exists when I plainly created it?
in Python 2.6.5 with sqlite3.version 2.4.1, I use the following code:
c = conn.cursor()
# Create table
c.execute('''create table stocks
(date text, trans text, symbol text,
qty real, price real)''')
# Insert a row of data
c.execute("""inse... | Why does Sqlite tell me no such column exists when I plainly created it? | in Python 2.6.5 with sqlite3.version 2.4.1, I use the following code:
c = conn.cursor()
# Create table
c.execute('''create table stocks
(date text, trans text, symbol text,
qty real, price real)''')
# Insert a row of data
c.execute("""insert into stocks
values ('2006-01-05','BUY','RHAT',100,35.14)""")
# S... | [
"Incorrect syntax for that insert statement. This will work:\n>>> c.execute('''insert into stocks \n (date, trans, symbol, qty, price)values(?,?,?,?,?)''', \n ('08-26-1984', 'SELL', 'GOGL', 3, 400.00))\n\n"
] | [
8
] | [] | [] | [
"python",
"sqlite"
] | stackoverflow_0004190476_python_sqlite.txt |
Q:
python: how to create persistent in-memory structure for debugging
[Python 3.1]
My program takes a long time to run just because of the pickle.load method on a huge data structure. This makes debugging very annoying and time-consuming: every time I make a small change, I need to wait for a few minutes to see if th... | python: how to create persistent in-memory structure for debugging | [Python 3.1]
My program takes a long time to run just because of the pickle.load method on a huge data structure. This makes debugging very annoying and time-consuming: every time I make a small change, I need to wait for a few minutes to see if the regression tests passed.
I would like replace pickle with an in-memory... | [
"You can use mmap to open a view on the same file in multiple processes, with access at almost the speed of memory once the file is loaded.\n",
"First you can pickle different parts of the hole object using this method:\n# gen_objects.py\n\nimport random\nimport pickle\n\nclass BigBadObject(object):\n def __ini... | [
1,
0
] | [] | [] | [
"debugging",
"persistence",
"python",
"python_3.x"
] | stackoverflow_0004189721_debugging_persistence_python_python_3.x.txt |
Q:
Accessing the name that an object being created is assigned to
I'm writing some code to determine the name that an object is assigned to. This is for general debugging work and to further familiarize myself with python internals.
I have it structured as a class decorator so that all instances of that class will ha... | Accessing the name that an object being created is assigned to | I'm writing some code to determine the name that an object is assigned to. This is for general debugging work and to further familiarize myself with python internals.
I have it structured as a class decorator so that all instances of that class will have their names recorded if it is possible to do. The code is fairly ... | [
"The AST can't give you that answer. Try using frame.f_lasti and then peeking into the bytecode. If the next line isn't a STORE_FAST, you've got interior calls or something else\ngoing on other than the simple assignment you're looking for.\ndef f():\n f = sys._getframe()\n i = f.f_lasti + 3 # capture current p... | [
2,
0,
0,
0
] | [] | [] | [
"python",
"python_internals"
] | stackoverflow_0003744792_python_python_internals.txt |
Q:
How to fix a Python elif?
Okay I have the below code performing something I don't want it to do. If you run the program it will ask you "How are you?" (obviously), but when you give a answer to the question that applies to the elif statement, I still get a if statement response. Why is this?
talk = raw_input("How ... | How to fix a Python elif? | Okay I have the below code performing something I don't want it to do. If you run the program it will ask you "How are you?" (obviously), but when you give a answer to the question that applies to the elif statement, I still get a if statement response. Why is this?
talk = raw_input("How are you?")
if "good" or "fine" ... | [
"The problem is that the or operator does not do what you want here. What you're really saying is if the value of \"good\" is True or \"fine\" is in talk. The value of \"good\" is always True, since it's a non-empty string, which is why that branch always gets executed.\n",
"if \"good\" in talk or \"fine\" in tal... | [
8,
4,
2,
2,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0004190701_python.txt |
Q:
Fixing an Or Statement With Variables
How would I change the below code so Python reads the list which is inside the two variables and then perform an action after that without reeving an error? My code:
bad = ['bad','terrible', 'dumb']
good = ['good','happy','awesome']
talk = raw_input("type:")
if (bad) in talk:
... | Fixing an Or Statement With Variables | How would I change the below code so Python reads the list which is inside the two variables and then perform an action after that without reeving an error? My code:
bad = ['bad','terrible', 'dumb']
good = ['good','happy','awesome']
talk = raw_input("type:")
if (bad) in talk:
print "I'm sorry to hear that :("
elif... | [
"Try this:\nbad = set(['bad','terrible', 'dumb'])\ngood = set(['good','happy','awesome'])\ntalk = raw_input(\"type:\")\nif bad & set(talk.lower().split()):\n print \"I'm sorry to hear that :(\"\nelif good & set(talk.lower().split()):\n print \"That's good!\"\n\n",
"Does this get you what you want?\nbad = ... | [
6,
3,
0
] | [] | [] | [
"python"
] | stackoverflow_0004190841_python.txt |
Q:
Tracing Python warnings/errors to a line number in numpy and scipy
I am getting the error:
Warning: invalid value encountered in log
From Python and I believe the error is thrown by numpy (using version 1.5.0). However, since I am calling the "log" function in several places, I'm not sure where the error is comi... | Tracing Python warnings/errors to a line number in numpy and scipy | I am getting the error:
Warning: invalid value encountered in log
From Python and I believe the error is thrown by numpy (using version 1.5.0). However, since I am calling the "log" function in several places, I'm not sure where the error is coming from. Is there a way to get numpy to print the line number that gene... | [
"Putting np.seterr(invalid='raise') in your code (before the errant log call)\nwill cause numpy to raise an exception instead of issuing a warning.\nThat will give you a traceback error message and tell you the line Python was executing when the error occurred.\n",
"If you have access to the numpy source, you sho... | [
22,
0
] | [] | [] | [
"numeric",
"numpy",
"python",
"scientific_computing",
"scipy"
] | stackoverflow_0004190817_numeric_numpy_python_scientific_computing_scipy.txt |
Q:
Python: open and display a text file at a specific line
I don't use Python very often, but I sometimes develop simple tools in it to make my life easier. My most frequently used is a log checker/crude debugger for SAS. It reads the SAS log line by line checking for any errors in my list and dumps anything it fin... | Python: open and display a text file at a specific line | I don't use Python very often, but I sometimes develop simple tools in it to make my life easier. My most frequently used is a log checker/crude debugger for SAS. It reads the SAS log line by line checking for any errors in my list and dumps anything it finds into standard out (I'm running Python 2.6 in a RedHat Linu... | [
"Once you've got the line number, you can run gvim filename -c 12 and it will go to line 12 (this is because -c <command> is \"Execute <command> after loading the first file\", so -c 12 is just saying run :12 after loading the file).\nSo I'm not sure if you really need Python at all in this case; just sending the l... | [
3,
2,
1
] | [] | [] | [
"python",
"vim"
] | stackoverflow_0004190695_python_vim.txt |
Q:
Is there a Ruby site like this python.mirocommunity.org (python)?
Is there a Ruby site like this http://python.mirocommunity.org (python videos). This is a great Python site, love to find a equivalent RUBY site any ideas? Maybe someone should start one?
Thankyou in advance ;-)
A:
For Rails this site is very pop... | Is there a Ruby site like this python.mirocommunity.org (python)? | Is there a Ruby site like this http://python.mirocommunity.org (python videos). This is a great Python site, love to find a equivalent RUBY site any ideas? Maybe someone should start one?
Thankyou in advance ;-)
| [
"For Rails this site is very popular: http://railscasts.com/\n",
"Something like those:\n\nhttp://rubyreflector.com/\nhttp://rubycorner.com/\n\n",
"Not as organized as \"http://python.mirocommunity.org\" but you may find this useful\n\nhttp://confreaks.net/events\n\n"
] | [
3,
1,
1
] | [] | [] | [
"jruby",
"python",
"ruby",
"ruby_on_rails",
"rubygems"
] | stackoverflow_0004185063_jruby_python_ruby_ruby_on_rails_rubygems.txt |
Q:
Python xml etree DTD from a StringIO source?
I'm adapting the following code (created via advice in this question), that took an XML file and it's DTD and converted them to a different format. For this problem only the loading section is important:
xmldoc = open(filename)
parser = etree.XMLParser(dtd_validation=T... | Python xml etree DTD from a StringIO source? | I'm adapting the following code (created via advice in this question), that took an XML file and it's DTD and converted them to a different format. For this problem only the loading section is important:
xmldoc = open(filename)
parser = etree.XMLParser(dtd_validation=True, load_dtd=True)
tree = etree.parse(xmldoc,... | [
"Here's a short but complete example, using the custom resolver technique @Steven mentioned.\nfrom StringIO import StringIO\nfrom lxml import etree\n\ndata = dict(\n xml_file = '''<?xml version=\"1.0\"?>\n<!DOCTYPE x SYSTEM \"a.dtd\">\n<x><y>ézz</y></x>\n''',\n dtd_file = '''<!ENTITY eacute \"é\">... | [
5,
1
] | [] | [] | [
"dtd",
"lxml",
"python",
"xml"
] | stackoverflow_0003817137_dtd_lxml_python_xml.txt |
Q:
How can I store my atom data so my IRC bot can access it? Should I use SQL at all?
I want to add feeds such as ajaxian, smashingmagazine and store feeds starting today on my server, in order so that I can push the new items to my irc bot so it can echo them in my channel.
I will get ATOM data from this service: ht... | How can I store my atom data so my IRC bot can access it? Should I use SQL at all? | I want to add feeds such as ajaxian, smashingmagazine and store feeds starting today on my server, in order so that I can push the new items to my irc bot so it can echo them in my channel.
I will get ATOM data from this service: http://superfeedr.com/subscriber .. so I'm wondering which of the NoSQL storage mechanisms... | [
"I would say that you will have to use the database you are most comfortable with.\nAlso look at the CAP Theorem to clarify better what exactly you need.\nCouple of minutes ago I replied to a similar question. So you can have a look.\n",
"I want to store external rss feed data - is this a good reason to use NoSQL... | [
0,
0,
0
] | [] | [] | [
"atom_feed",
"nosql",
"python",
"rss",
"sql"
] | stackoverflow_0004189691_atom_feed_nosql_python_rss_sql.txt |
Q:
"Unsupported hash type" error w/ Python 2.6.5 and django framework
My registration form is throwing a ValueError during form.save() in my custom registration form's password field.
Here are the exception details (copied from http://www.pastie.org/1299144):
Environment:
Request Method: POST
Request URL: http://192... | "Unsupported hash type" error w/ Python 2.6.5 and django framework | My registration form is throwing a ValueError during form.save() in my custom registration form's password field.
Here are the exception details (copied from http://www.pastie.org/1299144):
Environment:
Request Method: POST
Request URL: http://192.168.2.206:8080/register/
Django Version: 1.1.1
Python Version: 2.6.5
In... | [
"It looks like you're trying to implement your own registration framework with it. What's wrong with the existing one? I think you should read more about the Django framework generally and go through the tutorial.\nLooking at that traceback, the problem is in the line hashlib.new(str(random.random())).hexdigest()[:... | [
4,
1,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0004183016_django_python.txt |
Q:
python itertools skipping ahead
I have a list of lists. Using itertools, I am basically doing
for result in product([A,B],[C,D],[E,F,G]):
# test each result
and the result is the desired product, with each result containing one element from each of the lists. My code tests each of the results element-by-elem... | python itertools skipping ahead | I have a list of lists. Using itertools, I am basically doing
for result in product([A,B],[C,D],[E,F,G]):
# test each result
and the result is the desired product, with each result containing one element from each of the lists. My code tests each of the results element-by-element, looking for the first (and best... | [
"itertools is not the best way to go with the concern you have.\nIf you just have 3 sets to combine, just loop over and when you fail, break the loops. (If you code is complex, set a variable and break right outside.\nfor i1 in [A, B]:\n for i2 in [C, D]:\n for i3 in [E, F, G]:\n if not test(i1, i2, i... | [
1
] | [] | [] | [
"python",
"python_itertools"
] | stackoverflow_0004190966_python_python_itertools.txt |
Q:
Python string replace for UTF-16-LE file
Python 2.6
Using Python string.replace() seems not working for UTF-16-LE file. I think of 2 ways:
Find a Python module that can handle Unicode string manipulate.
Convert the target Unicode file to ASCII, use string.replace(), then convert it back. But I am worry about this... | Python string replace for UTF-16-LE file | Python 2.6
Using Python string.replace() seems not working for UTF-16-LE file. I think of 2 ways:
Find a Python module that can handle Unicode string manipulate.
Convert the target Unicode file to ASCII, use string.replace(), then convert it back. But I am worry about this may cause loss data.
Can the community sugge... | [
"You don't have a Unicode file. There is no such thing (unless you are the author of NotePad, which conflates \"Unicode\" and \"UTF-16LE\").\nPlease read the Python Unicode HOWTO and Joel on Unicode.\nUpdate I'm glad the suggested reading helped you. Here's a better version of your code:\ninfile = codecs.open(infil... | [
11,
1
] | [] | [] | [
"python",
"string"
] | stackoverflow_0004190683_python_string.txt |
Q:
Where is the entry-point of the C code generating by pypy
I'm using PyPy to translate some python code to C code. I wrote a very simple script as below:
def main():
print "hello world!"
def entry_point(argv):
main()
return 0
def target(*args):
return entry_point, None
Then I used translate.py --... | Where is the entry-point of the C code generating by pypy | I'm using PyPy to translate some python code to C code. I wrote a very simple script as below:
def main():
print "hello world!"
def entry_point(argv):
main()
return 0
def target(*args):
return entry_point, None
Then I used translate.py --source test.py. It did generate C code successful. When I make ... | [
"that's incorrect. Grep for pypy_g_entry_point. main() function is likely to be inlined in this example, so you won't get it. If you want it to be rendered use --inline-threshold=0 as a translation parameter.\n",
"PyPy is probably not giving you a \"main\" function because you actually don't have an entry point i... | [
2,
1
] | [] | [] | [
"c",
"entry_point",
"pypy",
"python"
] | stackoverflow_0004190481_c_entry_point_pypy_python.txt |
Q:
How to compile a svn python binding for windows from the source?
I'm setting up a new svn+trac environment, the svn server's version is 1.6.11, then I can't find any corresponding pre-compiled svn-python binding, finally I found the following thread:
Python SVN bindings for Windows
so, my question is: how to compi... | How to compile a svn python binding for windows from the source? | I'm setting up a new svn+trac environment, the svn server's version is 1.6.11, then I can't find any corresponding pre-compiled svn-python binding, finally I found the following thread:
Python SVN bindings for Windows
so, my question is: how to compile from these source?
http://svn.apache.org/viewvc/subversion/trunk/su... | [
"The win32svn project, Subversion for Windows, by alagazam,\nis a win32 build of subversion.\nAs of November 2010, the latest build is 1.6.13 dated 2010-10-05,\nincluding python 2.6 bindings.\nBuilds of earlier SVN versions on the same page include 1.6.11.\n"
] | [
3
] | [] | [] | [
"python",
"svn",
"windows"
] | stackoverflow_0002894744_python_svn_windows.txt |
Q:
How to fix Python error importing ElementTree?
I'm beginning to learn python and here I'm trying to read from an xml file using ElementTree:
import sys
from elementtree.ElementTree import ElementTree
doc = ElementTree(file="test.xml")
doc.write(sys.stdout)
However I get this error:
File "my_xml.py", line 2, i... | How to fix Python error importing ElementTree? | I'm beginning to learn python and here I'm trying to read from an xml file using ElementTree:
import sys
from elementtree.ElementTree import ElementTree
doc = ElementTree(file="test.xml")
doc.write(sys.stdout)
However I get this error:
File "my_xml.py", line 2, in
from elementtree.ElementTree import ElementTr... | [
"It should be:\nfrom xml.etree.ElementTree import ElementTree\n\nMore information on this can be found at the Python docs.\n"
] | [
14
] | [] | [] | [
"python",
"xml"
] | stackoverflow_0004192410_python_xml.txt |
Q:
What does django resolve_variable do? (template.Variable)
What does resolve_variable do? And could I use it for accessing the request outside of the view?
Edit
So template.Variable is the correct way to go - but I'm still unsure of its purpose. The documentation doesn't really help.
Cheers guys.
A:
I'm assuming... | What does django resolve_variable do? (template.Variable) | What does resolve_variable do? And could I use it for accessing the request outside of the view?
Edit
So template.Variable is the correct way to go - but I'm still unsure of its purpose. The documentation doesn't really help.
Cheers guys.
| [
"I'm assuming your trying to write a custom template tag here, so here's what you do.\nIn your compilation function, you bind the variable like so:\n@register.tag\ndef my_tag(parser, token):\n # This version uses a regular expression to parse tag contents.\n try:\n # Splitting by None == splitting by s... | [
5,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0004183252_django_python.txt |
Q:
How to add extra fields using django.forms Textarea
I am newbie in django and working on a pootle project.
I would like to add bio (in textarea), interests (textarea), and profile pics (image upload). this page is looking like this: http://pootle.locamotion.org/accounts/personal/edit/ (you might need to login to ... | How to add extra fields using django.forms Textarea | I am newbie in django and working on a pootle project.
I would like to add bio (in textarea), interests (textarea), and profile pics (image upload). this page is looking like this: http://pootle.locamotion.org/accounts/personal/edit/ (you might need to login to see this page)
I have edited local_apps/pootle_profile/vi... | [
"Firstly, as Digitalpbk says, don't manually add columns to Django's tables. Instead, create a UserProfile model in your own app, with a OneToOneField to auth.User.\nSecondly, to add extra fields to a modelform, you need to define them explicitly at the form level:\nclass UserForm(ModelForm): ... | [
13,
1
] | [] | [] | [
"django",
"django_forms",
"django_templates",
"django_views",
"python"
] | stackoverflow_0004190386_django_django_forms_django_templates_django_views_python.txt |
Q:
a question about this python script!
if __name__=="__main__":
fname= raw_input("Please enter your file:")
mTrue=1
Salaries=''
Salarieslist={}
Employeesdept=''
Employeesdeptlist={}
try:
f1=open(fname)
except:
mTrue=0
print 'The %s does not exist!'%fname
if... | a question about this python script! | if __name__=="__main__":
fname= raw_input("Please enter your file:")
mTrue=1
Salaries=''
Salarieslist={}
Employeesdept=''
Employeesdeptlist={}
try:
f1=open(fname)
except:
mTrue=0
print 'The %s does not exist!'%fname
if mTrue==1:
ss=[]
for x ... | [
"I can give you some hints which can help you to resolve problem better\nCreate a function and call it in main e.g. \nif __name__==\"__main__\":\n main()\n\nDon't put whole block under if mTrue==1: instead just return from function on error e.g.\ndef main():\n fname= raw_input(\"Please enter your file:\")\n ... | [
4,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0004190977_python.txt |
Q:
how to filled the data in django templates
I want to email a template in django. The template has one variable say name. I want to filled this value. How to do that. context is not working because i don't need to render the page.
A:
Of course you need to render the template - and you do that via the context. How... | how to filled the data in django templates | I want to email a template in django. The template has one variable say name. I want to filled this value. How to do that. context is not working because i don't need to render the page.
| [
"Of course you need to render the template - and you do that via the context. How is it not working?\n",
"\ncontext is not working because i don't need to render the page.\n\nI guess what you are looking for is render_to_string shortcut.\n",
"Try this\nfrom django.template.loader import render_to_string\ntext =... | [
1,
0,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0004192675_django_python.txt |
Q:
import os to j2me
I am trying to write this code to j2me. Does anyone has any idea how to do this?
Thanks!
import os
if os.path.isfile("c:\\python\\myfolder\\test.txt"):
A:
Understand what the line does. You can start with the docs to Python's os module: http://docs.python.org/library/os.path.html
Read the J2ME ... | import os to j2me | I am trying to write this code to j2me. Does anyone has any idea how to do this?
Thanks!
import os
if os.path.isfile("c:\\python\\myfolder\\test.txt"):
| [
"\nUnderstand what the line does. You can start with the docs to Python's os module: http://docs.python.org/library/os.path.html\nRead the J2ME docs to find a similar function call.\n\n",
"Something like what is below. Might help.. Just remember the phone needs to support JS175\n try {\n fconn = (FileConnectio... | [
1,
0
] | [] | [] | [
"blackberry",
"java",
"java_me",
"python"
] | stackoverflow_0004191546_blackberry_java_java_me_python.txt |
Q:
(py)cairo - fill
is there a way to fill everything outside of a closed path (polygon)?
Background: I'd like to render some maps with coastlines - so sometimes I need to fill the sea with blue color, so I thought it would be the easiest and in my situation the most efficient to fill everything outside of this coast... | (py)cairo - fill | is there a way to fill everything outside of a closed path (polygon)?
Background: I'd like to render some maps with coastlines - so sometimes I need to fill the sea with blue color, so I thought it would be the easiest and in my situation the most efficient to fill everything outside of this coastline polygon with blue... | [
"You can add a rectangle covering the whole drawing area to your coastline path and set the fill rule to cairo.FILL_RULE_EVEN_ODD. Calling fill() after this fills the area outside your original path. (If you choose the correct orientation for your rectangle you can skip setting the fill rule.)\n",
"Draw a big b... | [
4,
0,
0
] | [] | [] | [
"cairo",
"pycairo",
"python"
] | stackoverflow_0004192384_cairo_pycairo_python.txt |
Q:
IIS and ISAPI-WSGI = very slow
I have loaded 2 Django apps on IIS using isapi-wsgi.
These are both server setups:
Windows Server 2003, IIS6 and SQL Server 2005
Windows Server 2008 R2, IIS7.5 and SQL Server 2008
The Django apps are completely different from each other.
They both take random periods of time for ... | IIS and ISAPI-WSGI = very slow | I have loaded 2 Django apps on IIS using isapi-wsgi.
These are both server setups:
Windows Server 2003, IIS6 and SQL Server 2005
Windows Server 2008 R2, IIS7.5 and SQL Server 2008
The Django apps are completely different from each other.
They both take random periods of time for each requests between 1 and 10 secon... | [
"Install another web server, like apache.\nSeriously - IIS sucks on running python wsgi apps. There's not much you can do in that regard.\n"
] | [
-3
] | [] | [] | [
"django",
"iis",
"isapi",
"isapi_wsgi",
"python"
] | stackoverflow_0004193619_django_iis_isapi_isapi_wsgi_python.txt |
Q:
python print and whitespace
I am trying to print a result for example:
for record in result:
print varone,vartwo,varthree
I am trying to concatenate the variables which are from an SQL query, but I am getting whitespace. How can I strip whitespace from a 'print'? Should I feed the result into a variable then ... | python print and whitespace | I am trying to print a result for example:
for record in result:
print varone,vartwo,varthree
I am trying to concatenate the variables which are from an SQL query, but I am getting whitespace. How can I strip whitespace from a 'print'? Should I feed the result into a variable then do a 'strip(newvar)' then print t... | [
"This:\nprint \"%s%s%s\" % (varone,vartwo,varthree)\n\nwill replace the first %s in the quotes with the value in varone, the second %s with the contents of vartwo, etc.\nEDIT:\nAs of Python 2.6 you should prefer this method:\nprint \"{0}{1}{2}\".format(varone,vartwo,varthree)\n\n(Thanks Space_C0wb0y)\n",
"print p... | [
4,
1,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0004193920_python.txt |
Q:
Python's example for "iter" function gives me TypeError
The iter function example at python docs:
with open("mydata.txt") as fp:
for line in iter(fp.readline):
print line
gives me this:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
TypeError: 'builtin_function_or_method' obj... | Python's example for "iter" function gives me TypeError | The iter function example at python docs:
with open("mydata.txt") as fp:
for line in iter(fp.readline):
print line
gives me this:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
TypeError: 'builtin_function_or_method' object is not iterable
How's that possible? (Python 2.6.4)
| [
"It's because I'm stupid and can't read:\n\nWithout a second argument, o must be a collection object which supports the iteration protocol (the iter() method), or it must support the sequence protocol (the getitem() method with integer arguments starting at 0). If it does not support either of those protocols, Type... | [
4,
2
] | [
"The only thing I can think about is that you don't have a file called mydata.txt or it is in the wrong place.\n"
] | [
-2
] | [
"python",
"typeerror"
] | stackoverflow_0004193957_python_typeerror.txt |
Q:
problem with uploading and downloading xml document from Datastore using google app and python
i am creating one xml document in my google app and storing it as blob while fetching back from datastore how do i convert it to again xml doc
class xmlStore(db.Model):
xmlRef=db.BlobProperty()
creating xml doc like... | problem with uploading and downloading xml document from Datastore using google app and python | i am creating one xml document in my google app and storing it as blob while fetching back from datastore how do i convert it to again xml doc
class xmlStore(db.Model):
xmlRef=db.BlobProperty()
creating xml doc like this:
docRef=Document()
fp=docRef.createElement("Client")
fp.setAttribute("ID","21783")
docRef.appe... | [
"Have a look at Python's documentation about xml.dom.minidom toxml method.\nYou say:\n\nits giving me xml.dom.minidom.Document\n instance at 0x6a2bddb0b5aef438\n\nCall the .toxml() method of that object.\n"
] | [
0
] | [] | [] | [
"google_app_engine",
"python",
"xml"
] | stackoverflow_0004193509_google_app_engine_python_xml.txt |
Q:
AppEngine: IOError when saving a lot of objects to the Datastore
Cheers all. I'm running Ubuntu 10.04 and the latest Google AppEngine SDK. I'm working on a simple website which has posts and comments to posts. I basically implemented a simple tree to store my comments with a parent_comment, left and right values.
... | AppEngine: IOError when saving a lot of objects to the Datastore | Cheers all. I'm running Ubuntu 10.04 and the latest Google AppEngine SDK. I'm working on a simple website which has posts and comments to posts. I basically implemented a simple tree to store my comments with a parent_comment, left and right values.
I created an event which fires before a new (not is_saved()) comment i... | [
"I had the same problem for a massive taskqueue worker.\nSwitching to SQLite for your local Datastore could solve the problem:\ndev_appserver.py --use_sqlite \n\n\nSince App Engine SDK 1.3.3, the Python\n SDK has a new experimental feature\n that gives the option to use SQLite\n as the datastore stub backend. U... | [
2,
1
] | [] | [] | [
"binary_tree",
"google_app_engine",
"python",
"ubuntu"
] | stackoverflow_0004193610_binary_tree_google_app_engine_python_ubuntu.txt |
Q:
Make OptionMenu Widget Scrollable?
I've got an option menu that's about 60 items long and, needless to say, I can't see it all on the screen at once. Is there a way that I can make the OptionMenu widget in tkinter scrollable?
A:
Short answer is no, but you could try a ComboBox mega-widget (quick search will thro... | Make OptionMenu Widget Scrollable? | I've got an option menu that's about 60 items long and, needless to say, I can't see it all on the screen at once. Is there a way that I can make the OptionMenu widget in tkinter scrollable?
| [
"Short answer is no, but you could try a ComboBox mega-widget (quick search will throw some suitable examples up there) which could be a 'good enough' alternative (in fact with it being a combined entry field and scrolled list you could make it 'smart' by including auto-search / auto-complete - 60 items in a drop d... | [
2
] | [] | [] | [
"python",
"tkinter"
] | stackoverflow_0004186981_python_tkinter.txt |
Q:
How I can retrieve webcam info in python?
I need to retrieve the number of webcams instaled in my system and the brand, manufacturer, device id, etc., of the webcam.
Is there any way to do that in Python, and independent of the operating system?
A:
There's no truly cross-platform solution, but on Linux you can u... | How I can retrieve webcam info in python? | I need to retrieve the number of webcams instaled in my system and the brand, manufacturer, device id, etc., of the webcam.
Is there any way to do that in Python, and independent of the operating system?
| [
"There's no truly cross-platform solution, but on Linux you can use os.popen('lsusb') (or something along those lines) and then just scrape the screen (using grep or something else). For finding out on Windows, you can try using a TWAIN binding for Python (it's the Windows webcam protocol, a Python binding exists h... | [
0,
0
] | [] | [] | [
"python",
"webcam"
] | stackoverflow_0004186052_python_webcam.txt |
Q:
Django in Eclipse, laying out the project
Any "best practice" or "recommended" project layouts for a django project in eclipse?
In my eclipse it looks like this:
project name
-src
--project name
---__init__.py
---manage.py
---settings.py
---urls.py
---apps
----app1
-----__init__.py
-----forms.py
-----urls.py
---... | Django in Eclipse, laying out the project | Any "best practice" or "recommended" project layouts for a django project in eclipse?
In my eclipse it looks like this:
project name
-src
--project name
---__init__.py
---manage.py
---settings.py
---urls.py
---apps
----app1
-----__init__.py
-----forms.py
-----urls.py
-----views.py
-----templates
------app1
-------ind... | [
"you know you can create a django project without the src folder in eclipse which i think will be much cleaner; to do this when you want to create a new Django project the widget that ask for the name of the project in the bottom you can disable Create default \"scr\" ... .\nAnd i don't think it's a good idea to pu... | [
2,
1,
1
] | [] | [] | [
"django",
"eclipse",
"pydev",
"python"
] | stackoverflow_0004191284_django_eclipse_pydev_python.txt |
Q:
Python argparse: Is there a way to specify a range in nargs?
I have an optional argument that supports a list of arguments itself.
I mean, it should support:
-f 1 2
-f 1 2 3
but not:
-f 1
-f 1 2 3 4
Is there a way to force this within argparse ? Now I'm using nargs="*", and then checking the list length.
Ed... | Python argparse: Is there a way to specify a range in nargs? | I have an optional argument that supports a list of arguments itself.
I mean, it should support:
-f 1 2
-f 1 2 3
but not:
-f 1
-f 1 2 3 4
Is there a way to force this within argparse ? Now I'm using nargs="*", and then checking the list length.
Edit: As requested, what I needed is being able to define a range of... | [
"You could do this with a custom action:\nimport argparse\n\ndef required_length(nmin,nmax):\n class RequiredLength(argparse.Action):\n def __call__(self, parser, args, values, option_string=None):\n if not nmin<=len(values)<=nmax:\n msg='argument \"{f}\" requires between {nmin} ... | [
31
] | [] | [] | [
"argparse",
"python"
] | stackoverflow_0004194948_argparse_python.txt |
Q:
Replace part of string using python regular expression
I have the following lines (many, many):
...
gfnfgnfgnf: 5656756734
arvervfdsa: 1343453563
particular: 4685685685
erveveersd: 3453454545
verveversf: 7896789567
..
What I'd like to do is to find line 'particular' (whatever number is after ':')
and replace this ... | Replace part of string using python regular expression | I have the following lines (many, many):
...
gfnfgnfgnf: 5656756734
arvervfdsa: 1343453563
particular: 4685685685
erveveersd: 3453454545
verveversf: 7896789567
..
What I'd like to do is to find line 'particular' (whatever number is after ':')
and replace this number with '111222333'. How can I do that using python regu... | [
"for line in input:\n key, val = line.split(':')\n if key == 'particular':\n val = '111222333'\n\nI'm not sure regex would be of any value in this specific case. My guess is they'd be slower. That said, it can be done. Here's one way: \nfor line in input:\n re.sub('^particular : .*', 'particular : 11... | [
3,
3,
2,
0,
0,
0
] | [] | [] | [
"python",
"regex",
"replace"
] | stackoverflow_0004194534_python_regex_replace.txt |
Q:
"unknown column X.id" error in django using existing DB
I am trying to create a model for an existsing DB. Using the output of manage.py inspectdb, My models.py file looks like this:
from django.db import models
...some more stuff here...
class Scripts(models.Model):
run_site = models.ForeignKey(Sites, db_co... | "unknown column X.id" error in django using existing DB | I am trying to create a model for an existsing DB. Using the output of manage.py inspectdb, My models.py file looks like this:
from django.db import models
...some more stuff here...
class Scripts(models.Model):
run_site = models.ForeignKey(Sites, db_column='run_site')
script_name = models.CharField(max_lengt... | [
"There is always by default an implicit id field as auto incrementing primary key on every model. See primary_key in the Django docs how to change that field to some other name, but there needs to be one primary key (also in your table).\nAlso you may not want to call one of your fields super, since it is shadowing... | [
14,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0004192409_django_python.txt |
Q:
decoding problem with urllib2 in python
I'm trying to use urllib2 in python 2.7 to fetch a page from the web. The page happens to be encoded in unicode(UTF-8) and have greek characters. When I try to fetch and print it with the code below, I get gibberish instead of the greek characters.
import urllib2
print urlli... | decoding problem with urllib2 in python | I'm trying to use urllib2 in python 2.7 to fetch a page from the web. The page happens to be encoded in unicode(UTF-8) and have greek characters. When I try to fetch and print it with the code below, I get gibberish instead of the greek characters.
import urllib2
print urllib2.urlopen("http://www.pamestihima.gr").read(... | [
"\nUnicode is not UTF-8. UTF-8 is a string encoding, like ISO-8859-1, ASCII etc. \nAlways decode your data as soon as possible, to make real Unicode out of it. ('somestring in utf8'.decode('utf-8') == u'somestring in utf-8'), unicode objects are u'' , not ''\nWhen you have data leaving your app, always encode it in... | [
3,
1
] | [] | [] | [
"encoding",
"python",
"urllib2"
] | stackoverflow_0004195684_encoding_python_urllib2.txt |
Q:
Problems Installing lxml with python/django
I am trying to use lxml in one of my projects in django, but I am having trouble installing the lxml module. I am using Ubuntu 10.04. I have looked on the web for suitable tutorials on how to install the lxml module, but I never seem to understand it correctly. Would ... | Problems Installing lxml with python/django | I am trying to use lxml in one of my projects in django, but I am having trouble installing the lxml module. I am using Ubuntu 10.04. I have looked on the web for suitable tutorials on how to install the lxml module, but I never seem to understand it correctly. Would anyone be able to clearly tell me how to install ... | [
"apt-get install python-lxml\n\n"
] | [
3
] | [] | [] | [
"django",
"lxml",
"python"
] | stackoverflow_0004196167_django_lxml_python.txt |
Q:
How to deserialize 1GB of objects into Python faster than cPickle?
We've got a Python-based web server that unpickles a number of large data files on startup using cPickle. The data files (pickled using HIGHEST_PROTOCOL) are around 0.4 GB on disk and load into memory as about 1.2 GB of Python objects -- this takes... | How to deserialize 1GB of objects into Python faster than cPickle? | We've got a Python-based web server that unpickles a number of large data files on startup using cPickle. The data files (pickled using HIGHEST_PROTOCOL) are around 0.4 GB on disk and load into memory as about 1.2 GB of Python objects -- this takes about 20 seconds. We're using Python 2.6 on 64-bit Windows machines.
Th... | [
"\nTry the marshal module - it's internal (used by the byte-compiler) and intentionally not advertised much, but it is much faster. Note that it doesn't serialize arbitrary instances like pickle, only builtin types (don't remember the exact constraints, see docs). Also note that the format isn't stable.\nIf you n... | [
17,
7,
4,
3,
2,
2
] | [] | [] | [
"deserialization",
"pickle",
"python",
"serialization"
] | stackoverflow_0004195202_deserialization_pickle_python_serialization.txt |
Q:
Circular Reference with python lists
Can someone explain this?
>>> x = x[0] = [0]
>>> x
[[...]]
>>> x is x[0]
True
>>> x[0][0][0][0][0][0][0]
[[...]]
>>> x in x
True
what is [...]?
A:
That's just Python telling you that you have a circular reference; it's smart enough not to enter an infinite loop trying to pri... | Circular Reference with python lists | Can someone explain this?
>>> x = x[0] = [0]
>>> x
[[...]]
>>> x is x[0]
True
>>> x[0][0][0][0][0][0][0]
[[...]]
>>> x in x
True
what is [...]?
| [
"That's just Python telling you that you have a circular reference; it's smart enough not to enter an infinite loop trying to print it out.\n",
"iPython will do this:\n[<Recursion on list with id=38505216>]\nIt's the same thing; the interpreter telling you that you have a recursive data structure.\n",
"It's out... | [
15,
4,
3
] | [] | [] | [
"circular_reference",
"list",
"python"
] | stackoverflow_0004196329_circular_reference_list_python.txt |
Q:
Python app to django web app
I've written some python code to accomplish a task. Currently, there are 4-5 classes that I'm storing in separate files. I'd now like to change this whole thing into a database-backed web app. I've been reading tutorials on Django, and so far I get the impression that I'll need to manu... | Python app to django web app | I've written some python code to accomplish a task. Currently, there are 4-5 classes that I'm storing in separate files. I'd now like to change this whole thing into a database-backed web app. I've been reading tutorials on Django, and so far I get the impression that I'll need to manually specify the fields and their ... | [
"That is Django's ORM: it maps classes to tables. What else did you expect? There needs to be some way of specifying what the fields are, though, before you can use them, and that's managed through the models.Model class and the various models.Field subclasses. You can certainly use your classes as mixins in order ... | [
1,
0,
0
] | [] | [] | [
"django",
"django_models",
"python",
"web_applications"
] | stackoverflow_0004192339_django_django_models_python_web_applications.txt |
Q:
Tutorials on optimizing non-trivial Python applications with C extensions or Cython
The Python community has published helpful reference material showing how to profile Python code, and the technical details of Python extensions in C or in Cython. I am still searching for tutorials which show, however, for non-tri... | Tutorials on optimizing non-trivial Python applications with C extensions or Cython | The Python community has published helpful reference material showing how to profile Python code, and the technical details of Python extensions in C or in Cython. I am still searching for tutorials which show, however, for non-trivial Python programs, the following:
How to identify the hotspots which will benefit fro... | [
"Points 1 and 2 are just basic optimization rule of thumbs. I would be very astonished if there was anywhere the kind of tutorial you are looking for. Maybe that's why you haven't found one. My short list:\n\nrule number one of optimization is don't.\nrule number two measure\nrule number three identify the limiting... | [
9,
6,
4,
2
] | [] | [] | [
"c",
"cython",
"optimization",
"python",
"python_extensions"
] | stackoverflow_0004189328_c_cython_optimization_python_python_extensions.txt |
Q:
How to restrict dropdown in Django admin
class A(models.Model):
foreign = models.ForeignKey(B, unique=True)
I have the code above - how can I ensure that in the dropdown under A's Admin, for 'foreign', I am only presented with unique choices? This is just to prevent a user violating the uniqueness constraint ... | How to restrict dropdown in Django admin | class A(models.Model):
foreign = models.ForeignKey(B, unique=True)
I have the code above - how can I ensure that in the dropdown under A's Admin, for 'foreign', I am only presented with unique choices? This is just to prevent a user violating the uniqueness constraint and being presenting with the admin error mess... | [
"Please look at ModelAdmin.formfield_for_foreignkey() here. The downside is having to resort to raw SQL.\nclass AModelAdmin(admin.ModelAdmin):\ndef formfield_for_foreignkey(self, db_field, request, **kwargs):\n if db_field.name == \"foreign\":\n kwargs[\"queryset\"] = B.objects.raw('SELECT * FROM myapp_a ... | [
0
] | [] | [] | [
"django",
"django_admin",
"python"
] | stackoverflow_0004196673_django_django_admin_python.txt |
Q:
Where do two 2-D arrays begin to overlap each other?
I'm working with model output at the moment, and I can't seem to come up with a nice way of combining two arrays of data. Arrays A and B store different data, and the entries in each correspond to some spatial (x,y) point -- A holds some parameter, and B holds ... | Where do two 2-D arrays begin to overlap each other? | I'm working with model output at the moment, and I can't seem to come up with a nice way of combining two arrays of data. Arrays A and B store different data, and the entries in each correspond to some spatial (x,y) point -- A holds some parameter, and B holds model output. The problem is that B is a spatial subsecti... | [
"\nI have arrays associated with both A and B which store the (x,y) positions of the gridpoints for each.\n\nIn that case, the answer should be fairly simple...\nAre the two grids strictly on the same gridding scheme? Assuming they are, you can just do something like:\nnp.argwhere((Ax == Bx.min()) & (Ay == By.min()... | [
1,
0,
0
] | [] | [] | [
"multidimensional_array",
"numpy",
"overlap",
"python",
"subdomain"
] | stackoverflow_0004150909_multidimensional_array_numpy_overlap_python_subdomain.txt |
Q:
Python: Create a tuple from a command line input
I have a program which provides a command line input like this:
python2.6 prog.py -p a1 b1 c1
Now, we can have any number of input parameters i.e. -p a1 and -p a1 c1 b1 e2 are both possibilities.
I want to create a tuple based on the variable input parameters. Any s... | Python: Create a tuple from a command line input | I have a program which provides a command line input like this:
python2.6 prog.py -p a1 b1 c1
Now, we can have any number of input parameters i.e. -p a1 and -p a1 c1 b1 e2 are both possibilities.
I want to create a tuple based on the variable input parameters. Any suggestions on how to do this would be very helpful! A ... | [
"A tuple is fixed in length. Once you create a tuple, you can't modify it.\nThe command line arguments are stored in a list. \nimport sys\nt = tuple(sys.argv[1:]) # since sys.argv[0] is the name of the script\n\n",
"This should do it:\nimport sys\nt = tuple(sys.argv)\n\nSince maybe you don't want the script name,... | [
2,
1,
1,
1,
1,
1,
1,
1
] | [] | [] | [
"command",
"command_line_arguments",
"python",
"tuples"
] | stackoverflow_0004196389_command_command_line_arguments_python_tuples.txt |
Q:
'ascii' codec error in beautifulsoup
I am using beautifulsoup for scraping data from the html page. Till yesterday every thing was fine. But Now i am getting the error:
'ascii' codec can't encode character u'\xa9' in position 86700: ordinal not in range(128)
i am using the code:
import urllib2
from BeautifulSoup ... | 'ascii' codec error in beautifulsoup | I am using beautifulsoup for scraping data from the html page. Till yesterday every thing was fine. But Now i am getting the error:
'ascii' codec can't encode character u'\xa9' in position 86700: ordinal not in range(128)
i am using the code:
import urllib2
from BeautifulSoup import BeautifulSoup
page = urllib2.urlop... | [
"A wild guess:\nTry specifying the encoding of the page? \nsoup = BeautifulSoup(page, fromEncoding=<encoding of the page>)\n\nThis can also be a problem with the Python installation. If you print non-ASCII characters without BeautifulSoup, do you face the same problem? If yes, then you need to set the encoding:\nim... | [
2,
0
] | [] | [] | [
"beautifulsoup",
"python"
] | stackoverflow_0004197303_beautifulsoup_python.txt |
Q:
How do I use generic views in Django?
I am trying to use Django's generic views to make a user registration page. I have the following code in my app's urls.py
from django.conf.urls.defaults import *
from models import Ticket
urlpatterns = patterns('',
(r'^new/$', 'django.views.generic.create_update.create_ob... | How do I use generic views in Django? | I am trying to use Django's generic views to make a user registration page. I have the following code in my app's urls.py
from django.conf.urls.defaults import *
from models import Ticket
urlpatterns = patterns('',
(r'^new/$', 'django.views.generic.create_update.create_object', { 'model': User } ),
)
Now when I g... | [
"i don't think you need to create a view function. you need to provide a template (auth/user_form.html in this case, is also configurable) in your templates directory. The template needs to contain the necessary fields to create the new user object.\nsee the docs for this.\nans also check out this similar discussio... | [
1,
1
] | [] | [] | [
"django",
"django_templates",
"django_views",
"python"
] | stackoverflow_0004197221_django_django_templates_django_views_python.txt |
Q:
Pipe out of a command or script to another python script
I'm relatively to to python and I'm trying to write a python script to which one can pipe the output of a command or another script.
example command | python_sript.py
In python script I'll basically analyze the output of command and save it to file.
I thoug... | Pipe out of a command or script to another python script | I'm relatively to to python and I'm trying to write a python script to which one can pipe the output of a command or another script.
example command | python_sript.py
In python script I'll basically analyze the output of command and save it to file.
I thought I'll be able to do this with redirecting sys.stdin to subpr... | [
"On (old) Windows when you use pipes you need to call python scripts using python executable by default due to NT redirection bug:\nD:\\> echo \"test\" | python tee.py\n\nAfter that sys.stdin, raw_input(), fileinput.input() should work as expected.\n",
"You seem to be a bit unclear on how pipes work. They are han... | [
4,
1,
0
] | [] | [] | [
"pipe",
"python",
"windows"
] | stackoverflow_0004196969_pipe_python_windows.txt |
Q:
Using lxml & django/python - list index out of range
I have a small issue. I am trying to pull some data from my XML using lxml and I keep getting a "list index out of range" error, now I am trying to get the [0] position of my list, which should be the first one but it keeps giving me the error.
Here is a code ... | Using lxml & django/python - list index out of range | I have a small issue. I am trying to pull some data from my XML using lxml and I keep getting a "list index out of range" error, now I am trying to get the [0] position of my list, which should be the first one but it keeps giving me the error.
Here is a code snippet (thanks to MattH for helping me out):
req2 = urlli... | [
"With your XML document's structure being\n<projects>\n <projects>\n <id>\n ...\n </id>\n </project>\n</projects>\n\nyour XPath expression /project/id/text() surely won't match anything, and the accessing index 0 of the empty XPath result list of course results in an IndexError.\nInst... | [
3
] | [] | [] | [
"django",
"django_views",
"lxml",
"python"
] | stackoverflow_0004196770_django_django_views_lxml_python.txt |
Q:
To select a few columns in some tables related
I have these classes:
class Channel(rdb.Model):
rdb.metadata(metadata)
rdb.tablename("channels")
id = Column("id", Integer, primary_key=True)
title = Column("title", String(100))
items = relationship("MediaItem", secondary=channel_items, order_by... | To select a few columns in some tables related | I have these classes:
class Channel(rdb.Model):
rdb.metadata(metadata)
rdb.tablename("channels")
id = Column("id", Integer, primary_key=True)
title = Column("title", String(100))
items = relationship("MediaItem", secondary=channel_items, order_by="MediaItem.titleView", backref="channels")
class ... | [
"You can use the sqlalchemy expression builder through your well-defined models:\nsession.query(User.name, Channel.title, MediaItem.title)\\\n .join(Channel.users).join(MediaItem.channels)\n\nYou can look into this in the docs:\nhttp://www.sqlalchemy.org/docs/orm/query.html?highlight=join#sqlalchemy.orm.query.Quer... | [
0
] | [] | [] | [
"python",
"sqlalchemy"
] | stackoverflow_0003444652_python_sqlalchemy.txt |
Q:
how do I tell when a c++ program is waiting for input?
I'm trying to control a simple c++ program through python. The program works by prompting the user for input. The prompts are not necessarily endl terminated. What I would like to know is if there is a way to tell from python that the c++ program is no long... | how do I tell when a c++ program is waiting for input? | I'm trying to control a simple c++ program through python. The program works by prompting the user for input. The prompts are not necessarily endl terminated. What I would like to know is if there is a way to tell from python that the c++ program is no longer generating output and has switched to requesting input.
H... | [
"I'm not aware of a sufficiently general paradigm for detecting that the remote end is waiting for input. I can think of basic ways, but also of situations in which they will fail. Examples:\n\nRead with a non-blocking pipe/socket until no input arrives: the response might be interrupted by the process writing to d... | [
6,
3
] | [] | [] | [
"c++",
"cin",
"cout",
"python"
] | stackoverflow_0004197871_c++_cin_cout_python.txt |
Q:
Is it possible to access the internal elements of an embedded Flash object via a scripting language?
I would like to be able to access all the components of say a Flash image gallery on someone else's site. I want to be able to find the images, image coordinates, action script code, audio files, video, etc. I do n... | Is it possible to access the internal elements of an embedded Flash object via a scripting language? | I would like to be able to access all the components of say a Flash image gallery on someone else's site. I want to be able to find the images, image coordinates, action script code, audio files, video, etc. I do not want to manipulate these elements, I just want to view them and their related information.
Is this pos... | [
"No, not really. Not like you can examine the DOM of a webpage. You can download and decompile the swf, but you may or may not be able to get all the info you want out.\n",
"You can if (and only if) your application domain is the same. \n"
] | [
0,
0
] | [] | [] | [
"flash",
"javascript",
"python"
] | stackoverflow_0004198069_flash_javascript_python.txt |
Q:
How Can I limit bit number in the integer variable in Python?
I want to realize IDEA algorithm in Python. In Python we have no limits for variable size, but I need limit bit number in the integer number, for example, to do cyclic left shift. What do you advise?
A:
One way is to use the BitVector library.
Example... | How Can I limit bit number in the integer variable in Python? | I want to realize IDEA algorithm in Python. In Python we have no limits for variable size, but I need limit bit number in the integer number, for example, to do cyclic left shift. What do you advise?
| [
"One way is to use the BitVector library.\nExample of use:\n>>> from BitVector import BitVector\n>>> bv = BitVector(intVal = 0x13A5, size = 32)\n>>> print bv\n00000000000000000001001110100101\n>>> bv << 6 #does a cyclic left shift\n>>> print bv\n00000000000001001110100101000000\n>>> bv[0]... | [
3,
2,
2,
1
] | [] | [] | [
"algorithm",
"cryptography",
"python"
] | stackoverflow_0004197934_algorithm_cryptography_python.txt |
Q:
Python - Using "Google AJAX Search" API's Local Search Objects
I've just started using Google's search API to find addresses and the distances between those addresses. I used geopy for this, but, I often had the problem of not getting the correct addresses for my queries. I decided to experiment, therefore, with G... | Python - Using "Google AJAX Search" API's Local Search Objects | I've just started using Google's search API to find addresses and the distances between those addresses. I used geopy for this, but, I often had the problem of not getting the correct addresses for my queries. I decided to experiment, therefore, with Google's "Local Search" (http://code.google.com/apis/ajaxsearch/local... | [
"As the docs say,\n\nThe Google AJAX Search API is a\n Javascript library that allows you to\n embed Google Search in your web pages\n and other web applications. For Flash,\n and other Non-Javascript environments,\n the API exposes a raw RESTful\n interface that returns JSON encoded\n results that are easil... | [
2,
0
] | [] | [] | [
"geopy",
"google_api",
"json",
"python"
] | stackoverflow_0002799702_geopy_google_api_json_python.txt |
Q:
How can I convert a batch of Mavenized examples into a format that Eclipse understands?
I'm in the process of looking at taking some examples that are currently in one format (NOT Mavenized - actually in ANT form) and trying to find an automated way to munge them into something that Eclipse can comprehend. Though ... | How can I convert a batch of Mavenized examples into a format that Eclipse understands? | I'm in the process of looking at taking some examples that are currently in one format (NOT Mavenized - actually in ANT form) and trying to find an automated way to munge them into something that Eclipse can comprehend. Though I have several years of Java and other odd languages, doing this in Java sounds like using a ... | [
"\nHow can I convert a batch of Mavenized examples into a format that Eclipse understands?\n\nEclipse can understand Mavenized projects. You have two options:\n\nuse the Maven Eclipse Plugin (a Maven plugin) and run mvn eclipse:eclipse on a Mavenized example to generate the .project and .classpath and then import i... | [
5,
2,
0
] | [] | [] | [
"eclipse",
"maven",
"perl",
"python",
"ruby"
] | stackoverflow_0004159006_eclipse_maven_perl_python_ruby.txt |
Q:
there is a PYTHON wrapper for KONSOLE?
hi
i want to make a OmmWriter clone for my shell terminal.
in python with QT
there are some wrappers for Konsole, or something similar, or whatever?
some advice?
A:
You mean something like pyqonsole?
| there is a PYTHON wrapper for KONSOLE? | hi
i want to make a OmmWriter clone for my shell terminal.
in python with QT
there are some wrappers for Konsole, or something similar, or whatever?
some advice?
| [
"You mean something like pyqonsole?\n"
] | [
1
] | [] | [] | [
"console",
"python",
"qt"
] | stackoverflow_0004198266_console_python_qt.txt |
Q:
jquery.get not doing an xhr request on Firefox
I have just entered the world of jquery and am pretty new to javascript too. I have a small javascript snippet like below:-
<script type="text/javascript">
$(function(){
$('a').click(function(event){
event.preventDefault();
$.get('/_add_navigation... | jquery.get not doing an xhr request on Firefox | I have just entered the world of jquery and am pretty new to javascript too. I have a small javascript snippet like below:-
<script type="text/javascript">
$(function(){
$('a').click(function(event){
event.preventDefault();
$.get('/_add_navigation_',function(response){
$('#themaincontents')... | [
"Not all browsers send the same headers, and you cannot rely on them to be consistent across browsers. The easiest way is to not rely on the browser to send something, but manually send something yourself:\n$.get('url', {\n xhr: 'yes' // add this extra parameter here\n}, function(){\n\n});\n\nthen check for that... | [
0
] | [] | [] | [
"firefox",
"jquery",
"python",
"xmlhttprequest"
] | stackoverflow_0004198537_firefox_jquery_python_xmlhttprequest.txt |
Q:
batch script or python program to edit string in xml tags
I am looking to write a program that searches for the tags in an xml document and changes the string between the tags from localhost to manager. The tag might appear in the xml document multiple times, and the document does have a definite path. Would pyth... | batch script or python program to edit string in xml tags | I am looking to write a program that searches for the tags in an xml document and changes the string between the tags from localhost to manager. The tag might appear in the xml document multiple times, and the document does have a definite path. Would python or vbscript make the most sense for this problem? And can an... | [
"If it's a simple thing, like changing a few strings here and there, you might be able to do everything with a python regexp, check here:\n\nhttp://docs.python.org/library/re.html\n\nFor everything more complex, I would suggest using something like Beautiful Soup:\n\nhttp://www.crummy.com/software/BeautifulSoup/doc... | [
1,
1
] | [] | [] | [
"batch_file",
"python",
"string",
"xml"
] | stackoverflow_0004199081_batch_file_python_string_xml.txt |
Q:
I am not able to parse using Beautiful Soup
<td>
<a name="corner"></a>
<div>
<div style="aaaaa">
<div class="class-a">My name is alis</div>
</div>
<div>
<span><span class="class-b " title="My title"><span>Very Good</span></span> </span>
<b>My Description</b><br />
My Name is Alis I am a python learner...... | I am not able to parse using Beautiful Soup | <td>
<a name="corner"></a>
<div>
<div style="aaaaa">
<div class="class-a">My name is alis</div>
</div>
<div>
<span><span class="class-b " title="My title"><span>Very Good</span></span> </span>
<b>My Description</b><br />
My Name is Alis I am a python learner...
</div>
<div class="class-3" style="style... | [
"from BeautifulSoup import BeautifulSoup\nsoup = BeautifulSoup(\"Your sample html here\")\nsoup.td.div('div')[2].contents[-1]\n\nThis will return the string you are looking for (the unicode string, with any applicable whitespace, it should be noted).\nThis works by parsing the html, grabbing the first td tag and it... | [
1,
0
] | [] | [] | [
"beautifulsoup",
"python"
] | stackoverflow_0004198819_beautifulsoup_python.txt |
Q:
Django + Google App Engine, problem updating existent entry
I am having trouble with updating saved instance in datastore.
My form has two fields — title (optional) and content.
What I want to do is to set title field value to Post # id_of_just_created_post.
So I am checking form.instance.title is None and then wa... | Django + Google App Engine, problem updating existent entry | I am having trouble with updating saved instance in datastore.
My form has two fields — title (optional) and content.
What I want to do is to set title field value to Post # id_of_just_created_post.
So I am checking form.instance.title is None and then want to update this instance's title:
…
form.save()
id = form.insta... | [
"Try this:\ninst = form.save()\n\nif not inst.title:\n inst.title = \"Post # %s\" % inst.pk\n inst.save()\n\n"
] | [
1
] | [] | [] | [
"django",
"google_app_engine",
"python"
] | stackoverflow_0004199249_django_google_app_engine_python.txt |
Q:
PIL: Create one-dimensional histogram of image color lightness?
I've been working on a script, and I need it to basically:
Make the image greyscale (or bitonal, I will play with both to see which one works better).
Process each individual column and create a net intensity value for each column.
Spit the results i... | PIL: Create one-dimensional histogram of image color lightness? | I've been working on a script, and I need it to basically:
Make the image greyscale (or bitonal, I will play with both to see which one works better).
Process each individual column and create a net intensity value for each column.
Spit the results into an ordered list.
There is a really easy way to do this with Imag... | [
"I see you are using numpy. I would convert the greyscale image to a numpy array first, then use numpy to sum along an axis. Bonus: You'll probably find your smoothing function runs a lot faster when you fix it to accept an 1D array as input.\n>>> from PIL import Image\n>>> import numpy as np\n>>> i = Image.open(... | [
11,
7
] | [] | [] | [
"image_processing",
"python",
"python_imaging_library",
"scanning"
] | stackoverflow_0004188104_image_processing_python_python_imaging_library_scanning.txt |
Q:
too many threads due to synch communication
I'm using threads and xmlrpclib in python at the same time. Periodically, I create a bunch of thread to complete a service on a remote server via xmlrpclib. The problem is that, there are times that the remote server doesn't answer. This causes the thread to wait forever... | too many threads due to synch communication | I'm using threads and xmlrpclib in python at the same time. Periodically, I create a bunch of thread to complete a service on a remote server via xmlrpclib. The problem is that, there are times that the remote server doesn't answer. This causes the thread to wait forever for a response which it never gets. Over time, n... | [
"You are doing what I usually call (originally in Spanish xD) \"happy road programming\". You should implement your programs to handle undesired cases, not only the ones you want to happen.\nThe threads here are only showing an underlying mistake: your server can't handle a timeout, and the implementation is rigid ... | [
1,
0
] | [] | [] | [
"multithreading",
"python",
"xml_rpc"
] | stackoverflow_0002806397_multithreading_python_xml_rpc.txt |
Q:
Django + Eclipse, shell issues
I'm using pydev to use Django in Eclipse. I'm following the tutorial here (http://docs.djangoproject.com/en/dev/intro/tutorial01/), making a simple poll application. In the example when they run the shell they are able to do this:
from polls.models import Poll, Choice
however, for... | Django + Eclipse, shell issues | I'm using pydev to use Django in Eclipse. I'm following the tutorial here (http://docs.djangoproject.com/en/dev/intro/tutorial01/), making a simple poll application. In the example when they run the shell they are able to do this:
from polls.models import Poll, Choice
however, for some reason, I'm not able to do thi... | [
"I'm assuming that you're using PyDev. See how your PYTHONPATH is structured...\n(right click on your project in package explorer > properties > Pydev - PYTHONPATH.\nIf your project is set up as\nproject_root/\n+-projectname/\n +-polls/\n +-models.py\n\nand if your PYTHONPATH points to project_root, then you'll... | [
5
] | [] | [] | [
"django",
"eclipse",
"pydev",
"python"
] | stackoverflow_0004196887_django_eclipse_pydev_python.txt |
Q:
Python: String formatting a regex string that uses both '%' and '{' as characters
I have the following regular expression, which lets me parse percentages like '20%+', '20%', or '20% - 50%' using re.split.
'([0-9]{1,3}[%])([+-]?)'
I want to use string formatting to pass the series identifiers (i.e. '+-') as an ar... | Python: String formatting a regex string that uses both '%' and '{' as characters | I have the following regular expression, which lets me parse percentages like '20%+', '20%', or '20% - 50%' using re.split.
'([0-9]{1,3}[%])([+-]?)'
I want to use string formatting to pass the series identifiers (i.e. '+-') as an argument from config.py.
SERIES = '+-'
The two methods I've tried produced errors. New-s... | [
"You can use %% to insert a percent-sign using the old-style formatting:\n'([0-9]{1,3}[%%])([%s]?)' % (config.SERIES)\n\nSimilarly for the new-style formatting, double the braces:\n'([0-9]{{1,3}}[%])([{0}]?)'.format(config.SERIES)\n\n"
] | [
12
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0004199642_python_regex.txt |
Q:
Image.frombuffer with 16-bit image data
If my windows is in 32-bit color depth mode, then the following code gets a nice PIL Image from a window:
def image_grab_native(window):
hwnd = win32gui.GetDesktopWindow()
left, top, right, bot = get_rect(window)
w = right - left
h = bot - top
hwndDC = ... | Image.frombuffer with 16-bit image data | If my windows is in 32-bit color depth mode, then the following code gets a nice PIL Image from a window:
def image_grab_native(window):
hwnd = win32gui.GetDesktopWindow()
left, top, right, bot = get_rect(window)
w = right - left
h = bot - top
hwndDC = win32gui.GetWindowDC(hwnd)
mfcDC = win32... | [
"For the stride parameter, you need to give the row size in bytes. Your pixels are 16 bits each so you might naively assume stride = 2*bmpinfo['bmWidth']; unfortunately Windows adds padding to make the stride an even multiple of 32 bits. That means you'll have to round it to the next highest multiple of 4: stride =... | [
2
] | [] | [] | [
"python",
"python_imaging_library",
"screenshot",
"winapi",
"windows"
] | stackoverflow_0004199497_python_python_imaging_library_screenshot_winapi_windows.txt |
Q:
Selecting indices for a 2d array in numpy
This works quite well in 1 dimension:
# This will sort bar by the order of the values in foo
(Pdb) bar = np.array([1,2,3])
(Pdb) foo = np.array([5,4,6])
(Pdb) bar[np.argsort(foo)]
array([2, 1, 3])
But how do I do that in two dimensions? Argsort works nicely, but the sele... | Selecting indices for a 2d array in numpy | This works quite well in 1 dimension:
# This will sort bar by the order of the values in foo
(Pdb) bar = np.array([1,2,3])
(Pdb) foo = np.array([5,4,6])
(Pdb) bar[np.argsort(foo)]
array([2, 1, 3])
But how do I do that in two dimensions? Argsort works nicely, but the select no longer works:
(Pdb) foo = np.array([[5,4,... | [
"You want\nbar[[[0],[1]], np.argsort(foo)]\n\nThis is because you need two indices to index bar. The [[0], [1]] is to get correct broadcasting. See this post on numpy-discussion mailing list for exactly the same question and the answer.\n",
"A nice generic solution (with n rows to sort) is offered at this post,... | [
2,
1,
0
] | [] | [] | [
"numpy",
"python"
] | stackoverflow_0002016842_numpy_python.txt |
Q:
In python sockets will a output buffer solve my resource error?
i keep getting this error uncaptured python exception, closing channel <main.Handler connected 94.173.149.187:51162 at 0x2ac3dbeb48c0> (socket.error:(11, 'Resource temporarily unavailable').
I read that is problem is caused because im trying to send d... | In python sockets will a output buffer solve my resource error? | i keep getting this error uncaptured python exception, closing channel <main.Handler connected 94.173.149.187:51162 at 0x2ac3dbeb48c0> (socket.error:(11, 'Resource temporarily unavailable').
I read that is problem is caused because im trying to send data whilst data is still sending. First is this true ? it sounds poss... | [
"you can fix this problem by doing :\nsocket.setblocking(0)\n\nsee the doc for why , hope this can help :)\n"
] | [
1
] | [] | [] | [
"buffer",
"python",
"sockets"
] | stackoverflow_0004199707_buffer_python_sockets.txt |
Q:
python: how to get a subset of dict
I have a dict that has many elements, I want to write a function that can return the elements in the given index range(treat dict as array):
get_range(dict, begin, end):
return {a new dict for all the indexes between begin and end}
How that can be done?
EDIT: I am not askin... | python: how to get a subset of dict | I have a dict that has many elements, I want to write a function that can return the elements in the given index range(treat dict as array):
get_range(dict, begin, end):
return {a new dict for all the indexes between begin and end}
How that can be done?
EDIT: I am not asking using key filter... eg)
{"a":"b", "c":"... | [
"Edit: A dictionary is not ordered. It is impossible to make get_range return the same slice whenever you have modified the dictionary. If you need deterministic result, replace your dict with a collections.OrderedDict.\nAnyway, you could get a slice using itertools.islice:\nimport itertools\ndef get_range(diction... | [
17,
3,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0004194365_python.txt |
Q:
Adding custom header on serving static files with Apache
Is it possible to send additional custom headers (for example with a wsgi app) before Apache serves static content (image/js/css) ?
A:
Use the Apache mod_headers module.
http://httpd.apache.org/docs/2.2/mod/mod_headers.html
No way of doing it using mod_wsg... | Adding custom header on serving static files with Apache | Is it possible to send additional custom headers (for example with a wsgi app) before Apache serves static content (image/js/css) ?
| [
"Use the Apache mod_headers module.\nhttp://httpd.apache.org/docs/2.2/mod/mod_headers.html\nNo way of doing it using mod_wsgi.\nYou could do it with mod_python if you really had to, but better off trying to do it with builtin Apache modules.\n"
] | [
3
] | [] | [] | [
"apache",
"mod_wsgi",
"python",
"wsgi"
] | stackoverflow_0004192842_apache_mod_wsgi_python_wsgi.txt |
Q:
Forcing immutability on an object
Before I start, I'm already aware that object immutability in Python is often a bad idea, however, I believe that in my case it would be appropriate.
Let's say I'm working with a coordinate system in my code, such that each coordinate uses a struct of X, Y, Z. I've already overloa... | Forcing immutability on an object | Before I start, I'm already aware that object immutability in Python is often a bad idea, however, I believe that in my case it would be appropriate.
Let's say I'm working with a coordinate system in my code, such that each coordinate uses a struct of X, Y, Z. I've already overloaded subtraction, addition, etc. methods... | [
"In conjunction with katrielalex's suggestion, making the Point a named tuple would be good as well. Here I've just replaced the tuple parent with namedtuple('Point', 'x y z') - and that's enough for it to work.\n>>> from collections import namedtuple\n>>> class Point(namedtuple('Point', 'x y z')):\n... def __a... | [
4,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0004200221_python.txt |
Q:
Beginner Python question about making a web app
I am completely new to Python-- never used it before today. I am interested in devloping Python applications for the web. I would like to check to see if my web server supports WSGI or running python apps in some way.
Let's say I have a .py file that prints "Hello ... | Beginner Python question about making a web app | I am completely new to Python-- never used it before today. I am interested in devloping Python applications for the web. I would like to check to see if my web server supports WSGI or running python apps in some way.
Let's say I have a .py file that prints "Hello world!". How can I test to see if my server supports... | [
"A very basic WSGI application can look as follows:\ndef application(environ, start_response):\n start_response('200 OK', [('content-type', 'text/html')])\n return ['Hello world!']\n\nUnfortunately, if you put this into helloworld.py on the server and then browse to URL/helloworld.py you will most likely see ... | [
5,
3
] | [] | [] | [
"python",
"wsgi"
] | stackoverflow_0004199442_python_wsgi.txt |
Q:
Creating form from Django user model
I am trying to build a form for registering a user - using Django's built in user model and using generic views. I can't figure out how to confirm a password.
<form action="." method="post">
{% csrf_token %}
{{ form.non_field_errors }}
<p>
{{ form.username.errors ... | Creating form from Django user model | I am trying to build a form for registering a user - using Django's built in user model and using generic views. I can't figure out how to confirm a password.
<form action="." method="post">
{% csrf_token %}
{{ form.non_field_errors }}
<p>
{{ form.username.errors }}
<label for="username">Username<... | [
"Give a try to django-registration to register users. It is a very complete, reusable app for that purpose. I use it and I'm quite happy with it.\nhttp://bitbucket.org/ubernostrum/django-registration\nYou have the full sources to check how it solves the password confirmation issue, etc.\nThis may not directly answe... | [
1,
1
] | [] | [] | [
"django",
"django_models",
"django_templates",
"python"
] | stackoverflow_0004199551_django_django_models_django_templates_python.txt |
Q:
In python 2.x should I call object.__del__?
In Python 3.x all classes are subclasses of object. In 2.x you have to explicitly state class MyClass(object). And, as I'm trying to write as much 3.x compatible code as possible, I'm subclassing object.
In my program, I'm using the __del__ method, and I wanted to know ... | In python 2.x should I call object.__del__? | In Python 3.x all classes are subclasses of object. In 2.x you have to explicitly state class MyClass(object). And, as I'm trying to write as much 3.x compatible code as possible, I'm subclassing object.
In my program, I'm using the __del__ method, and I wanted to know if I should be calling object.__del__(self), or i... | [
"__del__ isn't meant to be called. Destructors are executed automatically when the object has no more references and is collected. \nInversely, you don't call __init__, but is taken care of automatically on object creation. Calling __del__ won't destruct the object and doing so may actually lead to unexpected be... | [
4,
4,
2
] | [] | [] | [
"destructor",
"python",
"python_2.x",
"subclass"
] | stackoverflow_0004199653_destructor_python_python_2.x_subclass.txt |
Q:
Python and hashlib module
I've just installed Python 2.6.6 from sources and what I get:
>>> import hashlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/hashlib.py", line 136, in <module>
md5 = __get_builtin_constructor('md5')
File "/usr/local/lib/p... | Python and hashlib module | I've just installed Python 2.6.6 from sources and what I get:
>>> import hashlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/hashlib.py", line 136, in <module>
md5 = __get_builtin_constructor('md5')
File "/usr/local/lib/python2.6/hashlib.py", line 63, ... | [
"Install openssl-dev and rebuild.\n",
"I have just tested this on my 2.6.6 installation and I have had no such problem. You might want to try reinstalling. Also, I am not sure if the hashlib module can be installed separately, but you may want to try that as well.\nAlso, can you try importing specific functions f... | [
7,
0,
0
] | [] | [] | [
"hashlib",
"python"
] | stackoverflow_0004200292_hashlib_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.