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:
Execute (part of) try block after except block
I know that is a weird question, and probably there is not an answer.
I'm trying to execute the rest of the try block after an exception was caught and the except block was executed.
Example:
[...]
try:
do.this()
do.that()
[...]
except:
foo.bar()
[...]
do.this() ... | Execute (part of) try block after except block | I know that is a weird question, and probably there is not an answer.
I'm trying to execute the rest of the try block after an exception was caught and the except block was executed.
Example:
[...]
try:
do.this()
do.that()
[...]
except:
foo.bar()
[...]
do.this() raise an exception managed by foo.bar(), then I woul... | [
"A try... except... block catches one exception. That's what it's for. It executes the code inside the try, and if an exception is raised, handles it in the except. You can't raise multiple exceptions inside the try.\nThis is deliberate: the point of the construction is that you need explicitly to handle the except... | [
5,
2,
1,
1,
1,
0,
0,
0
] | [] | [] | [
"exception_handling",
"python"
] | stackoverflow_0004225921_exception_handling_python.txt |
Q:
PDF programming in Python:Set limits on number of times the PDF can be printed
PDF allows you to set permissions such as a document can be printed just once or just 10 times etc. I believe Adobe Acrobat Professional allows you to set those.
My question is it possible to do so in Python programmatically? If so how?... | PDF programming in Python:Set limits on number of times the PDF can be printed | PDF allows you to set permissions such as a document can be printed just once or just 10 times etc. I believe Adobe Acrobat Professional allows you to set those.
My question is it possible to do so in Python programmatically? If so how?
| [
"There doesn't seem to be a way to restrict the number of times a PDF file can be printed (outside Adobe LiveCycle or some other very controlled hosted solution). Although there is lots of discussion about this e.g. https://superuser.com/questions/37216/restrict-print-copies-on-a-pdf\nIf you have other info please... | [
1,
0
] | [] | [] | [
"pdf",
"pdf_generation",
"python"
] | stackoverflow_0004226942_pdf_pdf_generation_python.txt |
Q:
Atomic state storage in Python?
I'm working on a project on an unreliable system which I'm assuming can fail at any point. What I want to guarantee is that if I write_state and the machine fails mid-operation, a read_state will either read a valid state or no state at all. I've implemented something which I think ... | Atomic state storage in Python? | I'm working on a project on an unreliable system which I'm assuming can fail at any point. What I want to guarantee is that if I write_state and the machine fails mid-operation, a read_state will either read a valid state or no state at all. I've implemented something which I think will work below -- I'm interested in ... | [
"Your two copies won't work. The filesystem can reorder things so that both files have been truncated before any has been written to disk.\nThere are a few filesystem operations that are guaranteed to be atomic: renaming a file over another is one, insofar as the file will either be in one place or another. However... | [
3,
2,
1,
1,
0
] | [] | [] | [
"atomic",
"persistence",
"python",
"state"
] | stackoverflow_0004220803_atomic_persistence_python_state.txt |
Q:
mod-wsgi segmentation fault under debian/apache2
I'm trying to get mod-wsgi running under Apache2 with an eye towards using it with Django.
Right now I'm just getting a basic app running and am getting a segmentation fault. Any suggestions on how to track down the error would be appreciated, I'm stuck.
This is un... | mod-wsgi segmentation fault under debian/apache2 | I'm trying to get mod-wsgi running under Apache2 with an eye towards using it with Django.
Right now I'm just getting a basic app running and am getting a segmentation fault. Any suggestions on how to track down the error would be appreciated, I'm stuck.
This is under Debian/Lenny, stock versions of Apache, mod-wsgi, ... | [
"Read through mod_wsgi documentation looking for where it discusses crashes. Start with:\nhttp://code.google.com/p/modwsgi/wiki/FrequentlyAskedQuestions\nhttp://code.google.com/p/modwsgi/wiki/InstallationIssues\nLikely a clash with mod_python or due to wrong Python installation being found at run time.\nFor later, ... | [
2
] | [] | [] | [
"apache2",
"mod_wsgi",
"python"
] | stackoverflow_0004226521_apache2_mod_wsgi_python.txt |
Q:
How to programmatically edit Excel sheets?
I need to edit an Excel workbook using python. Is there a way of doing this without reading in the workbook, editing what I want and the writing it back? i.e. is there a way I can do this on the fly, as I only need to edit a couple of values per sheet?
I have looked at py... | How to programmatically edit Excel sheets? | I need to edit an Excel workbook using python. Is there a way of doing this without reading in the workbook, editing what I want and the writing it back? i.e. is there a way I can do this on the fly, as I only need to edit a couple of values per sheet?
I have looked at pyexcelerator, xlrd, and xlwt, but they only seem ... | [
"First off, what version of Excel? Excel2007+ use an XML file format, while Excel2003- used a proprietary binary format... so the tools to read and write these work in totally different ways. \nIf you're after the more recent xlsx files, then take a look at Eric' Gazoni's openpyxl project. The code can be found on ... | [
9,
2,
0
] | [] | [] | [
"editing",
"excel",
"linux",
"python"
] | stackoverflow_0004226754_editing_excel_linux_python.txt |
Q:
Fast way to read interleaved data?
I've got a file containing several channels of data. The file is sampled at a base rate, and each channel is sampled at that base rate divided by some number -- it seems to always be a power of 2, though I don't think that's important.
So, if I have channels a, b, and c, sampled ... | Fast way to read interleaved data? | I've got a file containing several channels of data. The file is sampled at a base rate, and each channel is sampled at that base rate divided by some number -- it seems to always be a power of 2, though I don't think that's important.
So, if I have channels a, b, and c, sampled at divders of 1, 2, and 4, my stream wil... | [
"The best way to really improve the performance is to get rid of the Python loop over all samples and let NumPy do this loop in compiled C code. This is a bit tricky to achieve, but it is possible.\nFirst, you need a bit of preparation. As pointed out by Justin Peel, the pattern in which the samples are arranged ... | [
7,
2,
1
] | [] | [] | [
"binary_data",
"numpy",
"optimization",
"python"
] | stackoverflow_0004227990_binary_data_numpy_optimization_python.txt |
Q:
Issue with reversing list using list.pop()
I was working on writing a small code snippet to reverse a string using list appends and pop.
The script that I wrote is as follows:
someStr = raw_input("Enter some string here:")
strList = []
for c in someStr:
strList.append(c)
print strList
reverseCharList = []
f... | Issue with reversing list using list.pop() | I was working on writing a small code snippet to reverse a string using list appends and pop.
The script that I wrote is as follows:
someStr = raw_input("Enter some string here:")
strList = []
for c in someStr:
strList.append(c)
print strList
reverseCharList = []
for someChar in strList:
reverseCharList.appe... | [
"How about a simple reversal of string.\n>>> x = 'abcd'\n>>> x[::-1]\n'dcba'\n>>> \n\nOn your code:\n\nNever mutate the list on which you are iterating with. It can cause subtle errors.\n\n>>> strList = [1, 2, 3, 4, 5]\n>>> reverseCharList = []\n>>> for someChar in strList:\n... print strList\n... reverseCh... | [
5,
5,
1,
1
] | [] | [] | [
"loops",
"python",
"reverse",
"stack"
] | stackoverflow_0004228805_loops_python_reverse_stack.txt |
Q:
Child process detecting the parent process' death in Python
Is there a way for a child process in Python to detect if the parent process has died?
A:
If your Python process is running under Linux, and the prctl() system call is exposed, you can use the answer here.
This can cause a signal to be sent to the child... | Child process detecting the parent process' death in Python | Is there a way for a child process in Python to detect if the parent process has died?
| [
"If your Python process is running under Linux, and the prctl() system call is exposed, you can use the answer here.\nThis can cause a signal to be sent to the child when the parent process dies.\n",
"Assuming the parent is alive when you start to do this, you can check whether it is still alive in a busy loop as... | [
5,
4,
2,
1
] | [] | [] | [
"python",
"subprocess"
] | stackoverflow_0000759443_python_subprocess.txt |
Q:
What is the difference between using decorators and extending a sub class by inheritance?
I was trying to wrap my brain around Decorators in python but can't understand why we cannot achieve the same thing by using sub classes?
A:
You can achieve the same thing using subclasses, and in fact you don't even need s... | What is the difference between using decorators and extending a sub class by inheritance? | I was trying to wrap my brain around Decorators in python but can't understand why we cannot achieve the same thing by using sub classes?
| [
"You can achieve the same thing using subclasses, and in fact you don't even need subclasses - you can also achieve the same thing simply by wrapping a method in another method and reassigning it. There was a lot of discussion about whether or not the decorator syntax should be added to the language as it doesn't a... | [
4,
1
] | [] | [] | [
"decorator",
"python"
] | stackoverflow_0004229287_decorator_python.txt |
Q:
Python (with Django) and PHP
Just wondering, as I think about learning either PHP or Django (I have previous Python knowledge), what advantages do Python and Django have over PHP, what disadvantages etc.
I don't want to know which one is better, surely neither is better, both have their good sides as well as bad s... | Python (with Django) and PHP | Just wondering, as I think about learning either PHP or Django (I have previous Python knowledge), what advantages do Python and Django have over PHP, what disadvantages etc.
I don't want to know which one is better, surely neither is better, both have their good sides as well as bad sides and I will probably learn bot... | [
"\nPHP is a popular language for web development with tons of libraries and examples online.\nPython is a modern, well-design programming language where everything is an object. It works well in many environments, including web programming, although it wasn't originally designed for that environment.\n\nIf you want... | [
4
] | [] | [] | [
"django",
"php",
"python"
] | stackoverflow_0004229394_django_php_python.txt |
Q:
python and process
What is the best way in python find the process name and owner?
Now i use WMI, but this version is too slow.
A:
By using https://github.com/giampaolo/psutil:
>>> import psutil, os
>>> p = psutil.Process(os.getpid())
>>> p.name()
'python.exe'
>>> p.username()
'giampaolo'
>>>
A:
Process name:... | python and process | What is the best way in python find the process name and owner?
Now i use WMI, but this version is too slow.
| [
"By using https://github.com/giampaolo/psutil:\n>>> import psutil, os\n>>> p = psutil.Process(os.getpid())\n>>> p.name()\n'python.exe'\n>>> p.username()\n'giampaolo'\n>>> \n\n",
"Process name: is sys.argv[0] not sufficient for your purposes?\n"
] | [
1,
0
] | [] | [] | [
"python",
"windows",
"wmi"
] | stackoverflow_0002299627_python_windows_wmi.txt |
Q:
Pausing a process in Windows
I'm making a nice little Python GUI frontend for ffmpeg on Windows (one that is specifically designed to convert videos to an iPhone-friendly format and automatically import it to iTunes and tag it), and I want it to work so that you can pause the process and resume it if you want.
Sin... | Pausing a process in Windows | I'm making a nice little Python GUI frontend for ffmpeg on Windows (one that is specifically designed to convert videos to an iPhone-friendly format and automatically import it to iTunes and tag it), and I want it to work so that you can pause the process and resume it if you want.
Since I start ffmpeg as a separate pr... | [
"You can easily do this by using psutil ( https://github.com/giampaolo/psutil ):\nimport psutil\npid = 1034 # replace this with the pid of your process\np = psutil.Process(pid)\np.suspend()\n\n...to resume it:\np.resume()\n\nInternally this is implemented in C by using SuspendThread() and ResumeThread() Windows sy... | [
6
] | [] | [] | [
"python",
"windows"
] | stackoverflow_0001892356_python_windows.txt |
Q:
Monitor Process in Python?
I think this is a pretty basic question, but here it is anyway.
I need to write a python script that checks to make sure a process, say notepad.exe, is running. If the process is running, do nothing. If it is not, start it. How would this be done.
I am using Python 2.6 on Windows XP
A:
... | Monitor Process in Python? | I think this is a pretty basic question, but here it is anyway.
I need to write a python script that checks to make sure a process, say notepad.exe, is running. If the process is running, do nothing. If it is not, start it. How would this be done.
I am using Python 2.6 on Windows XP
| [
"The process creation functions of the os module are apparently deprecated in Python 2.6 and later, with the subprocess module being the module of choice now, so...\nif 'notepad.exe' not in subprocess.Popen('tasklist', stdout=subprocess.PIPE).communicate()[0]:\n subprocess.Popen('notepad.exe')\n\nNote that in Py... | [
15,
4,
3
] | [] | [] | [
"monitor",
"process",
"python",
"restart"
] | stackoverflow_0003215262_monitor_process_python_restart.txt |
Q:
Stuck in SQLAlchemy and Object Rlational
I'm just working on a simple database of an address book for learning sqlalchemy. This is the code under the 'tables.py' file (that is pretty like one in the tutorial!):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sqlalchemy import Column, Integer, String, create_en... | Stuck in SQLAlchemy and Object Rlational | I'm just working on a simple database of an address book for learning sqlalchemy. This is the code under the 'tables.py' file (that is pretty like one in the tutorial!):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sqlalchemy import Column, Integer, String, create_engine, ForeignKey
from sqlalchemy.ext.declarati... | [
"Please correct me if I'm wrong but the error is saying there is no detailT instance, and looking at the code I can't see anywhere where the detailT class is instantiated. It looks to me that since detailT is the parent of of nameT via the relationship you can't save nameT without its parent. I would start here.\n"... | [
1,
0
] | [] | [] | [
"python",
"sqlalchemy"
] | stackoverflow_0004225483_python_sqlalchemy.txt |
Q:
Is there a Python equivalent of Groovy/Grails for Java
I'm thinking of something like Jython/Jango? Does this exist? Or does Jython allow you to do everything-Python in Java including Django (I'm not sure how Jython differs from Python)?
A:
http://wiki.python.org/jython/DjangoOnJython
A:
"I'm not sure how Jyth... | Is there a Python equivalent of Groovy/Grails for Java | I'm thinking of something like Jython/Jango? Does this exist? Or does Jython allow you to do everything-Python in Java including Django (I'm not sure how Jython differs from Python)?
| [
"http://wiki.python.org/jython/DjangoOnJython\n",
"\"I'm not sure how Jython differs from Python\"\nhttp://www.jython.org/Project/\n\nJython is an implementation of the\n high-level, dynamic, object-oriented\n language Python seamlessly integrated\n with the Java platform.\n\nhttp://docs.python.org/reference/i... | [
8,
3,
2
] | [] | [] | [
"django",
"grails",
"groovy",
"jython",
"python"
] | stackoverflow_0000524147_django_grails_groovy_jython_python.txt |
Q:
Reading Command Line Arguments of Another Process (Win32 C code)
I need to be able to list the command line arguments (if any) passed to other running processes. I have the PIDs already of the running processes on the system, so basically I need to determine the arguments passed to process with given PID XXX.
I'm... | Reading Command Line Arguments of Another Process (Win32 C code) | I need to be able to list the command line arguments (if any) passed to other running processes. I have the PIDs already of the running processes on the system, so basically I need to determine the arguments passed to process with given PID XXX.
I'm working on a core piece of a Python module for managing processes. Th... | [
"To answer my own question, I finally found a CodeProject solution that does exactly what I'm looking for:\nhttp://www.codeproject.com/KB/threads/GetNtProcessInfo.aspx\nAs @Reuben already pointed out, you can use NtQueryProcessInformation to retrieve this information. Unfortuantely it's not a recommended approach, ... | [
6,
5,
3,
2,
0
] | [] | [] | [
"c",
"python",
"winapi"
] | stackoverflow_0000440932_c_python_winapi.txt |
Q:
Number formatting in python
How can I make this python code:
# -*- coding: cp1252 -*-
a=4
b=2
c=1.0
d=1.456
print '%fx³ + %fx² + %fx + %f = 0' %(a,b,c,d)
print like this:
4x³ + 2x² + 1x + 1.456 = 0
instead of like this (how it prints currently):
4.000000x³ + 2.000000x² + 1.0000000x + 1.456000 = 0
A:
print '%gx... | Number formatting in python | How can I make this python code:
# -*- coding: cp1252 -*-
a=4
b=2
c=1.0
d=1.456
print '%fx³ + %fx² + %fx + %f = 0' %(a,b,c,d)
print like this:
4x³ + 2x² + 1x + 1.456 = 0
instead of like this (how it prints currently):
4.000000x³ + 2.000000x² + 1.0000000x + 1.456000 = 0
| [
"print '%gx³ + %gx² + %gx + %g = 0' %(a,b,c,d)\n\n",
"Use this > Python Decimals format\n"
] | [
4,
2
] | [] | [] | [
"formatting",
"number_formatting",
"python"
] | stackoverflow_0004229767_formatting_number_formatting_python.txt |
Q:
What is the easiest way to see if a process with a given pid exists in Python?
In a POSIX system, I want to see if a given process (PID 4356, for example) is running. It would be even better if I could get metadata about that process.
A:
Instead of os.waitpid, you can also use os.kill with signal 0:
>>> os.kill... | What is the easiest way to see if a process with a given pid exists in Python? | In a POSIX system, I want to see if a given process (PID 4356, for example) is running. It would be even better if I could get metadata about that process.
| [
"Instead of os.waitpid, you can also use os.kill with signal 0:\n>>> os.kill(8861, 0)\n>>> os.kill(12765, 0)\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nOSError: [Errno 3] No such process\n>>> \n\nEdit: more expansively:\nimport errno\nimport os\n\ndef pid_exists(pid):\n try:\n ... | [
11,
4,
3,
1,
0,
0
] | [] | [] | [
"posix",
"python"
] | stackoverflow_0001005972_posix_python.txt |
Q:
Clearing background in matplotlib using wxPython
I want to create an animation with matplotlib to monitor the convergence of a clustering algorithm. It should draw a scatterplot of my data when called the first time and draw error ellipses each time the plot is updated. I am trying to use canvas_copy_from_bbox() a... | Clearing background in matplotlib using wxPython | I want to create an animation with matplotlib to monitor the convergence of a clustering algorithm. It should draw a scatterplot of my data when called the first time and draw error ellipses each time the plot is updated. I am trying to use canvas_copy_from_bbox() and restore_region() to save the scatterplot and then d... | [
"What's happening is that you're adding new patches to the plot each time, and then drawing all of them when you call self.canvas.draw(). \nThe quickest fix is to just call self.canvas.draw_artist(ellipsePlot) after adding each patch and remove the call to self.canvas.draw()\nAs a simple, stand-alone example:\n# An... | [
6
] | [] | [] | [
"matplotlib",
"python",
"wxpython"
] | stackoverflow_0004222344_matplotlib_python_wxpython.txt |
Q:
Process size in XP from Python
I have a python script that can approach the 2 GB process limit under Windows XP. On a machine with 2 GB physical memory, that can pretty much lock up the machine, even if the Python script is running at below normal priority.
Is there a way in Python to find out my own process size... | Process size in XP from Python | I have a python script that can approach the 2 GB process limit under Windows XP. On a machine with 2 GB physical memory, that can pretty much lock up the machine, even if the Python script is running at below normal priority.
Is there a way in Python to find out my own process size?
Thanks,
Gerry
| [
"try:\nimport win32process\nprint win32process.GetProcessMemoryInfo(win32process.GetCurrentProcess())\n\n",
"By using psutil https://github.com/giampaolo/psutil :\n>>> import psutil, os\n>>> p = psutil.Process(os.getpid())\n>>> p.memory_info()\nmeminfo(rss=6971392, vms=47755264)\n>>> p.memory_percent()\n0.1682125... | [
2,
1,
0
] | [] | [] | [
"python",
"windows_xp"
] | stackoverflow_0000417763_python_windows_xp.txt |
Q:
python generators duplicates
How do I either avoid adding duplicate entries into a generator or remove them once there are already there?
If I should be using something else, please advice.
A:
If the values are hashable, the simplest, dumbest way to remove duplicates is to use a set:
values = mygenerator()
uniqu... | python generators duplicates | How do I either avoid adding duplicate entries into a generator or remove them once there are already there?
If I should be using something else, please advice.
| [
"If the values are hashable, the simplest, dumbest way to remove duplicates is to use a set:\nvalues = mygenerator()\nunique_values = set(values)\n\nBut watch out: sets don't remember what order the values were originally in. So this scrambles the sequence.\nThe function below might be better than set for your purp... | [
12,
2
] | [] | [] | [
"python"
] | stackoverflow_0004230063_python.txt |
Q:
Python pattern matching
I'm currently in the process of converting an old bash script of mine into a Python script with added functionality. I've been able to do most things, but I'm having a lot of trouble with Python pattern matching.
In my previous script, I downloaded a web page and used sed to get the element... | Python pattern matching | I'm currently in the process of converting an old bash script of mine into a Python script with added functionality. I've been able to do most things, but I'm having a lot of trouble with Python pattern matching.
In my previous script, I downloaded a web page and used sed to get the elemented I wanted. The matching was... | [
"You will not parse html yourself. You will use a html parser built in python to parse the html. \n\nLightweight xml dom parser in python\nBeautiful Soup \n\n",
"You can user lxml to pull out the values you are looking for pretty easily with xpaths\n\nlxml\nxpath\n\nExample\nfrom lxml import html\npage = html.f... | [
4,
2,
1,
1
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0004227637_python_regex.txt |
Q:
Python: Test if an argument is an integer
I want to write a python script that takes 3 parameters. The first parameter is a string, the second is an integer, and the third is also an integer.
I want to put conditional checks at the start to ensure that the proper number of arguments are provided, and they are the ... | Python: Test if an argument is an integer | I want to write a python script that takes 3 parameters. The first parameter is a string, the second is an integer, and the third is also an integer.
I want to put conditional checks at the start to ensure that the proper number of arguments are provided, and they are the right type before proceeding.
I know we can use... | [
"str.isdigit() can be used to test if a string is comprised solely of numbers.\n",
"More generally, you can use isinstance to see if something is an instance of a class.\nObviously, in the case of script arguments, everything is a string, but if you are receiving arguments to a function/method and want to check t... | [
20,
11,
9,
6,
4,
3,
1,
0
] | [] | [] | [
"parameters",
"python",
"validation"
] | stackoverflow_0004228757_parameters_python_validation.txt |
Q:
Creating a 2d matrix in python
I create a 6x5 2d array, initially with just None in each cell. I then read a file and replace the Nones with data as I read them. I create the empty array first because the data is in an undefined order in the file I'm reading. My first attempt I did this:
x = [[None]*5]*6
which r... | Creating a 2d matrix in python | I create a 6x5 2d array, initially with just None in each cell. I then read a file and replace the Nones with data as I read them. I create the empty array first because the data is in an undefined order in the file I'm reading. My first attempt I did this:
x = [[None]*5]*6
which resulted in some weird errors that I ... | [
"Using nested comprehension lists :\nx = [[None for _ in range(5)] for _ in range(6)]\n\n",
"What's going on here is that the line \nx = [[None]*5]*6\n\nexpands out to\nx = [[None, None, None, None, None, None]]*6\n\nAt this point you have a list with 6 different references to the singleton None. You also have a ... | [
40,
31,
1
] | [] | [] | [
"list",
"python"
] | stackoverflow_0004230000_list_python.txt |
Q:
Python Tkinter listener in text box
I would like to know how (If Possible) to listen to a certain phrase or word that is entered in a text box and the run a command.
For instance if i type the phrase "turn me red" i would like to know if it is possible to turn it red without pressing enter.
I just started and here... | Python Tkinter listener in text box | I would like to know how (If Possible) to listen to a certain phrase or word that is entered in a text box and the run a command.
For instance if i type the phrase "turn me red" i would like to know if it is possible to turn it red without pressing enter.
I just started and here is what i have:
from Tkinter import *
c... | [
"So i thought it would be a little cleaner if rather than edit your code, i just provided a fresh example of working code that exhibits the behavior you are interested in.\nHere's what the code below does: when you run it, you get a little widget with an empty text box (technically, a Label in Tkinter) for the user... | [
4,
1
] | [] | [] | [
"python",
"tkinter"
] | stackoverflow_0004230093_python_tkinter.txt |
Q:
numpy magic to clean up function
I have the following function in which I wish to interpolate from a table at a specified value. The trick is that the table is defined in a log-log sense such that straight lines between points in log-log are really exponential. Thus I can't really use any of the typical scipy inte... | numpy magic to clean up function | I have the following function in which I wish to interpolate from a table at a specified value. The trick is that the table is defined in a log-log sense such that straight lines between points in log-log are really exponential. Thus I can't really use any of the typical scipy interpolate routines.
So here's what I hav... | [
"The easiest way to go is to just take the logarithm of PSD and then use SciPy interpolation functions:\nlogPSD = numpy.log(PSD)\nlogW_F = scipy.interpolate.interp1d(logPSD[:,0], logPSD[:,1])\nW_F = numpy.exp(logW_F(numpy.log(f)))\n\nThis will throw an error for out-of-bounds values. To avoid the error, you could\... | [
3
] | [] | [] | [
"numpy",
"python"
] | stackoverflow_0004230100_numpy_python.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 pytho... | 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 any... | [
"You can solve this problem in almost all languages including Python and Vbscript. \nHow ever it will be nicer to have the script in python or other languages that have quite a number of XML processing libraries. \nIf you are just searching for tags, you can use beautifulsoup.\n\nhttp://www.crummy.com/software/Beau... | [
2,
2,
0,
0,
0
] | [] | [] | [
"batch_file",
"python",
"scripting",
"vbscript",
"xml"
] | stackoverflow_0004198416_batch_file_python_scripting_vbscript_xml.txt |
Q:
Hidden Multithreading Bottlenecks in Jython?
What are some common hidden things that can bottleneck multithreading/parallelism in Jython? I have some parallel code (using Python's threading library) that won't scale past 3-4 CPUs, and I'm sure it's not because of any of these obvious pitfalls:
Explicit locks
Cal... | Hidden Multithreading Bottlenecks in Jython? | What are some common hidden things that can bottleneck multithreading/parallelism in Jython? I have some parallel code (using Python's threading library) that won't scale past 3-4 CPUs, and I'm sure it's not because of any of these obvious pitfalls:
Explicit locks
Calling library code that requires synchronization (T... | [
"Accessing variables is one of those \"hidden\" bottlenecks. If all threads access some shared datastructure(s) there will be synchronization between the threads.\nJython tries hard to achieve language compatibility with CPython. One thing that the GIL ensures is that access to local/global variables, object member... | [
4,
3,
1
] | [] | [] | [
"java",
"jvm",
"jython",
"multithreading",
"python"
] | stackoverflow_0004227269_java_jvm_jython_multithreading_python.txt |
Q:
Avoiding django QuerySet caching in a @staticmethod
The following few lines of code illustrate a distributed worker model that I use to crunch data. Jobs are being created in a database, their data goes onto the big drives, and once all information is available, the job status is set to 'WAITING'. From here, multi... | Avoiding django QuerySet caching in a @staticmethod | The following few lines of code illustrate a distributed worker model that I use to crunch data. Jobs are being created in a database, their data goes onto the big drives, and once all information is available, the job status is set to 'WAITING'. From here, multiple active workers come into play: from time to time each... | [
"Why not just have a plain module-level function claim_jobs() that would run the query?\ndef claim_jobs():\n\n jobs = Job.objects.filter(...)\n ... etc.\n\n"
] | [
0
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0004230510_django_django_models_python.txt |
Q:
Does this python code employs Depth First Search (DFS) for finding all paths?
This code is given in python official essays on graph theory. Here's the code:
def find_all_paths(graph, start, end, path=[]):
path = path + [start]
if start == end:
return [path]
if not graph.has_key(... | Does this python code employs Depth First Search (DFS) for finding all paths? | This code is given in python official essays on graph theory. Here's the code:
def find_all_paths(graph, start, end, path=[]):
path = path + [start]
if start == end:
return [path]
if not graph.has_key(start):
return []
paths = []
for node in graph[start]:
... | [
"The key to seeing that it is a DFS is that the recursion happens before the accumulation of paths. In other words the recursion will go as deep as it needs to go before putting anything on the \"paths\" list. All the deepest siblings are accumulated on \"paths\" before returning the list.\nI believe the code is ... | [
4,
4,
1
] | [] | [] | [
"depth_first_search",
"graph_theory",
"python"
] | stackoverflow_0004230878_depth_first_search_graph_theory_python.txt |
Q:
How to pass UTF-8 string from wx.TextCtrl to wx.ListCtrl
If I enter Baltic characters in textctrl and click button test1 I have an error
"InicodeEncodeError: 'ascii' codec can't encode characters in position 0-3:
ordinal not in range(128)"
Button test2 works fine.
#!/usr/bin/python
# -*- co... | How to pass UTF-8 string from wx.TextCtrl to wx.ListCtrl | If I enter Baltic characters in textctrl and click button test1 I have an error
"InicodeEncodeError: 'ascii' codec can't encode characters in position 0-3:
ordinal not in range(128)"
Button test2 works fine.
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import wx
class MyFrame(wx.Frame):
def _... | [
"can't reproduce... If I try with swedish caracters \"åäö\" it seems to work, also when using \"ąčęėįš\" locale problem?\n",
"Are you using the unicode build of wxPython? You didn't mention your platform and other system details.\n",
"Replace\ndef OnTest1(self, event):\n self.output_list.InsertStringItem... | [
0,
0,
0
] | [] | [] | [
"listctrl",
"python",
"textctrl",
"utf_8",
"wxpython"
] | stackoverflow_0004192744_listctrl_python_textctrl_utf_8_wxpython.txt |
Q:
pdflatex in a python subprocess on mac
I'm trying to run pdflatex on a .tex file from a Python 2.4.4. subprocess (on a mac):
import subprocess
subprocess.Popen(["pdflatex", "fullpathtotexfile"], shell=True)
which effectively does nothing. However, I can run "pdflatex fullpathtotexfile" in the terminal without iss... | pdflatex in a python subprocess on mac | I'm trying to run pdflatex on a .tex file from a Python 2.4.4. subprocess (on a mac):
import subprocess
subprocess.Popen(["pdflatex", "fullpathtotexfile"], shell=True)
which effectively does nothing. However, I can run "pdflatex fullpathtotexfile" in the terminal without issues, generating a pdf. What am I missing?
[E... | [
"Use the convenience function, subprocess.call\nYou don't need to use Popen here, call should suffice. \nFor example:\n>>> import subprocess\n>>> return_value = subprocess.call(['pdflatex', 'textfile'], shell=False) # shell should be set to False\n\nIf the call was successful, return_value will be set to 0, or else... | [
5,
1
] | [] | [] | [
"macos",
"pdflatex",
"python",
"subprocess"
] | stackoverflow_0004230926_macos_pdflatex_python_subprocess.txt |
Q:
3 Questions involving python and sqlite
Ok, I'm creating functions for use with a game server. This server uses plugins. I have these functions wich use a sqlite database, along with apsw to retrieve items stored by another function. I have 3 questions on this.
Question One: I keep getting the error "SQLError: nea... | 3 Questions involving python and sqlite | Ok, I'm creating functions for use with a game server. This server uses plugins. I have these functions wich use a sqlite database, along with apsw to retrieve items stored by another function. I have 3 questions on this.
Question One: I keep getting the error "SQLError: near "?": syntax error" Since my statement featu... | [
"This is funny (read on to learn why). \nThe first statement you have actually uses the value binding mechanism of the sqlite3-module (I assume that is what you use). Hence, the * (which is the default column) gets escaped, making the statement invalid. This is SQL-injection proof, and your own code tries to inject... | [
3,
0
] | [] | [] | [
"database",
"python",
"sqlite"
] | stackoverflow_0004114708_database_python_sqlite.txt |
Q:
sqlite / python - named parameters without enclosing quotes?
When using prepared statements with named parameters in SQLite (specifically with the python sqlite3 module http://docs.python.org/library/sqlite3.html ) is there anyway to include string values without getting quotes put around them ?
I've got this :
co... | sqlite / python - named parameters without enclosing quotes? | When using prepared statements with named parameters in SQLite (specifically with the python sqlite3 module http://docs.python.org/library/sqlite3.html ) is there anyway to include string values without getting quotes put around them ?
I've got this :
columnName = '''C1'''
cur = cur.execute('''SELECT DISTINCT(:colName)... | [
"In SELECT DISTINCT(C1) FROM T1 the C1 is not a string value, it is a piece of SQL code. The parameters (escaped in execute) are used to insert values, not pieces of code.\n",
"You are using bindings and bindings can only be used for values, not for table or column names. You will have to use string interpolatio... | [
4,
0
] | [] | [] | [
"named_parameters",
"prepared_statement",
"python",
"sqlite"
] | stackoverflow_0004191438_named_parameters_prepared_statement_python_sqlite.txt |
Q:
string operation
i have a string in which a word is like this "#<i><b>when</b></i>". i want only word without any tag. when in striped "#" word became "<i><b>when</b></i>". but when i striped "<i>" word became like "b>when"<b>when</b>"?
A:
Slice it.
>>> '#<i><b>when</b></i>'[4:-4]
'<b>when</b>'
A:
Use regular ... | string operation | i have a string in which a word is like this "#<i><b>when</b></i>". i want only word without any tag. when in striped "#" word became "<i><b>when</b></i>". but when i striped "<i>" word became like "b>when"<b>when</b>"?
| [
"Slice it.\n>>> '#<i><b>when</b></i>'[4:-4]\n'<b>when</b>'\n\n",
"Use regular expressions.\n>>> import re\n>>> s='#<i><b>when</b></i>'\n>>> wordPattern = re.compile(r'\\>(\\w+)\\<')\n>>> wordPattern.search(s).groups()\n('when',)\n\n"
] | [
1,
0
] | [] | [] | [
"python",
"regex",
"string"
] | stackoverflow_0004231362_python_regex_string.txt |
Q:
How to implement database-style table in Python
I am implementing a class that resembles a typical database table:
has named columns and unnamed rows
has a primary key by which I can refer to the rows
supports retrieval and assignment by primary key and column title
can be asked to add unique or non-unique index... | How to implement database-style table in Python | I am implementing a class that resembles a typical database table:
has named columns and unnamed rows
has a primary key by which I can refer to the rows
supports retrieval and assignment by primary key and column title
can be asked to add unique or non-unique index for any of the columns, allowing fast retrieval of a... | [
"I would consider building a dictionary with keys that are tuples or lists. Eg: my_dict((\"col_2\", \"row_24\")) would get you this element. Starting from there, it would be pretty easy (if not extremely fast for very large databases) to write 'get_col' and 'get_row' methods, as well as 'get_row_slice' and 'get_col... | [
2,
2,
0
] | [] | [] | [
"data_structures",
"implementation",
"performance",
"python"
] | stackoverflow_0004188202_data_structures_implementation_performance_python.txt |
Q:
trouble getting pylint to find inherited methods in pylons/SA models
I have a Pylons app that I'm using SqlAlchemy declarative models for. In order to make the code a bit cleaner I add a .query onto the SA Base and inherit all my models from that.
So in my app.model.meta I have
Base = declarative_base()
metadata ... | trouble getting pylint to find inherited methods in pylons/SA models | I have a Pylons app that I'm using SqlAlchemy declarative models for. In order to make the code a bit cleaner I add a .query onto the SA Base and inherit all my models from that.
So in my app.model.meta I have
Base = declarative_base()
metadata = Base.metadata
Session = scoped_session(sessionmaker())
Base.query = Ses... | [
"Best I could find for this is to pass pylint a list of classes to ignore this check on. It'll still do other checks for these classes, you'll just have to maintain a list of these somewhere:\npylint --ignored-classes=MyModel1,MyModel2 myfile.py\nI know it's not ideal, but there's something about the way that sqla... | [
8
] | [] | [] | [
"pylint",
"pylons",
"python",
"sqlalchemy"
] | stackoverflow_0004061720_pylint_pylons_python_sqlalchemy.txt |
Q:
Retrieving only HTTP header without the content in Python
Possible Duplicate:
How do you send a HEAD HTTP request in Python?
I am using Python's urllib and urllib2 to do an automated login. I am also using HTTPCookieProcessor to automate the handling of the cookies. The code is somewhat like this:
o = urllib2.bu... | Retrieving only HTTP header without the content in Python |
Possible Duplicate:
How do you send a HEAD HTTP request in Python?
I am using Python's urllib and urllib2 to do an automated login. I am also using HTTPCookieProcessor to automate the handling of the cookies. The code is somewhat like this:
o = urllib2.build_opener( urllib2.HTTPCookieProcessor() )
# assuming the sit... | [
"Just send a HEAD request instad of a GET request. You can use Python's httplib to do that. \nSomething like this:\n import httplib, urllib\n creds = urllib.urlencode({ 'username': 'me', 'password': 'mypass' });\n connection = httplib.HTTPConnection(\"www.mysite.com\")\n connection.request(\"HEAD\", \"/logi... | [
1
] | [] | [] | [
"python",
"urllib2"
] | stackoverflow_0004231469_python_urllib2.txt |
Q:
pyparsing isn't nesting list ... why?
For some reason, pyparsing isn't nesting the list for my string:
rank = oneOf("2 3 4 5 6 7 8 9 T J Q K A")
suit = oneOf("h c d s")
card = rank + Optional(suit)
suit_filter = oneOf("z o")
hand = card + card + Optional(suit_filter)
greater = Literal("+")
through = Literal("-")... | pyparsing isn't nesting list ... why? | For some reason, pyparsing isn't nesting the list for my string:
rank = oneOf("2 3 4 5 6 7 8 9 T J Q K A")
suit = oneOf("h c d s")
card = rank + Optional(suit)
suit_filter = oneOf("z o")
hand = card + card + Optional(suit_filter)
greater = Literal("+")
through = Literal("-")
series = hand + Optional(greater | through... | [
"Pyparsing isn't grouping these tokens because you didn't tell it to. Pyparsing's default behavior is to simply string together all matched tokens into a single list. To get grouping of your tokens, wrap the expressions in your parser that are to be grouped in a pyparsing Group expression. In your case, change se... | [
8
] | [] | [] | [
"pyparsing",
"python"
] | stackoverflow_0004231349_pyparsing_python.txt |
Q:
Python - NumPy - tuples as elements of an array
I'm a CS major in university working on a programming project for my Calc III course involving singular-value decomposition. The idea is basically to convert an image of m x n dimensions into an m x n matrix wherein each element is a tuple representing the color chan... | Python - NumPy - tuples as elements of an array | I'm a CS major in university working on a programming project for my Calc III course involving singular-value decomposition. The idea is basically to convert an image of m x n dimensions into an m x n matrix wherein each element is a tuple representing the color channels (r, g, b) of the pixel at point (m, n). I'm usin... | [
"Instead of setting the array element type to 'O' (object) you should set it to a tuple. See the SciPy manual for some examples.\nIn your case, easiest is to use something like\na = zeros((ph,pw), dtype=(float,3))\n\nAssuming your RGB values are tuples of 3 floating point numbers.\nThis is similar to creating a 3d ... | [
15,
3
] | [] | [] | [
"arrays",
"linear_algebra",
"numpy",
"python"
] | stackoverflow_0004231190_arrays_linear_algebra_numpy_python.txt |
Q:
How to find a relative URL and translate it to an absolute URL in Python
I extract some code from a web page (http://www.opensolaris.org/os/community/on/flag-days/all/) like follows,
<tr class="build">
<th colspan="0">Build 110</th>
</tr>
<tr class="arccase project flagday">
<td>Feb-25</td>
<td></td>
<td><... | How to find a relative URL and translate it to an absolute URL in Python | I extract some code from a web page (http://www.opensolaris.org/os/community/on/flag-days/all/) like follows,
<tr class="build">
<th colspan="0">Build 110</th>
</tr>
<tr class="arccase project flagday">
<td>Feb-25</td>
<td></td>
<td></td>
<td></td>
<td>
<a href="../pages/2009022501/">Flag Day and Heads ... | [
"I'm not sure about what you're trying to achieve but using the BASE tag in HTML may do this trick for you without having to resort to regular expressions when doing the processing.\n",
"First, I'd recommend using a HTML parser, such as BeautifulSoup. HTML is not a regular language, and thus can't be parsed fully... | [
5,
3,
2,
2,
1
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0000589833_python_regex.txt |
Q:
Python PIL - All areas of PNG with opacity > 0 have their opacity set to 1
Imagine a red circle with a black dropshadow that fades away on top of a fully transparent background. When I open and resave the image with PIL the background remains fully transparent but the dropshadow becomes full black.
The problem app... | Python PIL - All areas of PNG with opacity > 0 have their opacity set to 1 | Imagine a red circle with a black dropshadow that fades away on top of a fully transparent background. When I open and resave the image with PIL the background remains fully transparent but the dropshadow becomes full black.
The problem appears without even altering the image:
image = Image.open('input.png')
image = im... | [
"It looks like PIL currently doesn't support full alpha for PNG8.\nThere is a patch here for read-only support: http://mail.python.org/pipermail/image-sig/2010-October/006533.html\nIf you're feeling naughty, you could monkeypatch PIL:\nfrom PIL import Image, ImageFile, PngImagePlugin\n\ndef patched_chunk_tRNS(self,... | [
6,
0
] | [] | [] | [
"png",
"python",
"python_imaging_library"
] | stackoverflow_0004217869_png_python_python_imaging_library.txt |
Q:
Zip and apply a list of functions over a list of values in Python
Is there idiomatic and/or elegant Python for zipping and applying a list of functions over a list of values?
For example, suppose you have a list of functions:
functions = [int, unicode, float, lambda x: '~' + x + '~']
and a list of values:
values ... | Zip and apply a list of functions over a list of values in Python | Is there idiomatic and/or elegant Python for zipping and applying a list of functions over a list of values?
For example, suppose you have a list of functions:
functions = [int, unicode, float, lambda x: '~' + x + '~']
and a list of values:
values = ['33', '\xc3\xa4', '3.14', 'flange']
Is there a way to apply the ith... | [
"[x(y) for x, y in zip(functions, values)]\n\n",
"These solutions seem overly complicated: map already zips its arguments:\nmap(lambda x,y:x(y), functions, values)\n\nOr, if you prefer the iterator version:\nfrom itertools import imap\nimap(lambda x,y:x(y), functions, values)\n\n",
"One of the beautiful featur... | [
24,
24,
4,
1
] | [] | [] | [
"python"
] | stackoverflow_0004231345_python.txt |
Q:
Matching a space at the beginning of a line using pyparsing
I'm trying to parse a unified diff file using pyparsing as an exercise and I can't get something right. Here the part of my diff file that's causing me troubles :
(... some stuff over...)
banana
+apple
orange
The first line starts with " " then "banana... | Matching a space at the beginning of a line using pyparsing | I'm trying to parse a unified diff file using pyparsing as an exercise and I can't get something right. Here the part of my diff file that's causing me troubles :
(... some stuff over...)
banana
+apple
orange
The first line starts with " " then "banana". I have the following expression for parsing a line :
linestart... | [
"You can read and parse one line at a time. The following code works for me.\nfrom pyparsing import Literal, restOfLine\n\nlinestart = Literal(\" \") | Literal(\"+\") | Literal(\"-\")\nline = linestart.leaveWhitespace() + restOfLine\n\nf = open(\"/tmp/test.diff\")\nfor l in f.readlines():\n fields = line.parseStri... | [
1
] | [] | [] | [
"pyparsing",
"python"
] | stackoverflow_0004231835_pyparsing_python.txt |
Q:
Automating JPEG download
I need to download jpeg images of size > MIN_SIZE from the pages 1 <= PAGE_NUMBER <= NUM_OF_PAGES
http://somewebsite.com/showthread.php?t=12345&page=PAGE_NUMBER
How can I do that in python? I am new to python.
A:
Here's how I would do it in Python:
Fetch each page you need to grab image... | Automating JPEG download | I need to download jpeg images of size > MIN_SIZE from the pages 1 <= PAGE_NUMBER <= NUM_OF_PAGES
http://somewebsite.com/showthread.php?t=12345&page=PAGE_NUMBER
How can I do that in python? I am new to python.
| [
"Here's how I would do it in Python:\n\nFetch each page you need to grab image from (easy, just use mechanize or some other HTTP fetcher library)\nParse each HTML file to grab the image URLs. This a bit more involved -- have a look at HTMLParser. From memory, you can subclass HTMLParser to only grab the text that... | [
1
] | [] | [] | [
"python"
] | stackoverflow_0004232128_python.txt |
Q:
StringType and NoneType in python3.x
I have a codebase which uses StringType and NoneType(types module) in the python2.x codebase. On porting to Python3, tests failed as the types module in Python3.x does not have the above mentioned two types.
I solved the problem by replacing them with "str" and "None" respectiv... | StringType and NoneType in python3.x | I have a codebase which uses StringType and NoneType(types module) in the python2.x codebase. On porting to Python3, tests failed as the types module in Python3.x does not have the above mentioned two types.
I solved the problem by replacing them with "str" and "None" respectively. I was wondering if there is another (... | [
"Checking None is usually done by calling obj is None, while checking for string usually is isinstance(obj, str). In Python 2.x to detect both string and unicode, you could use isinstance(obj, basestring).\nIf you use 2to3, it's enough, but if you need to have single piece of code working in both Py2 and Py3, you m... | [
26,
7
] | [] | [] | [
"python",
"python_3.x"
] | stackoverflow_0004232111_python_python_3.x.txt |
Q:
python modify Tkinter.Listbox parameter
I need help with Tkinter.Listbox class, I'm trying to change the color of selected line
A:
from Tkinter import *
master = Tk()
listbox = Listbox(master, selectbackground="red")
If there are any other colours you want to change, then look them up at the documentation.
| python modify Tkinter.Listbox parameter | I need help with Tkinter.Listbox class, I'm trying to change the color of selected line
| [
"from Tkinter import *\nmaster = Tk()\nlistbox = Listbox(master, selectbackground=\"red\")\n\nIf there are any other colours you want to change, then look them up at the documentation. \n"
] | [
2
] | [] | [] | [
"listbox",
"python",
"selection",
"tkinter"
] | stackoverflow_0004232823_listbox_python_selection_tkinter.txt |
Q:
Communication between threads in PySide
I have a thread which produces some data (a python list) and which shall be available for a widget that will read and display the data in the main thread.
Actually, I'm using QMutex to provide access to the data, in this way:
class Thread(QThread):
def get_data(self):
... | Communication between threads in PySide | I have a thread which produces some data (a python list) and which shall be available for a widget that will read and display the data in the main thread.
Actually, I'm using QMutex to provide access to the data, in this way:
class Thread(QThread):
def get_data(self):
QMutexLock(self.mutex)
return deepcopy(se... | [
"I think this should work with PySide. if not work please report a bug on PySide bugzilla(http://bugs.openbossa.org/) with a small test case:\nclass Thread(QThread):\n dataReady = Signal(object)\n\n def run(self):\n while True:\n self.data = slowly_produce_data()\n # this will add a ref to self.data ... | [
15
] | [] | [] | [
"multithreading",
"pyqt",
"pyqt4",
"pyside",
"python"
] | stackoverflow_0002823112_multithreading_pyqt_pyqt4_pyside_python.txt |
Q:
Installing easy_install... to get to installing lxml
I've come to grips with the fact that ElementTree isn't going to do what I want it to do. I've checked out the documentation for lxml, and it appears that it will serve my purposes. To get lxml, I need to get easy_install. So I downloaded it from here, and put i... | Installing easy_install... to get to installing lxml | I've come to grips with the fact that ElementTree isn't going to do what I want it to do. I've checked out the documentation for lxml, and it appears that it will serve my purposes. To get lxml, I need to get easy_install. So I downloaded it from here, and put it in /Library/Frameworks/Python.framework/Versions/2.6/lib... | [
"First off we don't use easy_install anymore. We use pip. Please use pip instead.\nTo get to your particular troubles, as the comments point out, you're missing GCC. On OS X, Xcode Command Line Tools provides GCC, as well as many other programs necessary for building software on OS X. For OS X 10.9 (Mavericks) and ... | [
22,
13,
10,
2,
2
] | [] | [] | [
"easy_install",
"lxml",
"python"
] | stackoverflow_0002368008_easy_install_lxml_python.txt |
Q:
sqlite3 rowid alias not being properly created
According to the sqlite3 documentation, creating a table where the primary key is an ascending integer causes the primary key to be an alias for the rowID. This isn't happening for me.
Here is my creation code:
import sqlite3
con = sqlite3.connect("/tmp/emaildb.sqlite... | sqlite3 rowid alias not being properly created | According to the sqlite3 documentation, creating a table where the primary key is an ascending integer causes the primary key to be an alias for the rowID. This isn't happening for me.
Here is my creation code:
import sqlite3
con = sqlite3.connect("/tmp/emaildb.sqlite3")
c = con.cursor()
try:
c.execute("create tabl... | [
"http://www.sqlite.org/autoinc.html\nI am not familiar with the \"asc\" directive in your create-table.\n"
] | [
1
] | [] | [] | [
"python",
"sqlite"
] | stackoverflow_0004233098_python_sqlite.txt |
Q:
sha1WithRSAEncryption in Python
Can someone recommend a library for calculating SHA1WithRSAEncryption in Python?
Context: I'm trying to do some message authentication. I've looked at PyXMLDSig, but it seemed to expect the certificates as separate files. As a first step to better understanding the problem space, I ... | sha1WithRSAEncryption in Python | Can someone recommend a library for calculating SHA1WithRSAEncryption in Python?
Context: I'm trying to do some message authentication. I've looked at PyXMLDSig, but it seemed to expect the certificates as separate files. As a first step to better understanding the problem space, I wanted to calculate the digest values... | [
"Take a look at M2Crypto, it's probably the best and most complete crypto library for Python.\n"
] | [
0
] | [] | [] | [
"python",
"sha1",
"xml"
] | stackoverflow_0004107888_python_sha1_xml.txt |
Q:
Receiving Mail in Google App Engine
I am reading the tutorial about Receiving Mail. I updated the app.yaml file as instructed:
application: hello-1-world
version: 1
runtime: python
api_version: 1
handlers:
- url: /favicon.ico
static_files: static/images/favicon.ico
upload: static/images/favicon.ico
- url: /_... | Receiving Mail in Google App Engine | I am reading the tutorial about Receiving Mail. I updated the app.yaml file as instructed:
application: hello-1-world
version: 1
runtime: python
api_version: 1
handlers:
- url: /favicon.ico
static_files: static/images/favicon.ico
upload: static/images/favicon.ico
- url: /_ah/mail/.+
script: handle_incoming_emai... | [
"Is help@hello-1-world.appspotmail.com a valid google user? GAE can receive/send mails only from the google user of your application.\nYour code seems correct.\n\"Also, why do I need to have a separate script to handle incoming mail? Why can't I put the ReceiveEmail handler in my hw.py\" -> the main script is to ha... | [
1
] | [] | [] | [
"email",
"google_app_engine",
"python"
] | stackoverflow_0004233201_email_google_app_engine_python.txt |
Q:
Python script import fails if script is moved to subdirectory
This may be my own misunderstanding of how Python imports and search paths work, or it may be a problem in the packaging of the caldav package.
I have set up a virtualenv environment named myproject
In the top level of myproject, I have a script test.py... | Python script import fails if script is moved to subdirectory | This may be my own misunderstanding of how Python imports and search paths work, or it may be a problem in the packaging of the caldav package.
I have set up a virtualenv environment named myproject
In the top level of myproject, I have a script test.py which contains two imports:
import lxml
import caldav
In this dir... | [
"Most likely, caldav was in the same directory as test.py, so when you import it it worked fine. Now that you moved test.py to a subdirectory, your imports can't find it. You can either move caldav or set your PYTHONPATH.\nYou could also modify your sys.path\nInformation from Python's module tutorial: http://docs.p... | [
3
] | [] | [] | [
"python",
"virtualenv"
] | stackoverflow_0004233311_python_virtualenv.txt |
Q:
refreshing QTreeView / QSortFilterProxyModel
Good Day to All,
Been writing code for years, but still a bit green when it comes to PyQt,
so please forgive my syntactically lacking question(s) ;-)
I'm hacking a derivative of the (famous?) packaged example that
comes with PyQt4 (and Qt), namely "basicsortfiltermodel.... | refreshing QTreeView / QSortFilterProxyModel | Good Day to All,
Been writing code for years, but still a bit green when it comes to PyQt,
so please forgive my syntactically lacking question(s) ;-)
I'm hacking a derivative of the (famous?) packaged example that
comes with PyQt4 (and Qt), namely "basicsortfiltermodel.pyw"
from "../examples/itemviews" in PyQt4...
I've... | [
"I believe you have to add new items into your original model not the proxy one. Once items is added proxy model and view will updates themselves accordingly. See if an example below would work for you:\nimport sys\nfrom PyQt4 import QtGui\n\nclass MainForm(QtGui.QMainWindow):\n def __init__(self, parent=None):\... | [
3
] | [] | [] | [
"pyqt",
"python",
"qt"
] | stackoverflow_0004218778_pyqt_python_qt.txt |
Q:
Download prices with python
I have tried this before. I'm completely at a loss for ideas.
On this page this dialog box to qet quotes.
http://www.schwab.com/public/schwab/non_navigable/marketing/email/get_quote.html?
I used SPY, XLV, IBM, MSFT
The output is the above with a table.
If you have an account the qu... | Download prices with python | I have tried this before. I'm completely at a loss for ideas.
On this page this dialog box to qet quotes.
http://www.schwab.com/public/schwab/non_navigable/marketing/email/get_quote.html?
I used SPY, XLV, IBM, MSFT
The output is the above with a table.
If you have an account the quote are real time --- via cookie.... | [
"Use something like Beautiful Soup to parse the HTML response from the web site and load it into a dictionary. use the symbol as the key and a tuple of whatever data you're interested in as the value. Iterate over all the symbols returned and add one entry per symbol.\nYou can see examples of how to do this in To... | [
5,
4,
3,
0
] | [] | [] | [
"python"
] | stackoverflow_0004219007_python.txt |
Q:
Python separating images and text from MS office files
Is there a way to separate the text and images from MS Office files like word, excel, ppt etc.
and getting the position of the image in a document( where the image starts in the document between text)?
The application needs to be developed for Linux box.
Pleas... | Python separating images and text from MS office files | Is there a way to separate the text and images from MS Office files like word, excel, ppt etc.
and getting the position of the image in a document( where the image starts in the document between text)?
The application needs to be developed for Linux box.
Please suggest.
| [
"You may want to look at the Python UNO bindings for OpenOffice - wiki at http://wiki.services.openoffice.org/wiki/Python - this should let you open and work with MSOffice docs on linux.\nWhat exactly are you trying to accomplish - a new way to HTML-ize Office docs?\n"
] | [
0
] | [] | [] | [
"file",
"python"
] | stackoverflow_0004223958_file_python.txt |
Q:
Override __mul__ from a child class using parent implementation: leads to problems
I'm trying to implement the __mul__ method of class C which extends class P. Class P has an implementation of __mul__ but that's only for elements of that type (P() * P()).
So in C.__mul__ I want to implement simple multiplication ... | Override __mul__ from a child class using parent implementation: leads to problems | I'm trying to implement the __mul__ method of class C which extends class P. Class P has an implementation of __mul__ but that's only for elements of that type (P() * P()).
So in C.__mul__ I want to implement simple multiplication for a float when the argument is float. When it's not I want to use P.__mul__ ... but th... | [
"First you your typecheck in __mul__ for MyFloatExt should look like\nisinstance(other,(int,long,float))\n\nor even better\nisinstance(other,Number) #from numbers import Number\n\nAlso you would like to change definition of __mul__ in MyFloat to this:\nclass MyFloat(object):\n#...\n def __mul__(self, other):\n ... | [
6,
2
] | [] | [] | [
"inheritance",
"python"
] | stackoverflow_0004233628_inheritance_python.txt |
Q:
Loop will not break
I'm creating a sort of database, using a list that is read in from the user. When the user enters finish I want the while loop to stop. However, for some reason I need to enter finish TWICE for it to break the loop.
Also, the list is empty after being returned.
def readNames():
nameList = []
co... | Loop will not break | I'm creating a sort of database, using a list that is read in from the user. When the user enters finish I want the while loop to stop. However, for some reason I need to enter finish TWICE for it to break the loop.
Also, the list is empty after being returned.
def readNames():
nameList = []
count = 0
while count != -1... | [
"When you do\nreadNames()\nprint readNames()\n\nyou run the function twice. On the 2nd run you just enter \"finish\" and thats why your list remains empty.\nWhat you want to do is this:\ndef readNames():\n nameList = []\n while True: #infinite loop\n addList = raw_input(\"Please enter a name: \")\n ... | [
4,
2,
1
] | [
"Could you not replace\n\nif addList == 'finish':\n return nameList\n break\n\nWith\n\nif addList == 'finish':\n return nameList\n count = -1\n\n?\nJames\n"
] | [
-1
] | [
"break",
"list",
"python",
"while_loop"
] | stackoverflow_0004233785_break_list_python_while_loop.txt |
Q:
In python, how can you retrieve a key from a dictionary?
I have a hashable identifier for putting things in a dictionary:
class identifier():
def __init__(self, d):
self.my_dict = d
self.my_frozenset = frozenset(d.items())
def __getitem__(self, item):
return self.my_dict[item]
d... | In python, how can you retrieve a key from a dictionary? | I have a hashable identifier for putting things in a dictionary:
class identifier():
def __init__(self, d):
self.my_dict = d
self.my_frozenset = frozenset(d.items())
def __getitem__(self, item):
return self.my_dict[item]
def __hash__(self):
return hash(self.my_frozenset)
... | [
"Instead of \nd[n1] = 'Node 1'\n\nuse:\nd[n1] = ('Node 1', n1)\n\nThen you have access to n1 no matter how you found the value.\nI don't believe there is a way with dictionaries to retrieve the original key k1 if all you have is a k2 equal to k1.\n",
"Have two dictionaries.\n - Whenever you add a key/value to the... | [
5,
3,
1,
0,
0
] | [] | [] | [
"dictionary",
"networkx",
"performance",
"python",
"reverse_lookup"
] | stackoverflow_0004224895_dictionary_networkx_performance_python_reverse_lookup.txt |
Q:
I need a class that creates a dictionary file that lives on disk
I want to create a very very large dictionary, and I'd like to store it on disk so as not to kill my memory. Basically, my needs are a cross between cPickle and the dict class, in that it's a class that Python treats like a dictionary, but happens to... | I need a class that creates a dictionary file that lives on disk | I want to create a very very large dictionary, and I'd like to store it on disk so as not to kill my memory. Basically, my needs are a cross between cPickle and the dict class, in that it's a class that Python treats like a dictionary, but happens to live on the disk.
My first thought was to create some sort of wrappe... | [
"The simplest way is the shelve module, which works almost exactly like a dictionary:\nimport shelve\nmyshelf = shelve.open(\"filename\") # Might turn into filename.db\nmyshelf[\"A\"] = \"First letter of alphabet\"\nprint myshelf[\"A\"]\n# ...\nmyshelf.close() # You should do this explicitly when you're finished\... | [
2,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0004233923_python.txt |
Q:
Changing python immutable type while iterating through a mutable container such as list
I am wondering what is the most pythonic way to do the following and have it work:
strings = ['a','b']
for s in strings:
s = s+'c'
obviously this doesn't work in python but the result that I want to acheive is
strings =... | Changing python immutable type while iterating through a mutable container such as list | I am wondering what is the most pythonic way to do the following and have it work:
strings = ['a','b']
for s in strings:
s = s+'c'
obviously this doesn't work in python but the result that I want to acheive is
strings = ['ac','bc']
Whats the most pythonic way to achieve this kind of result?
Thanks for the gre... | [
"strings = ['a', 'b']\nstrings = [s + 'c' for s in strings]\n\n",
"You can use list comprehension to create a list that has these values: [s + 'c' for s in strings]. You can modify the list in-place like this:\nfor i, s in enumerate(strings):\n strings[i] = s + 'c'\n\nBut I found that quite often, in-place mod... | [
6,
3,
1
] | [] | [] | [
"immutability",
"iteration",
"python",
"types"
] | stackoverflow_0004234298_immutability_iteration_python_types.txt |
Q:
64bit prcessor with 32bit operating system program compatibilities?
on 64bit processors.
with 32bit operating system
all programs works fine ?
like suppose all python 32bit installation programs works fine ? or there are any issues found?
a program or software developed on 32bit operating system & 32bit processo... | 64bit prcessor with 32bit operating system program compatibilities? | on 64bit processors.
with 32bit operating system
all programs works fine ?
like suppose all python 32bit installation programs works fine ? or there are any issues found?
a program or software developed on 32bit operating system & 32bit processor
installed on 32bit operating system and 64bit processor
does it work ... | [
"\non 64bit processors. with 32bit\n operating system all programs works\n fine ?\n\nYes. \n\nlike suppose all python 32bit\n installation programs works fine ? or\n there are any issues found?\n\nNo issues. \n\na program or software developed on\n 32bit operating system & 32bit\n processor installed on 32bit... | [
3,
0
] | [] | [] | [
"linux",
"python"
] | stackoverflow_0004234275_linux_python.txt |
Q:
using stored variables as regex patterns
is there a way for python to use values stored in variables as patterns in regex?
supposing i have two variables:
begin_tag = '<%marker>'
end_tag = '<%marker/>'
doc = '<html> something here <%marker> and here and here <%marker/> and more here <html>'
how do you extract th... | using stored variables as regex patterns | is there a way for python to use values stored in variables as patterns in regex?
supposing i have two variables:
begin_tag = '<%marker>'
end_tag = '<%marker/>'
doc = '<html> something here <%marker> and here and here <%marker/> and more here <html>'
how do you extract the text between begin_tag and end_tag?
the tags... | [
"Don't use a regex at all. parse html inteligently!\nfrom BeautifulSoup import BeautifulSoup\nmarker = 'mytag'\ndoc = '<html>some stuff <mytag> different stuff </mytag> other things </html>'\nsoup = BeautifulSoup(doc)\nprint soup.find(marker).renderContents()\n\n",
"Regular expressions are strings. So you can do... | [
2,
1
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0004234240_python_regex.txt |
Q:
Web Proxy to Simulate Network Problems
I need a way to simulate connectivity problems in an automated test suite, on Linux, and preferably from Python. Some sort of proxy that I can put in front of the web server that can hang or drop connections after one trigger or another (after X bytes transferred, etc) would ... | Web Proxy to Simulate Network Problems | I need a way to simulate connectivity problems in an automated test suite, on Linux, and preferably from Python. Some sort of proxy that I can put in front of the web server that can hang or drop connections after one trigger or another (after X bytes transferred, etc) would be perfect.
It doesn't seem too hard to buil... | [
"when i needed one, i found that building it yourself is the best thing..\nstart by raising a threaded server in python http://docs.python.org/dev/library/socketserver.html (you don't have to use the class itself).\nand it's very simple:\nin the new connection thread, you create a new socket and connects it to the ... | [
2
] | [] | [] | [
"http",
"proxy",
"python"
] | stackoverflow_0004218900_http_proxy_python.txt |
Q:
Unicode not printing correctly to cp850 (cp437), play card suits
To summarize: How do I print unicode system independently to produce play card symbols?
What I do wrong, I consider myself quite fluent in Python, except I seem not able to print correctly!
# coding: utf-8
from __future__ import print_function
from _... | Unicode not printing correctly to cp850 (cp437), play card suits | To summarize: How do I print unicode system independently to produce play card symbols?
What I do wrong, I consider myself quite fluent in Python, except I seem not able to print correctly!
# coding: utf-8
from __future__ import print_function
from __future__ import unicode_literals
import sys
symbols = ('♥','♦','♠','... | [
"Whenever I need to output utf-8 characters, I use the following approach:\nimport codecs\n\nout = codecs.getwriter('utf-8')(sys.stdout)\n\nstr = u'♠'\n\nout.write(\"%s\\n\" % str)\n\nThis saves me an encode('utf-8') every time something needs to be sent to sdtout/stderr.\n",
"In response to the updated question\... | [
2,
1,
1,
0
] | [] | [] | [
"cmd",
"python",
"windows",
"windows_xp"
] | stackoverflow_0004233227_cmd_python_windows_windows_xp.txt |
Q:
Access XAMPP by default via MySQLdb Python lib on Ubuntu 10.10
I'm attempting to build a Virtual Machine to develop a Django application. The OS is Ubuntu 10.10. I have most everything installed. The last piece is getting MySQLdb to work with the MySQL instance that comes with XAMPP.
How can I get MySQLdb to defa... | Access XAMPP by default via MySQLdb Python lib on Ubuntu 10.10 | I'm attempting to build a Virtual Machine to develop a Django application. The OS is Ubuntu 10.10. I have most everything installed. The last piece is getting MySQLdb to work with the MySQL instance that comes with XAMPP.
How can I get MySQLdb to default to work with the XAMPP MySQL?
I found this: Accessing a XAMPP my... | [
"I don't understand why you don't just install MySQL via sudo apt-get install mysql-server, but nevertheless the answer to your question would seem to be to configure Django to use the specified socket in place of the default.\nFrom the documentation to settings.DATABASES, under HOST:\n\nIf this value starts with a... | [
3
] | [] | [] | [
"django",
"mysql",
"python",
"ubuntu",
"xampp"
] | stackoverflow_0004234316_django_mysql_python_ubuntu_xampp.txt |
Q:
Google app engine TypeError issue
I got a simple app on google app engine using django and I have two classes that look pretty much identical, but one of them crashes with TypeError.
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", ... | Google app engine TypeError issue | I got a simple app on google app engine using django and I have two classes that look pretty much identical, but one of them crashes with TypeError.
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 3211, in _HandleRequest
self._... | [
"def NotFoundPage(BasePage):\n\nshould be:\nclass NotFoundPage(BasePage):\n\n"
] | [
6
] | [] | [] | [
"django",
"google_app_engine",
"python",
"typeerror"
] | stackoverflow_0004235031_django_google_app_engine_python_typeerror.txt |
Q:
How to avoid infinite recursion with super()?
I have code like this:
class A(object):
def __init__(self):
self.a = 1
class B(A):
def __init__(self):
self.b = 2
super(self.__class__, self).__init__()
class C(B):
def __init__(self):
self.c = 3
super(self.__clas... | How to avoid infinite recursion with super()? | I have code like this:
class A(object):
def __init__(self):
self.a = 1
class B(A):
def __init__(self):
self.b = 2
super(self.__class__, self).__init__()
class C(B):
def __init__(self):
self.c = 3
super(self.__class__, self).__init__()
Instantiating B works as exp... | [
"When instantiating C calls B.__init__, self.__class__ will still be C, so the super() call brings it back to B.\nWhen calling super(), use the class names directly. So in B, call super(B, self), rather than super(self.__class__, self) (and for good measure, use super(C, self) in C). From Python 3, you can just use... | [
51
] | [] | [] | [
"multiple_inheritance",
"oop",
"python",
"super"
] | stackoverflow_0004235078_multiple_inheritance_oop_python_super.txt |
Q:
Python: Store the data into two lists and then convert to a dictionary
I am new to python, and have a question regarding store columns in lists and converting them to dictionary as follow:
I have a data in two column shown below, with nodes(N) and edges(E), and I want to first make a list of these two columns and ... | Python: Store the data into two lists and then convert to a dictionary | I am new to python, and have a question regarding store columns in lists and converting them to dictionary as follow:
I have a data in two column shown below, with nodes(N) and edges(E), and I want to first make a list of these two columns and then make a dictionary of those two lists as
{1:[9,2,10],2:[10,111,9],3:[166... | [
"A defaultdict is a subclass of dict which would be useful here:\nimport collections\nresult=collections.defaultdict(list)\nfor n,e in zip(N,E):\n result[n].append(e)\n\n",
"yourDict={}\nfor line in file('r.txt', 'r'):\n k , v = line.split()\n if k in yourDict.keys():\n yourDict[k].append(v)\n ... | [
6,
2,
2,
1,
1,
0
] | [] | [] | [
"dictionary",
"list",
"python"
] | stackoverflow_0004208204_dictionary_list_python.txt |
Q:
function that process multilple lines and/or single line in a file
if i have a file, how should i implement a function so that it can both read single and multiple lines. for example:
TimC
Tim Cxe
USA
http://www.TimTimTim.com
TimTim facebook!
ENDBIO
Charles
Dwight
END
Mcdon
Mcdonald
Africa
# website in here... | function that process multilple lines and/or single line in a file | if i have a file, how should i implement a function so that it can both read single and multiple lines. for example:
TimC
Tim Cxe
USA
http://www.TimTimTim.com
TimTim facebook!
ENDBIO
Charles
Dwight
END
Mcdon
Mcdonald
Africa
# website in here is empty, but we still need to consider it
# bio in here is empty... | [
"from itertools import izip\n\nline_meanings = (\"name\", \"location\", \"web\")\nresult = {}\nuser = None\n\ndef readClean(iterable, sentinel=None):\n for line in iterable:\n line = line.strip()\n if line == sentinel:\n break\n yield line\n\nwhile True:\n line = yourfile.readl... | [
1,
0,
0
] | [] | [] | [
"file",
"python",
"twitter"
] | stackoverflow_0004235106_file_python_twitter.txt |
Q:
Pygame doesn't draw
I need help with a program I'm making. It's a version of Conway's Game of Life.
This game is right now made out of 3 files: main.py, cellBoard.py, cell.py
main.py takes care to instance cellboard and make it update its data, give it mouse input, and tell it to draw itself (an instance of the py... | Pygame doesn't draw | I need help with a program I'm making. It's a version of Conway's Game of Life.
This game is right now made out of 3 files: main.py, cellBoard.py, cell.py
main.py takes care to instance cellboard and make it update its data, give it mouse input, and tell it to draw itself (an instance of the pygame surface is given to ... | [
"First of a quick suggestion:\nPeople are much more likely to help you if they don't have to download a zip file, next time just post the code parts you suspect not to work.\nAnyways, problem seems to be in your main loop: \n#Keyboard events\nevents = pygame.event.get()\nfor event in events:\n if event.type == ... | [
6
] | [] | [] | [
"draw",
"pygame",
"python"
] | stackoverflow_0004235381_draw_pygame_python.txt |
Q:
SQLAlchemy declarative one-to-many not defined error
I'm trying to figure how to define a one-to-many relationship using SQLAlchemy's declarative ORM, and trying to get the example to work, but I'm getting an error that my sub-class can't be found (naturally, because it's declared later...)
InvalidRequestError: W... | SQLAlchemy declarative one-to-many not defined error | I'm trying to figure how to define a one-to-many relationship using SQLAlchemy's declarative ORM, and trying to get the example to work, but I'm getting an error that my sub-class can't be found (naturally, because it's declared later...)
InvalidRequestError: When initializing mapper Mapper|Parent|parent, expression '... | [
"Here's how I do it:\nfrom sqlalchemy import create_engine\nfrom sqlalchemy import Column, Integer, ForeignKey\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker, relationship\n\nengine = create_engine('sqlite://', echo=True)\nBase = declarative_base(bind=engine)\nSess... | [
16
] | [] | [] | [
"database",
"python",
"sqlalchemy"
] | stackoverflow_0004234493_database_python_sqlalchemy.txt |
Q:
Google App Engine (Python) - Import Fails
I have a file structure like so:
app.yaml
something/
__init__.py
models.py
test.py
I have URL set up to run tests.py in app.yaml:
...
- url: /test
script: something/test.py
test.py imports models.py
When I try to navigate to http://myapp.appspot.com/test/ I... | Google App Engine (Python) - Import Fails | I have a file structure like so:
app.yaml
something/
__init__.py
models.py
test.py
I have URL set up to run tests.py in app.yaml:
...
- url: /test
script: something/test.py
test.py imports models.py
When I try to navigate to http://myapp.appspot.com/test/ I get the following error:
Error: Server Error
... | [
"inside test.py you can write at the top something like:\nfrom something.models import *\n\nThis will import your models.\nFor corrective code though - the wildcard '*' is not great and you explicitly import the models your using:\nfrom something.models import ModelName, OtherModel\n\nand so on.\n",
"test.py shou... | [
1,
1,
0
] | [] | [] | [
"google_app_engine",
"import",
"python"
] | stackoverflow_0004235591_google_app_engine_import_python.txt |
Q:
How to make python scripts executable on Windows?
Possible Duplicate:
Set up Python on Windows to not type python in cmd
When I use python on Linux, or even Mac OS from command line, I take advantage of the shebang and run some of my scripts directly, like so: ./myScript.py. I do need to give this script executa... | How to make python scripts executable on Windows? |
Possible Duplicate:
Set up Python on Windows to not type python in cmd
When I use python on Linux, or even Mac OS from command line, I take advantage of the shebang and run some of my scripts directly, like so: ./myScript.py. I do need to give this script executable permissions, but that is all.
Now, I just installe... | [
"This sums it up better than I can say it: \nhttp://docs.python.org/faq/windows.html\nMore specifically, check out the 2nd section titled \"How do I make Python scripts executable?\"\n\nOn Windows, the standard Python installer already associates the .py extension with a file type (Python.File) and gives that file ... | [
39
] | [] | [] | [
"python",
"shebang",
"windows"
] | stackoverflow_0004235834_python_shebang_windows.txt |
Q:
All files of a dir in tar as file-like obj
there is a simple way to get all files inside a specifically dir (dir that is in a tar file) one after another as a same file-like object?
TNX
A:
Use TarFile.getmembers() to get all the entries in a tarball, and iterate through them to filter the ones you want. Pass eac... | All files of a dir in tar as file-like obj | there is a simple way to get all files inside a specifically dir (dir that is in a tar file) one after another as a same file-like object?
TNX
| [
"Use TarFile.getmembers() to get all the entries in a tarball, and iterate through them to filter the ones you want. Pass each in turn to TarFile.extractfile() to get a file-like to the entry within the tarball.\n"
] | [
1
] | [] | [] | [
"python",
"tar"
] | stackoverflow_0004235974_python_tar.txt |
Q:
naming of physical quantities in python
I would like to establish a good naming scheme for physical/mathematical quantities used in my simulation code. Consider the following example:
from math import *
class GaussianBeamIntensity(object):
"""
Optical intensity profile of a Gaussian laser beam.
"""
... | naming of physical quantities in python | I would like to establish a good naming scheme for physical/mathematical quantities used in my simulation code. Consider the following example:
from math import *
class GaussianBeamIntensity(object):
"""
Optical intensity profile of a Gaussian laser beam.
"""
def __init__(self, intensity_at_waist_cent... | [
"I think you've already found the good balance. Expressive names are important, so I totally agree with the use of wavelenght instead of lambda as a class attribute. This way the interface remains clear and expressive.\nIn a long formula, though, lambda_ is good choice as shorthand notation, because this is a commo... | [
4,
0
] | [] | [] | [
"coding_style",
"naming",
"python",
"readability",
"scientific_computing"
] | stackoverflow_0004227503_coding_style_naming_python_readability_scientific_computing.txt |
Q:
Generate Tkinter Buttons dynamically
I want to generate n amount of Tkinter Buttons which do different things. I have this code:
import Tkinter as tk
for i in range(boardWidth):
newButton = tk.Button(root, text=str(i+1),
command=lambda: Board.playColumn(i+1, Board.getCurrentPlayer()))
... | Generate Tkinter Buttons dynamically | I want to generate n amount of Tkinter Buttons which do different things. I have this code:
import Tkinter as tk
for i in range(boardWidth):
newButton = tk.Button(root, text=str(i+1),
command=lambda: Board.playColumn(i+1, Board.getCurrentPlayer()))
Board.boardButtons.append(newButton)
If b... | [
"I think the problem is that the lambda is picking up the final value of i after the for loop ends. This should fix that (untested):\nimport Tkinter as tk\n\nfor i in range(boardWidth):\n newButton = tk.Button(root, text=str(i+1),\n command=lambda j=i+1: Board.playColumn(j, Board.getCurrentPla... | [
18,
4
] | [] | [] | [
"button",
"python",
"tkinter",
"user_interface"
] | stackoverflow_0004236182_button_python_tkinter_user_interface.txt |
Q:
Keystroke detection using Python
How is keystroke detection done using Python?
A:
This old discussion in StackOverflow might helpful.
A:
It's not clear from your question what problem you are trying to solve. However, there is a Python FAQ (with a stock answer) that should have you on your way: How do I get a ... | Keystroke detection using Python | How is keystroke detection done using Python?
| [
"This old discussion in StackOverflow might helpful.\n",
"It's not clear from your question what problem you are trying to solve. However, there is a Python FAQ (with a stock answer) that should have you on your way: How do I get a single keypress at a time?.\n"
] | [
2,
0
] | [] | [] | [
"python"
] | stackoverflow_0003013057_python.txt |
Q:
Is the cc recipients in a received email a Python list? (Google App Engine)
I am trying to pull the cc'ed email addresses from received email. I am working in the development server.
The tutorial says that "cc contains a list of the cc recipients." But it seems that message.cc returns a string. I am just using the... | Is the cc recipients in a received email a Python list? (Google App Engine) | I am trying to pull the cc'ed email addresses from received email. I am working in the development server.
The tutorial says that "cc contains a list of the cc recipients." But it seems that message.cc returns a string. I am just using the code I copied from the cookbook:
class ReceiveEmail(InboundMailHandler):
def... | [
"Try:\ncc_list = message.cc.split(',')\n\n",
"cc\nA recipient's email address (a string) or a list of email addresses to appear on the Cc: line in the message header.\nMessage Fields\ncc is a string \nmessage.cc.split(\", \")[0] is \"cc12@example.com\" that you want.\n"
] | [
1,
0
] | [] | [] | [
"google_app_engine",
"python",
"regex"
] | stackoverflow_0004236087_google_app_engine_python_regex.txt |
Q:
python: module has no attribute mechanize
#!/usr/bin/env python
import mechanize
mech = mechanize.Browser()
page = br.open(SchoolRank('KY'))
Gives:
Traceback (most recent call last):
File "mechanize.py", line 2, in <module>
import mechanize
File "/home/jcress/Documents/programming/schooldig/trunk/mechan... | python: module has no attribute mechanize | #!/usr/bin/env python
import mechanize
mech = mechanize.Browser()
page = br.open(SchoolRank('KY'))
Gives:
Traceback (most recent call last):
File "mechanize.py", line 2, in <module>
import mechanize
File "/home/jcress/Documents/programming/schooldig/trunk/mechanize.py", line 12, in <module>
mech = mechan... | [
"Change your filename away from mechanize.py. Python is importing your file as the module.\n"
] | [
18
] | [] | [] | [
"attributes",
"mechanize_python",
"module",
"python"
] | stackoverflow_0004236365_attributes_mechanize_python_module_python.txt |
Q:
which more secure to build web apps with, php or python?
which programming language is more secure to build web apps with, php or python?
A:
This has little to do with the language, and much to do with the code.
| which more secure to build web apps with, php or python? | which programming language is more secure to build web apps with, php or python?
| [
"This has little to do with the language, and much to do with the code.\n"
] | [
11
] | [] | [] | [
"php",
"programming_languages",
"python",
"web_applications"
] | stackoverflow_0004236416_php_programming_languages_python_web_applications.txt |
Q:
django apache mod-wsgi hangs on importing a python module from .so file
I'm trying to deploy a django application for production on apache mod-wsgi. I have a third party python application called freecad which packages python module in an FreeCAD.so library file. Requests hang on 'import FreeCAD'. Some apache log ... | django apache mod-wsgi hangs on importing a python module from .so file | I'm trying to deploy a django application for production on apache mod-wsgi. I have a third party python application called freecad which packages python module in an FreeCAD.so library file. Requests hang on 'import FreeCAD'. Some apache log errors tell me that it might be problem with zlib?? compression when trying t... | [
"Set:\nWSGIApplicationGroup %{GLOBAL}\n\nSee the application issues document on mod_wsgi wiki.\nMost likely you have an extension module not designed to work in sub interpreter. The above forces it to run in main interpreter.\n"
] | [
26
] | [] | [] | [
"django",
"module",
"python",
"wsgi"
] | stackoverflow_0004236045_django_module_python_wsgi.txt |
Q:
IndexError: list index out of range (in query results)
I am having problems understanding how to work with query results. I asked about half a dozen questions about this but I still do not understand. I copy from previous code and I make it work somehow but since I don't understand the underlying concept the code ... | IndexError: list index out of range (in query results) | I am having problems understanding how to work with query results. I asked about half a dozen questions about this but I still do not understand. I copy from previous code and I make it work somehow but since I don't understand the underlying concept the code breaks down if I make a minor change. I would really appreci... | [
"To understand the code break it down and look at it piece by piece:\nclass ReceiveEmail(InboundMailHandler):\n def receive(self, message):\n logging.info(\"Received email from %s\" % message.sender)\n\n # Get a list of CC addresses. This is basically a for loop.\n cc_addresses = [address.s... | [
1
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0004236427_google_app_engine_python.txt |
Q:
Best way to iterate through entries delimited by two keywords?
Text File contents:
&CRB A='test1' B=123,345, 678 &END
Misc text potentially between entries ...
&CRB A='test2'
B=788, 345, 3424 &END
&CRB A='test3'
B=788, 345, 3424 &END
&CRB A='test4' B=788, 345, 3424 &EN... | Best way to iterate through entries delimited by two keywords? | Text File contents:
&CRB A='test1' B=123,345, 678 &END
Misc text potentially between entries ...
&CRB A='test2'
B=788, 345, 3424 &END
&CRB A='test3'
B=788, 345, 3424 &END
&CRB A='test4' B=788, 345, 3424 &END
What is the most efficient way to iterate through the entries bet... | [
"Assuming that the entry is all of the text between &CRB and &END pairs, you can pull out the text between them with something like this:\nimport re\n\n# the regular expression treats newlines as a regular character, so the\n# multiline entries are okay. It's non-greedy, so it gets individual entries.\npat = re.com... | [
4,
1,
0
] | [] | [] | [
"python",
"string"
] | stackoverflow_0004233250_python_string.txt |
Q:
Is there a better way to do this python code?
Looking at this snippet of python code I wrote:
return map(lambda x: x[1],
filter(lambda x: x[0] == 0b0000,
my_func(i)
)
)
(Hoping it's self-explanatory)
I'm wondering if python has a better way to do it?
I le... | Is there a better way to do this python code? | Looking at this snippet of python code I wrote:
return map(lambda x: x[1],
filter(lambda x: x[0] == 0b0000,
my_func(i)
)
)
(Hoping it's self-explanatory)
I'm wondering if python has a better way to do it?
I learned python several months ago, wrote a couple scr... | [
"I think you want a list comprehension:\n[x[1] for x in my_func(i) if x[0] == 0]\n\nList comprehensions are an extremely common Python idiom.\n",
"You could use something like:\nreturn [x[1] for x in my_func(i) if x[0] == 0b0000]\n\nMany people would call that \"better\" as its a little shorter and more obvious.\... | [
9,
2,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0004230689_python.txt |
Q:
How can I express this query in sqlalchemy ORM?
Here is my SQL query:
select survey_spec.survey_spec_id, cr.login as created_by, installed_at, req.login as requested_by, role
from survey_spec
join (select survey_spec_id, role, max(installed_at) as installed_at from survey_installation_history group by 1, 2... | How can I express this query in sqlalchemy ORM? | Here is my SQL query:
select survey_spec.survey_spec_id, cr.login as created_by, installed_at, req.login as requested_by, role
from survey_spec
join (select survey_spec_id, role, max(installed_at) as installed_at from survey_installation_history group by 1, 2) latest using (survey_spec_id)
left join sur... | [
"Do you have the example output of what you have got so far? i.e. the output of:\nprint survey_spec.query.filter(survey_spec.survey_id==survey_id).options(\n eagerload(...))\n\nIf you just want to load up your entities, you could bypass the SQL generation and load from your given literal SQL, something alo... | [
1
] | [] | [] | [
"python",
"sql",
"sqlalchemy"
] | stackoverflow_0004228825_python_sql_sqlalchemy.txt |
Q:
Combine model data with list of objects
I have a list of objects :
film_hc = [{'count': 2, 'pk': '33'},
{'count': 1, 'pk': '37'},
{'count': 1, 'pk': '49'}]
The 'pk' value is the primary key for a record in a model. I would like to add the name field of that record to this list of objects. ... | Combine model data with list of objects | I have a list of objects :
film_hc = [{'count': 2, 'pk': '33'},
{'count': 1, 'pk': '37'},
{'count': 1, 'pk': '49'}]
The 'pk' value is the primary key for a record in a model. I would like to add the name field of that record to this list of objects. To get one name, I can use:
record = Film.obj... | [
"To avoid hitting the database multiple times, I recommend you use the in_bulk queryset method. This takes a list of IDs, and returns a dictionary of ID mapped to model instance. So what you need to do is to run through your list of dictionaries first to extract the ID values, then do the query, then run through ag... | [
1
] | [] | [] | [
"django",
"python",
"zip"
] | stackoverflow_0004236779_django_python_zip.txt |
Q:
Plotting time against size of input for Longest Common Subsequence Problem
I wish to plot the time against size of input, for Longest common subsequence problem in recursive as well as dynamic programming approaches. Until now I've developed programs for evaluating lcs functions in both ways, a simple random strin... | Plotting time against size of input for Longest Common Subsequence Problem | I wish to plot the time against size of input, for Longest common subsequence problem in recursive as well as dynamic programming approaches. Until now I've developed programs for evaluating lcs functions in both ways, a simple random string generator(with help from here) and a program to plot the graph. Now I need to ... | [
"If the data being passed from program to program is small and can be converted to character format, you can pass it as one or more command-line arguments. If not you can write it to a file and pass its name as a argument.\nFor Python programs many people use the timeit module's Timer class to measure code executio... | [
0,
0
] | [] | [] | [
"c",
"lcs",
"python"
] | stackoverflow_0004237384_c_lcs_python.txt |
Q:
Regular expression further checking
I am working with a regular expression that would check a string,Is it a function or not.
My regular expression for checking that as follows:
regex=r' \w+[\ ]*\(.*?\)*'
It succefully checks whether the string contains a function or not.
But it grabs normal string which contains... | Regular expression further checking | I am working with a regular expression that would check a string,Is it a function or not.
My regular expression for checking that as follows:
regex=r' \w+[\ ]*\(.*?\)*'
It succefully checks whether the string contains a function or not.
But it grabs normal string which contains firs barcket value,such as "test (meanin... | [
"(\\w+\\([^)]*\\))(\\s+|$)\n\nBascially you make sure it ends with either spaces or end of line.\nBTW the kiki tool is very useful for debugging Python re: http://code.google.com/p/kiki-re/\n",
"regex=r'\\w+\\([\\w,]+\\)(?:\\s+|$)'\n\n",
"\nI have solved the problem at first I just chexked for the string that h... | [
1,
0,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0004236513_python_regex.txt |
Q:
Is it possible to check that a list is not empty before grabbing the first element using as few lines as possible in Python?
I keep having to do this operation all over the place in my python code. I'm willing to bet there is an easier (aka one-line) way to do this.
results = getResults()
if len(results) > 0:
... | Is it possible to check that a list is not empty before grabbing the first element using as few lines as possible in Python? | I keep having to do this operation all over the place in my python code. I'm willing to bet there is an easier (aka one-line) way to do this.
results = getResults()
if len(results) > 0:
result = results[0]
I actually don't need "results" anywhere else, and I should only run "getResults" once.
Any ideas?
| [
"You haven't specified what result should be if results is empty, but this is one option (assuming Python 2.6 or greater):\nresult = results[0] if results else None\n\n",
"result = len(results) and results[0] or None. In case if results[0] is not 0, or False, or any empty container [], (), '', {}, set(), ....\n",... | [
8,
2,
1,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0004237422_python.txt |
Q:
Python: How can you access an object or dictionary interchangeably?
I'm writing a Django view that sometimes gets data from the database, and sometimes from an external API.
When it comes from the database, it is a Django model instance. Attributes must be accessed with dot notation.
Coming from the API, the data ... | Python: How can you access an object or dictionary interchangeably? | I'm writing a Django view that sometimes gets data from the database, and sometimes from an external API.
When it comes from the database, it is a Django model instance. Attributes must be accessed with dot notation.
Coming from the API, the data is a dictionary and is accessed through subscript notation.
In either cas... | [
"In JavaScript they're equivalent (often useful; I mention it in case you didn't know as you're doing web development), but in Python they're different - [items] versus .attributes.\nIt's easy to write something which allows access through attributes, using __getattr__:\nclass AttrDict(dict):\n def __getattr__(s... | [
6,
6,
2
] | [] | [] | [
"dictionary",
"django",
"object",
"python"
] | stackoverflow_0004237541_dictionary_django_object_python.txt |
Q:
run a function (from a .py file) from a linux console
maybe the title is not very clear, let me elaborate.
I have a python script that open a ppm file , apply a chosen filter(rotations...) and create a new picture. until here everything work fine.
but I want to do the same thing through a linux console like:
ppmfi... | run a function (from a .py file) from a linux console | maybe the title is not very clear, let me elaborate.
I have a python script that open a ppm file , apply a chosen filter(rotations...) and create a new picture. until here everything work fine.
but I want to do the same thing through a linux console like:
ppmfilter.py ROTD /path/imageIn.ppm /path/imageOut.ppm
here R... | [
"There is a relatively easy way:\nYou can determine the global names (functions, variables, etc.) with the use of 'globals()'. This gives you a dictionary of all global symbols. You'll just need to check the type (with type() and the module types) and if it's a function, you can call it with sys.argv:\nimport types... | [
7,
1,
1,
0
] | [] | [] | [
"console",
"ppm",
"python"
] | stackoverflow_0004237749_console_ppm_python.txt |
Q:
problem with a 2 dimensional array(list of list of dict)
cell={'num':0,'state':1}
cell_2d=[]
cell_list=[]
for i in range(2):
for j in range(2):
cell_list=cell_list+[cell]
cell_2d=cell_2d+[cell_list]
cell_list=[]
print "initially:"
print cell_2d
cell_2d[0][0]['num']=-1
print "finally:"
print cell_2d
Outp... | problem with a 2 dimensional array(list of list of dict) | cell={'num':0,'state':1}
cell_2d=[]
cell_list=[]
for i in range(2):
for j in range(2):
cell_list=cell_list+[cell]
cell_2d=cell_2d+[cell_list]
cell_list=[]
print "initially:"
print cell_2d
cell_2d[0][0]['num']=-1
print "finally:"
print cell_2d
Output obtained is:
initially:
[[{'state': 1, 'num': 0}, {'state':... | [
"OK, I see it. You're reusing the cell object. Because Python uses references, you're just making four references to the same object, so when you change one, you change them all.\nInside your inner loop, try:\ncell_list = cell_list + [{'num':1, 'state':0}]\n\nWhich can be shortened to:\ncell_list.append({'num':1, '... | [
2,
0
] | [] | [] | [
"python"
] | stackoverflow_0004237824_python.txt |
Q:
Python Qt: embedded html bug?
Here is a strange thing that is happening... I have used embedded html with Qt Python to display a form inside the GUI/Widget. The problem is, if the cell has more content, it shows a black shadow like a box on the right side of that cell/table.
Here is an example of the code working ... | Python Qt: embedded html bug? | Here is a strange thing that is happening... I have used embedded html with Qt Python to display a form inside the GUI/Widget. The problem is, if the cell has more content, it shows a black shadow like a box on the right side of that cell/table.
Here is an example of the code working fine:
html += ("<BR><BR><table ... | [
"If this is an exact snippet from you code then problem may be connected with the fact that you don't have closing </b> tag. If that doesn't help try removing <div> and adding align='center' to <td>\n"
] | [
0
] | [] | [] | [
"html",
"html_table",
"python",
"qt"
] | stackoverflow_0002130705_html_html_table_python_qt.txt |
Q:
Django url problem
I'm getting this error
error at /
unknown specifier: ?P&
and I suppose it's coming from this line
(r'^(?P<template>\w+)/$', static_page),
I copied this from a tutorial, how do I fix this error ?
A:
You want to use
r'^(?P<template>\w+)/$'
for your regex. You seem to have copied the ... | Django url problem | I'm getting this error
error at /
unknown specifier: ?P&
and I suppose it's coming from this line
(r'^(?P<template>\w+)/$', static_page),
I copied this from a tutorial, how do I fix this error ?
| [
"You want to use\nr'^(?P<template>\\w+)/$'\n\nfor your regex. You seem to have copied the regex with HTML entities still encoded; the regex engine expects verbatim < and >.\n"
] | [
2
] | [] | [] | [
"django",
"python",
"regex",
"url"
] | stackoverflow_0004237805_django_python_regex_url.txt |
Q:
Python: max/min builtin functions depend on parameter order
max(float('nan'), 1) evaluates to nan
max(1, float('nan')) evaluates to 1
Is it the intended behavior?
Thanks for the answers.
max raises an exception when the iterable is empty. Why wouldn't Python's max raise an exception when nan is present? Or at lea... | Python: max/min builtin functions depend on parameter order | max(float('nan'), 1) evaluates to nan
max(1, float('nan')) evaluates to 1
Is it the intended behavior?
Thanks for the answers.
max raises an exception when the iterable is empty. Why wouldn't Python's max raise an exception when nan is present? Or at least do something useful, like return nan or ignore nan. The curren... | [
"In [19]: 1>float('nan')\nOut[19]: False\n\nIn [20]: float('nan')>1\nOut[20]: False\n\nThe float nan is neither bigger nor smaller than the integer 1.\nmax starts by choosing the first element, and only replaces it when it finds an element which is strictly larger.\nIn [31]: max(1,float('nan'))\nOut[31]: 1\n\nSince... | [
49,
9,
1
] | [] | [] | [
"comparison",
"math",
"python"
] | stackoverflow_0004237914_comparison_math_python.txt |
Q:
Security Web programming API in Python
Is there a secure API available which will help protect against attacks like XSS, CSRF etc by providing encoders, token support etc.? for python which can be used with google app engine?
I do not want to reinvent the wheel by coding it all again if its already out there .
A:... | Security Web programming API in Python | Is there a secure API available which will help protect against attacks like XSS, CSRF etc by providing encoders, token support etc.? for python which can be used with google app engine?
I do not want to reinvent the wheel by coding it all again if its already out there .
| [
"Python Security is a good resource:\n\nAccess Control/Authorization\nAuthentication\nConfiguration\nCross-Site Request Forgery (CSRF)\nCross-Site Scripting (XSS) \nCryptography\nEscaping\nHashing\nInjection\nObject Reference\nRedirects\nSession Management\nTaint Mode\nTransport Layer Security\nValidation\n\n"
] | [
5
] | [] | [] | [
"api",
"google_app_engine",
"python",
"security"
] | stackoverflow_0004238112_api_google_app_engine_python_security.txt |
Q:
Encoding problem in Google AppEngine when BlobstoreUploadHandler
I am seeing weird characters in the datastore when reading them in BlobstoreUploadHandler. The problem is only on Google servers, everything works great on the development server.
This usually works:
item = models.Item()
item.description = self.reque... | Encoding problem in Google AppEngine when BlobstoreUploadHandler | I am seeing weird characters in the datastore when reading them in BlobstoreUploadHandler. The problem is only on Google servers, everything works great on the development server.
This usually works:
item = models.Item()
item.description = self.request.get("description")
item.put()
However, if this is within a Blobsto... | [
"It's a known bug, check Blobstore handler breaking data encoding issue.\nPerforming a POST to a Blobstore handler, test fields are getting converted to MIME quoted printable format.\nI think you could workaround this using quopri Python standard module.\n"
] | [
1
] | [] | [] | [
"google_app_engine",
"python",
"unicode"
] | stackoverflow_0004235992_google_app_engine_python_unicode.txt |
Q:
Mechanize for Python 3.x
is there any way how to use Mechanize with Python 3.x?
Or is there any substitute which works in Python 3.x?
I've been searching for hours, but I didn't find anything :(
I'm looking for way how to login to the site with Python, but the site uses javascript.
Thanks in advance,
Adam.
A:
lx... | Mechanize for Python 3.x | is there any way how to use Mechanize with Python 3.x?
Or is there any substitute which works in Python 3.x?
I've been searching for hours, but I didn't find anything :(
I'm looking for way how to login to the site with Python, but the site uses javascript.
Thanks in advance,
Adam.
| [
"lxml.html provides form handling facilities and supports Python 3.\n",
"I'm working on a similar project, but the faq for mechanize explicitly says they don't intend on supporting 3x any time soon. Is there a reason the code has to be written in 3? \nThe way I'm trying to tackle the problem is by emulating the ... | [
3,
0
] | [] | [] | [
"authentication",
"mechanize",
"python",
"screen",
"screen_scraping"
] | stackoverflow_0004237164_authentication_mechanize_python_screen_screen_scraping.txt |
Q:
TypeError coercing to Unicode: need string or buffer
In a Django project, I am trying to pass the url to a want instance. Comments are applied to a Want. I have been trying to figure out this error but am stumped.
This function:
def comment_email(request, comment, **kwargs):
want = get_object_or_404(... | TypeError coercing to Unicode: need string or buffer | In a Django project, I am trying to pass the url to a want instance. Comments are applied to a Want. I have been trying to figure out this error but am stumped.
This function:
def comment_email(request, comment, **kwargs):
want = get_object_or_404(Want, id=comment.object_pk)
url = want.get_absolu... | [
"I think the problem is\ndef __unicode__(self):\n return self\n\nwhich should return a unicode string rather than a \"Want\" instance. I'm not sure what you want there instead -- maybe \"self.id\"\n"
] | [
7
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0004237324_django_django_models_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.