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:
Controlling input/output of Python interactive shell
I have to evaluate (millions of) Python expressions e.g. (int(a) >> 8 == 4) and b
in my OCaml program. There is pycaml but I failed to get it working.
So I turned to another idea: control the input/output of Python interpreter directly.
Ideally I would like to i... | Controlling input/output of Python interactive shell | I have to evaluate (millions of) Python expressions e.g. (int(a) >> 8 == 4) and b
in my OCaml program. There is pycaml but I failed to get it working.
So I turned to another idea: control the input/output of Python interpreter directly.
Ideally I would like to intercept both the input/output of the interpreter itself.
... | [
"I'm not going to comment on the weirdness of the entire concept (driving python to evaluate expressions from o'caml) but it seems like you might want to look into writing a python program that is an eval cycle that reads/writes a string from/to a pipe. Look up the eval command.\n",
"You can supply a command to t... | [
3,
2
] | [] | [] | [
"ocaml",
"pipe",
"python",
"redirect",
"stdout"
] | stackoverflow_0006326190_ocaml_pipe_python_redirect_stdout.txt |
Q:
root.after causes Tkinter application to stop working
def colision(self):
if self.coords(self.bola)[1]<50:
self.boladir=1
if self.coords(self.bola)[1]>870:
self.jugando=0
self.pierde()
# ladrillos=self.find_withtag("brick")
def mueve_bola(self):
... | root.after causes Tkinter application to stop working | def colision(self):
if self.coords(self.bola)[1]<50:
self.boladir=1
if self.coords(self.bola)[1]>870:
self.jugando=0
self.pierde()
# ladrillos=self.find_withtag("brick")
def mueve_bola(self):
if self.jugando:
if self.boladir==0:
... | [
"colision calls itself via after, so when the game starts this will be called every 20 ms. mueve_bola also calls itself every 20ms. However,mueve_bola_also_ callscolision. So, every 20ms,colisioncreates another unending stream of calls to itself every 20ms. 20 ms latermueve_bolacallscolisionagain, which again start... | [
1
] | [] | [] | [
"canvas",
"python",
"tkinter"
] | stackoverflow_0006323814_canvas_python_tkinter.txt |
Q:
In Django, how does one override an object's delete() function?
I am trying to create an application in which users are locked out from logging in due to too many failed login attempts.
To this end, if there are 5 failed logins within 5 minutes, a Lockout object is created, and the user is deactivated (is_active=F... | In Django, how does one override an object's delete() function? | I am trying to create an application in which users are locked out from logging in due to too many failed login attempts.
To this end, if there are 5 failed logins within 5 minutes, a Lockout object is created, and the user is deactivated (is_active=False).
However, when this Lockout object is deleted, the user should ... | [
"That's the correct way to do it. The problem you're having is that you're trying to delete via a QuerySet, which does not invoke the model methods. You will need to .filter(), then iterate through it calling .delete() on each model.\nBut it would probably be easier to create a new auth backend that checked for a l... | [
3
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0006326263_django_django_models_python.txt |
Q:
Python Packaging - Distutils for a program
I understand distutils is the defacto standard for the module installation world, using the common
setup.py install
But what if I don't want to install my program as a module but instead as a program, that can be executed by the user?
If I'm not being clear I'm very sor... | Python Packaging - Distutils for a program | I understand distutils is the defacto standard for the module installation world, using the common
setup.py install
But what if I don't want to install my program as a module but instead as a program, that can be executed by the user?
If I'm not being clear I'm very sorry but feel free to ask more questions.
Thanks!
| [
"I'd hope that you're structuring your code so that the bulk of it is modular and could be imported into other code. In that structure than your application is a wrapper between the program's command-line and/or other user interfaces and the functionality provided by your modules.\nThat said, here's a pointer to t... | [
3,
1
] | [] | [] | [
"distutils",
"installation",
"python"
] | stackoverflow_0006325787_distutils_installation_python.txt |
Q:
Automating file downloads with Javascript URLs using Python
I was assigned to automate the download of several csv files from a site heavily encoded in Javascript (https://www.quantcast.com/download/plannerCSV?&d0Id=01&sc=1&mr=10000&rs2=-1). There is a convenient 'download' button that prompts the download, the UR... | Automating file downloads with Javascript URLs using Python | I was assigned to automate the download of several csv files from a site heavily encoded in Javascript (https://www.quantcast.com/download/plannerCSV?&d0Id=01&sc=1&mr=10000&rs2=-1). There is a convenient 'download' button that prompts the download, the URL of which I found using Firebug:
https://www.quantcast.com/downl... | [
"Does appending a dummy GET variable work? For some things -- the obvious one to me is the Google Code wiki regarding image files -- they require a file extension and achieve that by passing GET variables that won't be used by the server. Something like:\nhttps://www.quantcast.com/download/plannerCSV?&d0Id=10&sc=1&... | [
0,
0
] | [] | [] | [
"download",
"javascript",
"python",
"urllib2"
] | stackoverflow_0006326367_download_javascript_python_urllib2.txt |
Q:
How do I convert a file stream to a data URI in Python?
I have a file stream of an image in Python:
\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x04\x87...
How do I convert this to a data URI?
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAU...'
A:
Encode it in base64, then remove the newlines.
>>> '\x89PNG\... | How do I convert a file stream to a data URI in Python? | I have a file stream of an image in Python:
\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x04\x87...
How do I convert this to a data URI?
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAU...'
| [
"Encode it in base64, then remove the newlines.\n>>> '\\x89PNG\\r\\n\\x1a\\n\\x00\\x00\\x00\\rIHDR\\x00\\x00\\x04\\x87...'.encode('base64').replace('\\n', '')\n'iVBORw0KGgoAAAANSUhEUgAABI....'\n\n"
] | [
6
] | [] | [] | [
"data_uri",
"filestream",
"python",
"stream"
] | stackoverflow_0006326558_data_uri_filestream_python_stream.txt |
Q:
Updating to Python 3 on Kubuntu 11.04 -- do/should I uninstall previous versions?
Is this going to break anything? Is there anything I would need to keep in mind if I do uninstall the older versions?
A:
Personally, I would keep both around (and when upgrading to Ubuntu 11.04, I did). The problem is that there a... | Updating to Python 3 on Kubuntu 11.04 -- do/should I uninstall previous versions? | Is this going to break anything? Is there anything I would need to keep in mind if I do uninstall the older versions?
| [
"Personally, I would keep both around (and when upgrading to Ubuntu 11.04, I did). The problem is that there are still a lot of libs which are only in Python 2.x. The good news is that they are decreasing in number/prominence, but too much relies on the older way of doing things to reliably remove it.\nIf you feel ... | [
4,
3
] | [] | [] | [
"python",
"python_3.x",
"ubuntu"
] | stackoverflow_0006326279_python_python_3.x_ubuntu.txt |
Q:
Python void/null function
Python noob so I might be going about this the wrong way
I want to use a try/except block to find if a value in a dict isn't set like
try:
if entry['VALUE1'] == None: void()
if entry['VALUE2'] == None: void()
except KeyError:
print "Values not Found"
Of course the 'void' func... | Python void/null function | Python noob so I might be going about this the wrong way
I want to use a try/except block to find if a value in a dict isn't set like
try:
if entry['VALUE1'] == None: void()
if entry['VALUE2'] == None: void()
except KeyError:
print "Values not Found"
Of course the 'void' function doesn't exist, is there an... | [
"Try replacing void() with pass.\nOf course, in practice, you can just do if key in some_dict:. But if you ever need a \"do nothing\" in a block, pass is what you're looking for.\n",
"Try:\nif \"VALUE1\" in entry:\n foo()\n\nto determine if the \"VALUE1\" string is in the set of keys of the entry dict.\nYour l... | [
8,
3,
0,
0,
0
] | [] | [] | [
"function",
"python",
"void"
] | stackoverflow_0006326423_function_python_void.txt |
Q:
Tornado and Python 3.x
I really like Tornado and I would like to use it with Python 3, though it is written for Python versions 2.5 and 2.6.
Unfortunately it seems like the project's source doesn't come with a test suite. If I understand correctly the WSGI part of it wouldn't be that easy to port as it's spec is n... | Tornado and Python 3.x | I really like Tornado and I would like to use it with Python 3, though it is written for Python versions 2.5 and 2.6.
Unfortunately it seems like the project's source doesn't come with a test suite. If I understand correctly the WSGI part of it wouldn't be that easy to port as it's spec is not ready for Python 3 yet (?... | [
"first of all, I want to apologize for an answer to an outdated topic, \nbut once I found this topic through Google, I want to update important information!\nIn the Tornado 2.0 adds support for Python 3.2!\nhttps://github.com/facebook/tornado/blob/master/setup.py\nhttp://groups.google.com/group/python-tornado/brows... | [
25,
13,
4
] | [] | [] | [
"asynchronous",
"python",
"python_3.x",
"tornado",
"wsgi"
] | stackoverflow_0001780303_asynchronous_python_python_3.x_tornado_wsgi.txt |
Q:
Python- Possible English one-word anagrams given input letters
I know variations of this have been asked before, but I was unable to understand any of the previous implementations because most of them involved using sets and the issubset method.
Here is what I am trying to do: I have a set of words in a dictionary... | Python- Possible English one-word anagrams given input letters | I know variations of this have been asked before, but I was unable to understand any of the previous implementations because most of them involved using sets and the issubset method.
Here is what I am trying to do: I have a set of words in a dictionary and a list of possible letters. I want to find if the members of t... | [
"To know if you can make a word out of a set of letters [oops, I did it myself -- I meant 'collection'!], you want every letter to occur at least the right number of times, so I think we're going to have to work the counts in there somehow. By definition, Python sets don't care about the number of elements in a so... | [
5,
1,
0
] | [] | [] | [
"anagram",
"list",
"membership",
"python",
"set"
] | stackoverflow_0006326620_anagram_list_membership_python_set.txt |
Q:
Python/Django to PHP transition ? Wrong learning Curve?
I have been coding in python/django and c/c++ from last three years for various web-based and desktop applications in my previous companies. While following the general learning curve, I started working on functional programming languges like Haskell/Erlang. ... | Python/Django to PHP transition ? Wrong learning Curve? | I have been coding in python/django and c/c++ from last three years for various web-based and desktop applications in my previous companies. While following the general learning curve, I started working on functional programming languges like Haskell/Erlang. But recently I switched to a company where the programming la... | [
"\nIf you must do step down to php, at least use one of the good available MVC frameworks with an ORM:\n\nZend Framework\nSymfony\nMore: https://stackoverflow.com/questions/2648/what-php-framework-would-you-choose-for-a-new-application-and-why\n\nAdopt the good parts of using the framework: Don't forget to write t... | [
3
] | [] | [] | [
"django",
"php",
"programming_languages",
"python"
] | stackoverflow_0006327041_django_php_programming_languages_python.txt |
Q:
Ninja-IDE for Django or Python
I'm looking for a good IDE to programming with Python, I found this http://ninja-ide.org/.
Did anyone try Ninja-IDE to programming Python or Django Apps, any suggestions about its use?
A:
I personally use Netbeans for Python development mostly because I also use it for PHP and Java... | Ninja-IDE for Django or Python | I'm looking for a good IDE to programming with Python, I found this http://ninja-ide.org/.
Did anyone try Ninja-IDE to programming Python or Django Apps, any suggestions about its use?
| [
"I personally use Netbeans for Python development mostly because I also use it for PHP and Java development. It works quite well for Python.\n",
"I prefer Aptana Studio 3, try it here!\n"
] | [
0,
-1
] | [] | [] | [
"django",
"ide",
"python"
] | stackoverflow_0006326972_django_ide_python.txt |
Q:
Python - class object initialization within function
The code below works (it will eventually pull records from a database via SQL), but I am having trouble understanding why the assert statement in the code below works.
def build_row(table, cols):
"""Build a class that creates instances of specific rows"""
... | Python - class object initialization within function | The code below works (it will eventually pull records from a database via SQL), but I am having trouble understanding why the assert statement in the code below works.
def build_row(table, cols):
"""Build a class that creates instances of specific rows"""
class DataRow:
"""Generic data row class, specia... | [
"data is given a value when you instantiate the class returned by the build_row() function.\nIt is not guaranteed to be the same length as self.cols; perhaps you never instantiate the class, and so never see an error.\n",
"This may make more sense to you if you replace the references to self.cols and self.table w... | [
1,
1,
0
] | [] | [] | [
"initialization",
"python",
"python_3.x"
] | stackoverflow_0006326370_initialization_python_python_3.x.txt |
Q:
upload an excel file and read the data
In my application, I uploaded an excel file and trying to read the data.
I am trying in following way,
@expose()
def save(self, **params):
xls_file = params['xls_file']
wb = xlrd.open_workbook(bill_file,'w')
sh = wb.sheet_by_index(0)
for i,rownum in enumerate(... | upload an excel file and read the data | In my application, I uploaded an excel file and trying to read the data.
I am trying in following way,
@expose()
def save(self, **params):
xls_file = params['xls_file']
wb = xlrd.open_workbook(bill_file,'w')
sh = wb.sheet_by_index(0)
for i,rownum in enumerate(range(sh.nrows)):
print sh.row_value... | [
"enumerate() is already returning pairs (index, item). The range() call is completely unnecessary.\n"
] | [
0
] | [] | [] | [
"python"
] | stackoverflow_0006327430_python.txt |
Q:
Python PIL save file with datetime as name
I'm relatively new to python and know very little syntax, but I'm willing to learn as much as possible. Simply put I want to use the save feature in PIL to save a .png with the file's name being the current date and time. This may be complicated by the fact that I'm not u... | Python PIL save file with datetime as name | I'm relatively new to python and know very little syntax, but I'm willing to learn as much as possible. Simply put I want to use the save feature in PIL to save a .png with the file's name being the current date and time. This may be complicated by the fact that I'm not using PIL directly, but through the Videocapture ... | [
"'C:\\Users\\Myname\\Dropbox\\Foldes\\image.png'\n\nIn strings in Python, backslashes have special meaning so you need to treat them differently. You can either use two of them instead of one...\n'C:\\\\Users\\\\Myname\\\\Dropbox\\\\Foldes\\\\image.png'\n\n...or you can put an r before the string (as long as it doe... | [
9
] | [] | [] | [
"datetime",
"python",
"python_imaging_library",
"video_capture"
] | stackoverflow_0006327498_datetime_python_python_imaging_library_video_capture.txt |
Q:
What does data.strip() with XML mean in Python?
I do not understand the end of this statement:
print node.getElementsByTagName(`author')[0].childNodes[0].data.strip()
What does data.strip() do in this statement?
A:
It removes extra whitespace from the beginning and end of the string. This is not XML-specific, b... | What does data.strip() with XML mean in Python? | I do not understand the end of this statement:
print node.getElementsByTagName(`author')[0].childNodes[0].data.strip()
What does data.strip() do in this statement?
| [
"It removes extra whitespace from the beginning and end of the string. This is not XML-specific, but is a general string method in Python which you can find in the documentation here.\n",
"Return a copy of the string with leading and trailing characters removed (defaulting to removing whitespace characters)\nhttp... | [
7,
3
] | [] | [] | [
"python",
"string",
"xml"
] | stackoverflow_0006327675_python_string_xml.txt |
Q:
How can I write code in Java/ASP.NEt/Python for using a component based library written in PHP?
I have a component based library which is completely written in PHP and works like a charm.
A sample snippet of the code is :
<?php
require_once 'lib/my_class_file.php';
$variable1 = "some-value";
$variable2 = "some-v... | How can I write code in Java/ASP.NEt/Python for using a component based library written in PHP? | I have a component based library which is completely written in PHP and works like a charm.
A sample snippet of the code is :
<?php
require_once 'lib/my_class_file.php';
$variable1 = "some-value";
$variable2 = "some-value";
$new_variable = ClassName::newInstance(.....);
$new_variable->method_call($args);
?>
Now, ... | [
"A web service will be the common answer for your problem. In the past SOAP was popular - you can still use it, but it's probably better to use a simple REST server, or even better, use Thrift as a generic scalable solution. To use it, you first need to describe your data structures for your parameters and return... | [
1
] | [] | [] | [
"asp.net",
"code_conversion",
"java",
"php",
"python"
] | stackoverflow_0006295838_asp.net_code_conversion_java_php_python.txt |
Q:
Scope of lists in Python - Project Euler 007
first question here. I am trying to learn python by stepping through project euler, and I've run into a roadblock. The following method (returns a list of prime factors) works fine for a single call:
def findPrimeFactors(num, primeFactors = []):
'''Find the prime fa... | Scope of lists in Python - Project Euler 007 | first question here. I am trying to learn python by stepping through project euler, and I've run into a roadblock. The following method (returns a list of prime factors) works fine for a single call:
def findPrimeFactors(num, primeFactors = []):
'''Find the prime factors of an arbitrary positive integer
in... | [
"See \"Least Astonishment\" and the Mutable Default Argument\n",
"The default value of primeFactors is being shared between calls, so when you change it, it stays changed for future calls.\nExample:\ndef foo(bar = []):\n bar.append(1)\n return bar\n\nprint foo()\nprint foo()\n\nOutput:\n[1]\n[1, 1]\n\nYou s... | [
3,
1,
1
] | [] | [] | [
"list",
"primes",
"python",
"scope"
] | stackoverflow_0006327087_list_primes_python_scope.txt |
Q:
Web session in pure python
I am creating a web site using python and html/css. I am not using any web framework just using pure python.
I want to implement session in this site but cant find appropriate code/example for it. Please somebody help me out in this.
If possible can you please send me a code or link.
A:... | Web session in pure python | I am creating a web site using python and html/css. I am not using any web framework just using pure python.
I want to implement session in this site but cant find appropriate code/example for it. Please somebody help me out in this.
If possible can you please send me a code or link.
| [
"Python has a Cookie module in its stdlib that allows you to create and manipulate cookies in a server written in Python. Writing a HTTP server in Python is easy - just use BaseHTTPServer - again from the stdlib. With the Cookie module it shouldn't be difficult to implement sessions, since sessions are usually base... | [
1,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0006327180_python.txt |
Q:
HOWTO parse textfile for lines containing expressions of the form VARIABLE=SOMEVALUE
I have a textfile (actually, .xml) that contains certain lines of the form MACAddress=SOMEVALUE, and mixed within other lines. For example, a typical such line is (on a single line):
<Adapter slot="3" enabled="false" MACAddre... | HOWTO parse textfile for lines containing expressions of the form VARIABLE=SOMEVALUE | I have a textfile (actually, .xml) that contains certain lines of the form MACAddress=SOMEVALUE, and mixed within other lines. For example, a typical such line is (on a single line):
<Adapter slot="3" enabled="false" MACAddress="080027671C79" cable="true" speed="0"
type="Am79C973">
N.B. In the line above, SOMEVAL... | [
"It's XML, so use an XML parser. For example:\nfrom xml.dom.minidom import parse\n\nmacs = [adapter.getAttribute(\"MACAddress\") for adapter in\n parse(\"file.xml\").getElementsByTagName(\"Adapter\")]\n\n",
"Not sure that i correctly know what is MAC address but please fine two more options below:\nInput:\... | [
4,
0,
0
] | [] | [] | [
"parsing",
"python",
"xml"
] | stackoverflow_0006308681_parsing_python_xml.txt |
Q:
What dependencies are required for Python to avoid UnicodeDecodeError?
I am using the Plone collective's Python buildout. It builds various versions of Python including 2.6 and 2.7.
For some reason, when I try to do a release with 2.7 I get this error:
$ /Users/aclark/Developer/collective/python/python-2.7/bin/mkr... | What dependencies are required for Python to avoid UnicodeDecodeError? | I am using the Plone collective's Python buildout. It builds various versions of Python including 2.6 and 2.7.
For some reason, when I try to do a release with 2.7 I get this error:
$ /Users/aclark/Developer/collective/python/python-2.7/bin/mkrelease -T -d local
…
adding 'plonetheme.grungeera-0.1.1/plonetheme.grungeera... | [
"Here is what I think differs: The version of docutils in both python installations.\nThere is still constant work being done on the docutils package and that project releases the current Subversion HEAD as a snapshot on a regular basis. The line numbers in your Python 2.7 traceback seem to match the latest snapsho... | [
1,
0
] | [] | [] | [
"buildout",
"python",
"unicode"
] | stackoverflow_0006324926_buildout_python_unicode.txt |
Q:
Python decorator classes that take arguments and change types
Im just playing around with decorators in python and enjoying the experience, to me a decorator class seems cleaner to me than decorator functions so I have been playing with this design
def returns(object):
"""Enforces return to a specific type"""
... | Python decorator classes that take arguments and change types | Im just playing around with decorators in python and enjoying the experience, to me a decorator class seems cleaner to me than decorator functions so I have been playing with this design
def returns(object):
"""Enforces return to a specific type"""
def __init__(self, returns):
self.returns = returns
... | [
"Your returns() function returns nothing. Did you mean to make it a class?\n",
"Maybe you want to replace \ndef returns(object):\n\nby\nclass returns(object):\n\n"
] | [
2,
2
] | [] | [] | [
"decorator",
"int",
"python"
] | stackoverflow_0006328267_decorator_int_python.txt |
Q:
Can I generate html templates from models
I know we can generate Database Tables from models, which enables a fast development.
Can we also generate HTML templates from models, such as list/add/edit?
You know we can do this in Grails. Hopefully we can also do that in Django.
A:
You want generic views.
A:
Fo... | Can I generate html templates from models | I know we can generate Database Tables from models, which enables a fast development.
Can we also generate HTML templates from models, such as list/add/edit?
You know we can do this in Grails. Hopefully we can also do that in Django.
| [
"You want generic views.\n",
"\nFor a list page, you could just generate a table.\nFor an add/edit page, use Django Forms.\n\n"
] | [
1,
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006328289_django_python.txt |
Q:
how to get the math operators strings from module `operator` in python
Take operator.add for example:
>>>import operator as op
>>>op.add(1,2) #means 1 + 2
3
>>>op.add.__name__
'add'
I want sort of:
>>>op.add.math_str
"+"
Can I get all those math string "+", "-", ">"... module operator supported runtime?
ED... | how to get the math operators strings from module `operator` in python | Take operator.add for example:
>>>import operator as op
>>>op.add(1,2) #means 1 + 2
3
>>>op.add.__name__
'add'
I want sort of:
>>>op.add.math_str
"+"
Can I get all those math string "+", "-", ">"... module operator supported runtime?
EDIT:
>>> [eval(x) for x in [".".join(("op",x,"__doc__")) for x in dir(op)]]
[... | [
"You can use the following table from tutorial to build your own mappings dictionary only once and then simply use it whenever you will need it.\n",
"No. Build your own dictionary.\n"
] | [
3,
2
] | [] | [] | [
"math",
"operators",
"python",
"string"
] | stackoverflow_0006328340_math_operators_python_string.txt |
Q:
Segmentation fault with KIO in python?
The following small python program uses the KDE APIs to retrieve the contents of an URL. Unfortunately, it segfaults. Am I doing anything wrong, or is this a bug in KDE?
kio.py:
#!/usr/bin/env python2
# coding: utf-8
from PyKDE4 import kdecore,kio
url = kdecore.KUrl("http://... | Segmentation fault with KIO in python? | The following small python program uses the KDE APIs to retrieve the contents of an URL. Unfortunately, it segfaults. Am I doing anything wrong, or is this a bug in KDE?
kio.py:
#!/usr/bin/env python2
# coding: utf-8
from PyKDE4 import kdecore,kio
url = kdecore.KUrl("http://www.google.com")
print url
kio.KIO.get(url)
... | [
"You need to have an event loop running in order fo this to work, which means a Q or KApplication depending on what you're using. I usually use a KApplication. \nSome more information on KIO usage with PyKDE4 is available in the KDE Examples module:\nhttps://projects.kde.org/projects/kde/kdeexamples/repository/revi... | [
1
] | [] | [] | [
"kde_plasma",
"python",
"qt",
"segmentation_fault"
] | stackoverflow_0006328329_kde_plasma_python_qt_segmentation_fault.txt |
Q:
Writing a file upload API using Django
I have a Django app that revolves around users uploading files, and I'm attempting to make an API. Basically, the idea is that a POST request can be sent (using curl for example) with the file to my app which would accept the data and handle it.
How can I tell Django to list... | Writing a file upload API using Django | I have a Django app that revolves around users uploading files, and I'm attempting to make an API. Basically, the idea is that a POST request can be sent (using curl for example) with the file to my app which would accept the data and handle it.
How can I tell Django to listen for and accept files this way? All of Dja... | [
"Create a small view which accepts only POST and make sure it does not have CSRF protection:\nforms.py\nfrom django import forms\n\nclass UploadFileForm(forms.Form):\n title = forms.CharField(max_length=50)\n file = forms.FileField()\n\nviews.py\nfrom django.views.decorators.csrf import csrf_exempt\nfrom dja... | [
11
] | [] | [] | [
"django",
"file_upload",
"post",
"python"
] | stackoverflow_0006299584_django_file_upload_post_python.txt |
Q:
How to do form validation/processing in Django?
This is my views.py
from django.conf import settings
from django.shortcuts import render_to_response
from django.template import RequestContext, loader
from django import forms
from django.core import validators
from django.contrib.auth.models import User
from django... | How to do form validation/processing in Django? | This is my views.py
from django.conf import settings
from django.shortcuts import render_to_response
from django.template import RequestContext, loader
from django import forms
from django.core import validators
from django.contrib.auth.models import User
from django.utils import simplejson
def PermLayer(request):
... | [
"If I've understood you correctly you want to check if user exist in database?\nIf so, why didn't you set user field in PermForm (forms.py) as ForeignKey(User)?\nAnd okay, get User you can by this way:\nuser = User.objects.get(username=form.cleaned_data['user'])\n\nuser's primary key will be user.id\n"
] | [
2
] | [] | [] | [
"django",
"python",
"validation"
] | stackoverflow_0006328530_django_python_validation.txt |
Q:
python package import on windows
i am working on windows 7 platform,please tell me how to install and configure third party packages,to use that package in some other python program
Thanks mukthyar
A:
"Installing Python Modules"
| python package import on windows | i am working on windows 7 platform,please tell me how to install and configure third party packages,to use that package in some other python program
Thanks mukthyar
| [
"\"Installing Python Modules\"\n"
] | [
1
] | [] | [] | [
"python"
] | stackoverflow_0006328999_python.txt |
Q:
Using the difflib.HtmlDiff class - showing single chars
I am using the difflib.HtmlDiff class, calling the function using two sets of text (HTML from websites), however when it makes the table
html_diff = difflib.HtmlDiff()
print html_diff.make_table(previous_contents, fetch_url.page_contents)
however that just s... | Using the difflib.HtmlDiff class - showing single chars | I am using the difflib.HtmlDiff class, calling the function using two sets of text (HTML from websites), however when it makes the table
html_diff = difflib.HtmlDiff()
print html_diff.make_table(previous_contents, fetch_url.page_contents)
however that just seems to compare char by char (1 char per table row), and I en... | [
"You're supplying strings, not lists of strings (lines).\nAssuming UNIX or Windows line ends:\nprint html_diff.make_table(previous_contents.split('\\n'),\n fetch_url.page_contents.split('\\n'))\n\n"
] | [
6
] | [] | [] | [
"difflib",
"python"
] | stackoverflow_0006329192_difflib_python.txt |
Q:
Python development - unexpected indent problem
I have recently inserted an if statement into some previously working code. I now get an unexpected indent error when I run it on the start of my if statement.
ImpressionsBasedOnWeight = setImpressionsBasedOnWeight(setImpressionsBasedOnWeightData)
impressions = ... | Python development - unexpected indent problem | I have recently inserted an if statement into some previously working code. I now get an unexpected indent error when I run it on the start of my if statement.
ImpressionsBasedOnWeight = setImpressionsBasedOnWeight(setImpressionsBasedOnWeightData)
impressions = data[2]
if reportSuite.RP_UniqueUsers > weigh... | [
"impressions = data[2] is a simple assigment. There should be no change of the indentation afterwards. So you need to have impressions = .. and if .. with the same indentation:\nImpressionsBasedOnWeight = setImpressionsBasedOnWeight(setImpressionsBasedOnWeightData)\nimpressions = data[2]\nif reportSuite.RP_UniqueUs... | [
6,
2
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006329233_django_python.txt |
Q:
How to keep attribute outside __dict__?
I am creating a series of object instances, the attributes of which i save and load using their __dict__ attribute. I would like to keep some attributes outside of __dict__, simply because i do not want them to be saved or loaded.
More specifically:
I created a parent object... | How to keep attribute outside __dict__? | I am creating a series of object instances, the attributes of which i save and load using their __dict__ attribute. I would like to keep some attributes outside of __dict__, simply because i do not want them to be saved or loaded.
More specifically:
I created a parent object merely holding a list of children objects. C... | [
"Add some prefix for attributes you don't want to save and exclude them while saving.\n",
"This approach won't work and so is not going to solve your problem. You should instead extend your framework to allow you to specify which attributes were to be omitted from the save/load.\nHowever, it seems odd that you a... | [
3,
1,
1,
1
] | [] | [] | [
"attributes",
"dictionary",
"parent_child",
"python",
"reference"
] | stackoverflow_0006329347_attributes_dictionary_parent_child_python_reference.txt |
Q:
urllib's urlencode returning weird encoded results
I'm trying to use Facebook's REST api, and am encoding a JSON string/dictionary using urllib.urlencode. The result I get however, is different from the correct encoded result (as displayed by pasting the dictionary in the attachment field here http://developers.fa... | urllib's urlencode returning weird encoded results | I'm trying to use Facebook's REST api, and am encoding a JSON string/dictionary using urllib.urlencode. The result I get however, is different from the correct encoded result (as displayed by pasting the dictionary in the attachment field here http://developers.facebook.com/docs/reference/rest/stream.publish/). I was w... | [
"urllib.encode isn't meant for urlencoding a single value (as functions of the same name are in many languages), but for encoding a dict of separate values. For example, if I had the dict {\"a\": 1, \"b\": 2} it would produce the string \"a=1&b=2\".\nFirst, you want to encode your dict as JSON.\ndata = {\"media\": ... | [
2
] | [] | [] | [
"facebook",
"facebook_graph_api",
"json",
"python",
"urlencode"
] | stackoverflow_0006329212_facebook_facebook_graph_api_json_python_urlencode.txt |
Q:
In Python, why is list[] automatically global?
This is a weird behavior.
Try this :
rep_i=0
print "rep_i is" , rep_i
def test():
global rep_i #without Global this gives error but list , dict , and others don't
if rep_i==0:
print "Testing Integer %s" % rep_i
rep_i=1
return "Done"
rep_lst=[1,2,3]
d... | In Python, why is list[] automatically global? | This is a weird behavior.
Try this :
rep_i=0
print "rep_i is" , rep_i
def test():
global rep_i #without Global this gives error but list , dict , and others don't
if rep_i==0:
print "Testing Integer %s" % rep_i
rep_i=1
return "Done"
rep_lst=[1,2,3]
def test2():
if rep_lst[0]==1:
print "Testing L... | [
"It isn't automatically global.\nHowever, there's a difference between rep_i=1 and rep_lst[0]=1 - the former rebinds the name rep_i, so global is needed to prevent creation of a local slot of the same name. In the latter case, you're just modifying an existing, global object, which is found by regular name lookup (... | [
16,
5,
5,
4,
3
] | [] | [] | [
"global",
"list",
"python",
"python_2.7"
] | stackoverflow_0006329499_global_list_python_python_2.7.txt |
Q:
Need help building an SQLAlchemy query + subquery
This is the SQL I need SQLAlchemy to generate via its ORM.
SELECT
*
FROM
notes
WHERE
notes.student_id == {student_id}
OR
notes.student_id IN (
SELECT
*
FROM
peers
WHERE
peers.student_id ... | Need help building an SQLAlchemy query + subquery | This is the SQL I need SQLAlchemy to generate via its ORM.
SELECT
*
FROM
notes
WHERE
notes.student_id == {student_id}
OR
notes.student_id IN (
SELECT
*
FROM
peers
WHERE
peers.student_id == {student_id}
AND
peers.date_pe... | [
"Basically, you can use the .subquery() method to get a sub query that you can place into another conditional like that.\nSomething like\nsubq = sess.query(Peers.id).filter(and_(Peers.student==student, XXX)).subquery()\n\nThen\nnotes = sess.query(Notes).filter(or_(Notes.student==student, Notes.studing.in_(subq))).a... | [
8,
0
] | [] | [] | [
"python",
"sql",
"sqlalchemy",
"subquery"
] | stackoverflow_0006329543_python_sql_sqlalchemy_subquery.txt |
Q:
How to reliably generate Ethernet frame errors in software?
Question:
I'm testing a section of cable-fault finding software, and I'd like to reliably and reproducibly generate cable faults on a cat5 cable.
At the moment I'm using a meter length of untwisted cable, and wriggle the cable manually next to a power su... | How to reliably generate Ethernet frame errors in software? | Question:
I'm testing a section of cable-fault finding software, and I'd like to reliably and reproducibly generate cable faults on a cat5 cable.
At the moment I'm using a meter length of untwisted cable, and wriggle the cable manually next to a power supply, but I cannot detect any faults in the application (I'm read... | [
"If you're working in C, you can send a raw Ethernet frame using socket(AF_PACKET, SOCK_RAW, ...), and passing it a pointer to a raw buffer that you've generated yourself (e.g. by following the frame layout at wikipedia ).\nIt's been a long time since I've done this, so I'm not going to attempt to write a represent... | [
7
] | [] | [] | [
"c",
"ethernet",
"networking",
"python",
"raw_ethernet"
] | stackoverflow_0006329583_c_ethernet_networking_python_raw_ethernet.txt |
Q:
Python - How to request pages from website that uses OpenID
I'm writing a python script that scrapes a website, where the website uses OpenID auth to identify me via google.
Is there a python library that will handle do this for me, or do I need to find out and replicate the steps that my browser already does?
Oth... | Python - How to request pages from website that uses OpenID | I'm writing a python script that scrapes a website, where the website uses OpenID auth to identify me via google.
Is there a python library that will handle do this for me, or do I need to find out and replicate the steps that my browser already does?
Otherwise, is there some standard way of doing this in some other la... | [
"From the client's perspective, an OpenID login is very similar to any other web-based login. There isn't a defined protocol for the client; it is an ordinary web session that varies based on your OpenID provider. For this reason, I doubt that any such libraries exist. You will probably have to code it yourself.\n"... | [
1
] | [] | [] | [
"authentication",
"google_openid",
"openid",
"python"
] | stackoverflow_0006330335_authentication_google_openid_openid_python.txt |
Q:
Getting a KeyError in DB backend of django-digest
I have just started to integrate django_digest into my app. As a start I have added the @httpdigest decorator to one of my views.
If I try to connect to it I get a KeyError exception thrown in django_digest/backend/db.py . Depending on which db I configure I get a... | Getting a KeyError in DB backend of django-digest | I have just started to integrate django_digest into my app. As a start I have added the @httpdigest decorator to one of my views.
If I try to connect to it I get a KeyError exception thrown in django_digest/backend/db.py . Depending on which db I configure I get a different KeyError in a different location. I am usi... | [
"Just so that this question shows as answered am adding the solution I added in comment above as an answer (is this the correct thing to do?):\nit seems that this is specific to Django 1.2 and the multidatabase backend. Modifying the database wrapper in django_digest's backend/db.py from:\n_connection = backend.Dat... | [
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0003026647_django_python.txt |
Q:
python subprocess throws error "no such file or direcrory"
s=subprocess.Popen(['/home/karthik/Downloads/stanford-parser-2011-06-08/lexparser.csh','-'],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/... | python subprocess throws error "no such file or direcrory" | s=subprocess.Popen(['/home/karthik/Downloads/stanford-parser-2011-06-08/lexparser.csh','-'],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/subprocess.py", line 672, in __init__
errr... | [
"Make sure csh is installed and is in /bin/csh (otherwise edit the command after the shebang in lexparser.sh).\n"
] | [
4
] | [] | [] | [
"python",
"subprocess"
] | stackoverflow_0006330705_python_subprocess.txt |
Q:
Python script runs fine from command line, file not found error when using Eclipse and PyDev
Folder Structure:
src
+ root
+ nested
++ myprogram.py
++ helper.py
++ res
+++ excluded.txt
+++ whitelist.txt
Case 1 - Create a PyDev project in eclipse. Run as a PyDev configuration. Specify main module and ... | Python script runs fine from command line, file not found error when using Eclipse and PyDev | Folder Structure:
src
+ root
+ nested
++ myprogram.py
++ helper.py
++ res
+++ excluded.txt
+++ whitelist.txt
Case 1 - Create a PyDev project in eclipse. Run as a PyDev configuration. Specify main module and everythin. Main module is myprogram.py. When run using eclipse, I get the error -
IOError: [Errno ... | [
"Sounds to me a like a path issue. Post what you see when you do\nimport sys\nprint sys.path\n\nOP says that sys.path outputs the following\nC:\\Documents and Settings\\sumod_pawgi\\workspace\\SWCTester\\src\\root\\nested \nC:\\eclipse\\plugins\\org.python.pydev.debug_2.1.0.2011052613\\pysrc \nC:\\Documents and Set... | [
0,
0
] | [] | [] | [
"eclipse",
"python"
] | stackoverflow_0006330419_eclipse_python.txt |
Q:
Best way to name my distribution on Plone?
I work at Company, creating project Project that implements a functionality. Let's name it Newsletter. It could be used in further projects.
I need to create a new Plone Product, but I don't know the best way to do it. I thought about company.project.newsletter. I've read... | Best way to name my distribution on Plone? | I work at Company, creating project Project that implements a functionality. Let's name it Newsletter. It could be used in further projects.
I need to create a new Plone Product, but I don't know the best way to do it. I thought about company.project.newsletter. I've read somewhere (@aclark answer remembered the link) ... | [
"Generally speaking, you are asking about a convention (versus something technical). In short, it doesn't matter. I prefer flat or short namespaces, but they can be as long as you like e.g. https://github.com/aclark4life/viewlets_dont_suck.\nIn the case of nested namespaces, e.g. plone.*, and plone.app.* the conven... | [
5
] | [] | [] | [
"egg",
"package",
"plone",
"python"
] | stackoverflow_0006330827_egg_package_plone_python.txt |
Q:
How to query mongodb using a list of items
Given the fact that I have a list of urls (stored in the variable urls), is it possible to make a mongodb query to get all the documents in a collection that have a key (say url) matching with one of those in urls?
I can currently do that by doing N queries to the collect... | How to query mongodb using a list of items | Given the fact that I have a list of urls (stored in the variable urls), is it possible to make a mongodb query to get all the documents in a collection that have a key (say url) matching with one of those in urls?
I can currently do that by doing N queries to the collection (with N = len(urls)) but I'm pretty sure I'm... | [
"Have a look at the $in operator\n"
] | [
5
] | [] | [] | [
"mongodb",
"python"
] | stackoverflow_0006331351_mongodb_python.txt |
Q:
lxml: split at attribute?
I'm using lxml to scrape some HTML that looks like this:
<div align=center><a style="font-size: 1.1em">Football</a></div>
<a href="">Team A</a>
<a href="">Team B</a>
<div align=center><a style="font-size: 1.1em">Baseball</a></div>
<a href="">Team C</a>
<a href="">Team D</a>
How can I en... | lxml: split at attribute? | I'm using lxml to scrape some HTML that looks like this:
<div align=center><a style="font-size: 1.1em">Football</a></div>
<a href="">Team A</a>
<a href="">Team B</a>
<div align=center><a style="font-size: 1.1em">Baseball</a></div>
<a href="">Team C</a>
<a href="">Team D</a>
How can I end up with data in the form
[ {'... | [
"I had success with the following code:\n#!/usr/bin/env python\n\nsnippet = \"\"\"\n<html><head></head><body>\n<div align=center><a style=\"font-size: 1.1em\">Football</a></div>\n<a href=\"\">Team A</a>\n<a href=\"\">Team B</a>\n<div align=center><a style=\"font-size: 1.1em\">Baseball</a></div>\n<a href=\"\">Team C... | [
3,
1
] | [] | [] | [
"html",
"lxml",
"python",
"screen_scraping",
"xpath"
] | stackoverflow_0006330457_html_lxml_python_screen_scraping_xpath.txt |
Q:
Django, Jenkins and PyLint looking at everything
I am currently running Jenkins CI with pylint to look at a Django project I've been working on. One thing I have been frustrated by is pylint reporting for all the central django modules I import, meaning that my own project files get buried within mounds of other d... | Django, Jenkins and PyLint looking at everything | I am currently running Jenkins CI with pylint to look at a Django project I've been working on. One thing I have been frustrated by is pylint reporting for all the central django modules I import, meaning that my own project files get buried within mounds of other django modules (e.g. /usr/local/lib/python2.6/dist-pack... | [
"Right, well thanks to the creator of Django_Jenkins (kmmbvnr) the correct way to get it to look at only your project's files is to use the following:\nIn settings.py, you need:\nPROJECT_APPS=(\n 'appname',\n)\n\nAnd that sorts out the searching through every dependency out there.\nHope that helps!\nJ\n",
"Fro... | [
11,
0
] | [] | [] | [
"django",
"jenkins",
"pylint",
"python"
] | stackoverflow_0006321205_django_jenkins_pylint_python.txt |
Q:
Python distributed application architecture on constrained corporate environment
This is my scenario: I developed a Python desktop application which I use to probe the status of services/DBs on the very same machine it is running on.
My need is to monitor, using my application, two "brother" Window Server 2003 hos... | Python distributed application architecture on constrained corporate environment | This is my scenario: I developed a Python desktop application which I use to probe the status of services/DBs on the very same machine it is running on.
My need is to monitor, using my application, two "brother" Window Server 2003 hosts (Python version is 2.5 for both). One of the hosts lies in my own LAN, the other on... | [
"Answer to myself: I found one possible solution..\nI'm lucky because the console.py script is actually invoking many slave python scripts, each of them performing one single system check via standard third-party command-line tools which can be fired to check features on remote hosts.\nThen, what I did was to modif... | [
0
] | [] | [] | [
"architecture",
"distributed",
"environment",
"python"
] | stackoverflow_0006307829_architecture_distributed_environment_python.txt |
Q:
error parsing XML file using ElementTree.parse
I am using Python's elementtree library to parse an .XML file that I exported from MySQL query browser. When I export the result set to a .XML it includes this really weird character that shows up as the letters "BS" highlighted in a green rounded rectangle in my edit... | error parsing XML file using ElementTree.parse | I am using Python's elementtree library to parse an .XML file that I exported from MySQL query browser. When I export the result set to a .XML it includes this really weird character that shows up as the letters "BS" highlighted in a green rounded rectangle in my editor. (see screen shot) Anyway I iterate through the f... | [
"The backspace character is not a valid XML character and needs to be escaped (). I'm surprised MySQL is not doing that here, but I'm not familiar with MySQL. You can also check your data and clean it up with an update statement to get rid of that character if it is not valid data for the table.\nAs far as par... | [
1
] | [] | [] | [
"mysql",
"python",
"xml"
] | stackoverflow_0006332100_mysql_python_xml.txt |
Q:
SVN pre-commit hook encoding
I'm using Python script to implement SVN pre-commit hook:
svnlookPath = 'path-to-svnlook'
f = subprocess.Popen([svnlookPath, 'log', sys.argv[1], '--transaction', sys.argv[2]], stdout=subprocess.PIPE).stdout
commitMessage = f.read()
f.close()
commitMessage = commitMessage.rstrip('\n\r'... | SVN pre-commit hook encoding | I'm using Python script to implement SVN pre-commit hook:
svnlookPath = 'path-to-svnlook'
f = subprocess.Popen([svnlookPath, 'log', sys.argv[1], '--transaction', sys.argv[2]], stdout=subprocess.PIPE).stdout
commitMessage = f.read()
f.close()
commitMessage = commitMessage.rstrip('\n\r')
print >> sys.stderr, 'Commit me... | [
"I would say this is more the fault of the .bat then of the python script, because python has excellent unicode support.\nPerhaps the answer of this question can help you.\nBatch file encoding\n",
"The problem could be Tortoise itself. Try the following\nsvn log http://rev_url\nand see what svn says the log comme... | [
2,
0
] | [] | [] | [
"pre_commit_hook",
"python",
"svn",
"svn_hooks",
"tortoisesvn"
] | stackoverflow_0006328640_pre_commit_hook_python_svn_svn_hooks_tortoisesvn.txt |
Q:
Pyramid - Is it possible to render my mako template as a string within my view callable?
I have a view callable that does looks similar to:
def post_comment(request):
""" Posts the users comment to the thread """
try:
new_comment = comments.post()
except InvalidComment as e:
return {'s... | Pyramid - Is it possible to render my mako template as a string within my view callable? | I have a view callable that does looks similar to:
def post_comment(request):
""" Posts the users comment to the thread """
try:
new_comment = comments.post()
except InvalidComment as e:
return {'success' : False, 'message' : e.message}
# need to do something like:
new_comment = py... | [
"You can call render directly using the documented Pyramid API here: http://docs.pylonsproject.org/projects/pyramid/1.0/api/renderers.html#pyramid.renderers.render\nfrom pyramid.renderers import render\n\ndef my_view(request)\n renderer_dict = {} # dictionary of values to pass to the renderer\n new_comment = ... | [
8,
0
] | [] | [] | [
"ajax",
"json",
"pyramid",
"python"
] | stackoverflow_0006321625_ajax_json_pyramid_python.txt |
Q:
Python dictionary iteration
I have a dictionary dict2 which I want to iter through and remove all entries that contain certain ID numbers in idlist. dict2[x] is a list of lists (see example dict2 below). This is the code I have written so far, however it does not remove all instances of the IDs (entry[1]) that a... | Python dictionary iteration | I have a dictionary dict2 which I want to iter through and remove all entries that contain certain ID numbers in idlist. dict2[x] is a list of lists (see example dict2 below). This is the code I have written so far, however it does not remove all instances of the IDs (entry[1]) that are in the idlist. Any help?
dict... | [
"Try a cleaner version perhaps?\nfor k in dict2.keys():\n dict2[k] = [x for x in dict2[k] if x[1] not in idlist]\n if not dict2[k]:\n del dict2[k]\n\n",
"An approach using sets (Note that I needed to change your variables A, B, C, etc. to strings and the numbers in your idlist to actual integers; als... | [
34,
15
] | [] | [] | [
"dictionary",
"python"
] | stackoverflow_0006332691_dictionary_python.txt |
Q:
Why does Tkinter wipe previous rectangles when drawing?
When I draw a rectangle at global scope:
c = Canvas(width=IMAGE_WIDTH, height=IMAGE_HEIGHT, bg='black')
c.create_rectangle([100, 100, 110, 110], fill='white')
c.pack()
root = Tk()
and follow this by drawing multiple rectangles in a loop
class gDrawer :
... | Why does Tkinter wipe previous rectangles when drawing? | When I draw a rectangle at global scope:
c = Canvas(width=IMAGE_WIDTH, height=IMAGE_HEIGHT, bg='black')
c.create_rectangle([100, 100, 110, 110], fill='white')
c.pack()
root = Tk()
and follow this by drawing multiple rectangles in a loop
class gDrawer :
def __init__(self) :
self.rect_array = []
se... | [
"The default color for the outline of a rectangle is black. This makes it seem like the other rectangles aren't being drawn when their outline is just overlapping.\nTry changing:\nself.rect_array.append(c.create_rectangle(one_pixel_loc, fill='white'))\n\nto this:\nself.rect_array.append(c.create_rectangle(one_pixe... | [
4
] | [] | [] | [
"drawing",
"python",
"tkinter"
] | stackoverflow_0006332694_drawing_python_tkinter.txt |
Q:
Django on Apache web server 'dict' object has no attribute 'render_context'
I'm having a bit of a problem, I uploaded my Django project to a webserver running apache, mod_python, and django. On the computer I developed on the following works fine
nameBox = getNamesBox().render(locals())
-
def getNamesBox():
u... | Django on Apache web server 'dict' object has no attribute 'render_context' | I'm having a bit of a problem, I uploaded my Django project to a webserver running apache, mod_python, and django. On the computer I developed on the following works fine
nameBox = getNamesBox().render(locals())
-
def getNamesBox():
users = User.objects.filter()
templateString = '<select name="name box">'
... | [
"The render() method on a Template takes a Context object as its argument, not a dict. You'll have to construct a Context object from the dict, e.g.\nnamedbox = getNamesBox().render(Context(locals()))\n\n"
] | [
17
] | [] | [] | [
"apache",
"django",
"html",
"mod_python",
"python"
] | stackoverflow_0006333367_apache_django_html_mod_python_python.txt |
Q:
Python XML parsing question
I have an xml file that looks like this:
<!DOCTYPE ROOT SYSTEM "zombie.dtd">
<ROOT>
<row>
<field name="buildid">26960</field>
<field name="cast(status as char)">Filesystem 1K-blocks Used Available Use% Mounted on
C:cygwinin 285217976 88055920 1971... | Python XML parsing question | I have an xml file that looks like this:
<!DOCTYPE ROOT SYSTEM "zombie.dtd">
<ROOT>
<row>
<field name="buildid">26960</field>
<field name="cast(status as char)">Filesystem 1K-blocks Used Available Use% Mounted on
C:cygwinin 285217976 88055920 197162056 31% /usr/bin
C:cygwinlib ... | [
"You should be getting the text property of the zombie, not using its get() method. That will give you the content inside de <field> tag.\nAlso, if you are using ElementTree, take a look at the lxml module, which is generally better than ET, and fully supports XPath 1.0 expressions (which you can use to easily find... | [
0,
0
] | [] | [] | [
"python",
"xml",
"xml_parsing"
] | stackoverflow_0006333578_python_xml_xml_parsing.txt |
Q:
MySQLdb module installation problem for python
I installed MySQLdb module in centos VPS using yum and it says successfully installed producing no error. but when I browse the python site it displays the error. "Error loading MySQLdb module: No module named MySQLdb". Details of the error can be seen at http://74.5... | MySQLdb module installation problem for python | I installed MySQLdb module in centos VPS using yum and it says successfully installed producing no error. but when I browse the python site it displays the error. "Error loading MySQLdb module: No module named MySQLdb". Details of the error can be seen at http://74.53.127.172/. I also tried to install this module fro... | [
"use the following command to install other packages required to run mysql in centos smoothly\n>> yum install python-devel\n>> yum install MySQL-devel\n>> yum install zlib-devel\n>> yum install openssl-devel\n\nHappy coading :)\n",
"Try spawning a python interactive shell then import MySQLdb and see if you get th... | [
3,
0
] | [] | [] | [
"django",
"python",
"yum"
] | stackoverflow_0006331377_django_python_yum.txt |
Q:
Why the extract function stopped extracting?
Can someone explain and help me resolve why my function stopped extracting .tgz files when I added a counter to create folders with different names to keep the extracted folder from overwriting the previous one when I extracted another .tgz file in the same directory? W... | Why the extract function stopped extracting? | Can someone explain and help me resolve why my function stopped extracting .tgz files when I added a counter to create folders with different names to keep the extracted folder from overwriting the previous one when I extracted another .tgz file in the same directory? What am I doing wrong? Thanks! Below are the two fu... | [
"Perhaps it was this change that broke your code:\ntar = tarfile.open(tar_url, 'r')\n\nChanged to:\ntar = tarfile.open(tar_url, 'wb')# changed from r to wb 6/12\n\n",
"Does the extract path with the counter exist?\n for item in tar:\n os.mkdir(extract_path + \"_%d\" % counter)\n tar.extract(item, extra... | [
1,
0,
0
] | [] | [] | [
"extract",
"function",
"python"
] | stackoverflow_0006333931_extract_function_python.txt |
Q:
Downloadlink for a file dynamically created by a Trac- Wikimacro
I've been given the task to write a plugin for Trac.
It should provide burndown data for the ticketcount and estimations filed in the issue tracking system.
The user writes his request as a wikimacro and is provided a link/ button for downloading t... | Downloadlink for a file dynamically created by a Trac- Wikimacro | I've been given the task to write a plugin for Trac.
It should provide burndown data for the ticketcount and estimations filed in the issue tracking system.
The user writes his request as a wikimacro and is provided a link/ button for downloading the burndown as a csv-file, output as a chart is also planned, but has l... | [
"Basically you need to write your own IRequestHandler which handles a specific URL and returns your dynamically created data. Afterwards you macro should return a url which is configured for your request handler.\n",
"If match_request isn't getting called, then process_request never has a chance to execute. Assu... | [
2,
2
] | [] | [] | [
"genshi",
"python",
"trac"
] | stackoverflow_0006276080_genshi_python_trac.txt |
Q:
Open a text file without clearing everything in it?
file = io.open('spam.txt', 'w')
file.write(u'Spam and eggs!\n')
file.close()
....(Somewhere else in the code)
file = io.open('spam.txt', 'w')
file.write(u'Spam and eggs!\n')
file.close()
I was wondering how I can keep a log.txt file that I can write to?
I want... | Open a text file without clearing everything in it? | file = io.open('spam.txt', 'w')
file.write(u'Spam and eggs!\n')
file.close()
....(Somewhere else in the code)
file = io.open('spam.txt', 'w')
file.write(u'Spam and eggs!\n')
file.close()
I was wondering how I can keep a log.txt file that I can write to?
I want to be able to open a txt file, write to it, then be able... | [
"Change 'w' to 'a', for append mode. But you really ought to just keep the file open and write to it when you need it. If you are repeating yourself, use the logging module.\n",
"file = io.open('spam.txt', 'a') \nfile.write(u'Spam and eggs!\\n') \nfile.close()\n\nThe w(rite) mode truncates a file, the a(ppend) mo... | [
12,
1,
0,
0
] | [] | [] | [
"io",
"python"
] | stackoverflow_0006334382_io_python.txt |
Q:
the .set() method is not in the xml.etree library for Python?
working on creating an XML file with some data using Python. I am trying to set values in dictionary to data in the list. I am going to be making multiple lines, so that is why I reference each value this way. Thanks guys. Here is my code:
from xml.etre... | the .set() method is not in the xml.etree library for Python? | working on creating an XML file with some data using Python. I am trying to set values in dictionary to data in the list. I am going to be making multiple lines, so that is why I reference each value this way. Thanks guys. Here is my code:
from xml.etree import ElementTree as ET
root = ET.Element("painter")
root.set('... | [
"You are calling get() and set() on the attrib member of the Element. attrib is a regular old Python dictionary that does not have a set() function. The documentation you linked is for the set() function on the actual Element object itself.\nTo set a value in attrib member you would use:\nelem_line.attrib['r'] = ... | [
1
] | [] | [] | [
"python",
"xml",
"xml.etree"
] | stackoverflow_0006334573_python_xml_xml.etree.txt |
Q:
How does legend() work on a dynamic data set?
I need a legend for a code which generates data from a dict. I don't know how much keys exist in the dict is there a way to do 'dynamic' a legend on this?
import matplotlib.pyplot as plt
for host in d.keys():
plt.plot(range(100),d[host])
plt.show()
A:
If I unders... | How does legend() work on a dynamic data set? | I need a legend for a code which generates data from a dict. I don't know how much keys exist in the dict is there a way to do 'dynamic' a legend on this?
import matplotlib.pyplot as plt
for host in d.keys():
plt.plot(range(100),d[host])
plt.show()
| [
"If I understand you, then sure: you simply need to turn the key into a label somehow, even if it's as simple as calling str on it.\nimport matplotlib.pyplot as plt\nimport numpy\n\nx = numpy.arange(10.)\nd = dict((i, numpy.sin(x+i)) for i in range(5))\n\nfor k in sorted(d): # sort purely to make deterministic\n ... | [
2
] | [] | [] | [
"matplotlib",
"plot",
"python"
] | stackoverflow_0006334506_matplotlib_plot_python.txt |
Q:
Python usage of breadth-first search on social graph
I've been reading a lot of stackoverflow questions about how to use the breadth-first search, dfs, A*, etc, the question is what is the optimal usage and how to implement it in reality verse simulated graphs. E.g.
Consider you have a social graph of Twitter/Face... | Python usage of breadth-first search on social graph | I've been reading a lot of stackoverflow questions about how to use the breadth-first search, dfs, A*, etc, the question is what is the optimal usage and how to implement it in reality verse simulated graphs. E.g.
Consider you have a social graph of Twitter/Facebook/Some social networking site, to me it seems a search ... | [
"For my two cents, if you're just trying to traverse the whole graph it doesn't matter a whole lot what algorithm you use so long as it only hits each node once. This seems to be what you're saying when you note: \n\nI'm just trying to traverse the whole graph\n\nThis means your terminology is technically flawed- ... | [
0,
0
] | [] | [] | [
"algorithm",
"breadth_first_search",
"python",
"social_networking",
"traversal"
] | stackoverflow_0004488783_algorithm_breadth_first_search_python_social_networking_traversal.txt |
Q:
How to get the PyBindGen PyObject for a given C++ pointer?
Given the PyObject created by PyBindGen, it's easy to get the pointer to the wrapped C++ object, just use the obj member in the struct:
typedef struct {
PyObject_HEAD
MyWrappedClass *obj;
PyObject *inst_dict;
PyBindGenWrapperFlags flags:8;
... | How to get the PyBindGen PyObject for a given C++ pointer? | Given the PyObject created by PyBindGen, it's easy to get the pointer to the wrapped C++ object, just use the obj member in the struct:
typedef struct {
PyObject_HEAD
MyWrappedClass *obj;
PyObject *inst_dict;
PyBindGenWrapperFlags flags:8;
} PyMyWrappedClass;
However, let's say I have just MyWrappedCla... | [] | [] | [
"I would have added this as a comment if I had enough reputation as I'm not familiar with PyBindGen, but unless inst_dict is a dictionary of backpointers (as the name might suggest) I think you're out of luck (Unless you want to trawl through the Python heap to see if there are any instances of your class there).\n... | [
-1
] | [
"c++",
"pybindgen",
"python"
] | stackoverflow_0006334753_c++_pybindgen_python.txt |
Q:
Clear stdout in Python after flush()
I'm trying to make my Python script stream its output to my webpage as its printed.
So in my javascript I do:
var xmlhttp;
var newbody = "";
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==3) {
newbody = newbody + xmlhttp.... | Clear stdout in Python after flush() | I'm trying to make my Python script stream its output to my webpage as its printed.
So in my javascript I do:
var xmlhttp;
var newbody = "";
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==3) {
newbody = newbody + xmlhttp.responseText;
document.getElementByI... | [
"xmlhttp.responseText on the client side always contains the entire response, so you don't need newbody, just use xmlhttp.responseText.\n"
] | [
3
] | [] | [] | [
"ajax",
"onreadystatechange",
"python",
"streaming"
] | stackoverflow_0006335104_ajax_onreadystatechange_python_streaming.txt |
Q:
Backing up a postgresql data dir with python tarfile. What errors to expect / ignore
I am writing a python script for automating the backing up of the PostgreSQL data directory to enable "Continuous Archiving and Point-In-Time Recovery".
I would like to use Pythons tarfile library to create an archive.
The compli... | Backing up a postgresql data dir with python tarfile. What errors to expect / ignore | I am writing a python script for automating the backing up of the PostgreSQL data directory to enable "Continuous Archiving and Point-In-Time Recovery".
I would like to use Pythons tarfile library to create an archive.
The complication is that the data files can change during the backup. To quote the PostgreSQL manual... | [
"If you are using the tarfile module, the implementation of this is essentially up to you. GNU tar checks the file size and ctime before and after it processes a file and complains if they differ. It's not an actual error, it's just something that tar feels like it should mention. But in your use case, you don't... | [
1
] | [
"Continuous Archiving is explained in PostgreSQL documentation. It is implemented and there is no need to create additional script - but you will have many files.\n24.3.2. Making a Base Backup - follow instructions and you can create tar, data files will not change.\n24.3.1. Setting up WAL archiving - here you have... | [
-1
] | [
"backup",
"postgresql",
"python",
"tar"
] | stackoverflow_0006327021_backup_postgresql_python_tar.txt |
Q:
Reading and writing to a file
I have an XML file that contains an illegal character, I am iterating through the file, removing the character from all of the lines and storing the lines in a list. I now want to write those same lines back into the file and overwrite what is already there.
I tried this:
file = open... | Reading and writing to a file | I have an XML file that contains an illegal character, I am iterating through the file, removing the character from all of the lines and storing the lines in a list. I now want to write those same lines back into the file and overwrite what is already there.
I tried this:
file = open(filename, "r+")
#do stuff
Which i... | [
"You could re-write the lines list with writelines function.\nwith open(filename, \"r\") as f:\n\n lines = f.readlines()\n\n#edit lines here\n\nwith open(filename, \"w\") as f:\n\n f.writelines(lines)\n\n",
"The reason you're appending to the end of the file the whole time is that you need to seek to the be... | [
2,
0
] | [] | [] | [
"file_io",
"python"
] | stackoverflow_0006335624_file_io_python.txt |
Q:
What does this (simple?) expression in Python mean? func(self)(*args)
I saw some Python code like: getattr(self, that)(*args). what does it mean? I see that the builtin getattr function gets called, passing the current object and that; but what is the (*args) doing after that? Does it call something with *args as ... | What does this (simple?) expression in Python mean? func(self)(*args) | I saw some Python code like: getattr(self, that)(*args). what does it mean? I see that the builtin getattr function gets called, passing the current object and that; but what is the (*args) doing after that? Does it call something with *args as parameter?
| [
"It calls the value returned by getattr(self, that) with the arguments specified in the array args.\nFor example, assuming that = 'thatFunction' and args = [1,2,3], it's the same as\nself.thatFunction(1, 2, 3)\n\n",
"You're right on track. that is going to be the name of a method on the object. getattr() is ret... | [
3,
3,
2,
2
] | [] | [] | [
"getattr",
"python"
] | stackoverflow_0006335676_getattr_python.txt |
Q:
Running as many instances of a program as possible
I'm trying to implement some code to import user's data from another service via the service's API. The way I'm going to set it up is all the request jobs will be kept in a queue which my simple importer program will draw from. Handling one task at a time won't co... | Running as many instances of a program as possible | I'm trying to implement some code to import user's data from another service via the service's API. The way I'm going to set it up is all the request jobs will be kept in a queue which my simple importer program will draw from. Handling one task at a time won't come anywhere close to maxing out any of the computer's re... | [
"Use a Producer-Consumer queue, with as many Consumer threads as you need to optimize resource usage on the host (sorry - that's very vague advice, but the \"right number\" is problem-dependent). \nIf requests are lightweight you may well only need one Producer thread to handle them.\nLaunching multiple processes ... | [
1
] | [] | [] | [
"multiple_instances",
"multithreading",
"process",
"python"
] | stackoverflow_0006335905_multiple_instances_multithreading_process_python.txt |
Q:
Agnostic automated deployment
What do you use to automatically deploy applications for various kinds of server applications (web, socket, daemon) that uses various technologies (different DBs, languages, etc)?
Here we use Python, Java and Ruby, and may use other languages as well in the future.
Update: I ended up... | Agnostic automated deployment | What do you use to automatically deploy applications for various kinds of server applications (web, socket, daemon) that uses various technologies (different DBs, languages, etc)?
Here we use Python, Java and Ruby, and may use other languages as well in the future.
Update: I ended up using Puppet to manage all server ... | [
"I use Puppet for some of the deployements / initial configuration of server. Maven and Ant for Java based projects.\n",
"You could use Ant, Makefile, or a batch script. Or a combination of them.\n",
"Go for KWateeSDCM. It comes with a straightforward web GUI and does not require obscure scripting and integrate... | [
3,
2,
2,
1,
1,
1,
1,
1
] | [] | [] | [
"deployment",
"java",
"python",
"ruby"
] | stackoverflow_0003864223_deployment_java_python_ruby.txt |
Q:
Adding elements within a Python list of list based on a comparison
I have a list of list that looks like this:
['000000000000012', 'AUD ', ' -1500000.0000', '29473550', 'TD CASH', 'Currencies', 'Unsettled Transactions', 'Unsettled']
['000000000000012', 'BRL ', ' 6070.5400', ' ', 'TD CASH', 'Be... | Adding elements within a Python list of list based on a comparison | I have a list of list that looks like this:
['000000000000012', 'AUD ', ' -1500000.0000', '29473550', 'TD CASH', 'Currencies', 'Unsettled Transactions', 'Unsettled']
['000000000000012', 'BRL ', ' 6070.5400', ' ', 'TD CASH', 'Beginning Balance', 'Positions', 'Settled']
['000000000000012', 'MXN ', ' ... | [
"There is a function for exactly this purpose: itertools.groupby().\nprint [key + [sum(float(x[2]) for x in it)]\n for key, it in groupby(my_list, lambda x: x[:2])]\n\nprints\n[['000000000000012', 'AUD ', -1500000.0],\n ['000000000000012', 'BRL ', 6070.54],\n ['000000000000012', 'MXN ', 19524996.539999999],\n... | [
4
] | [] | [] | [
"element",
"list",
"python",
"sum"
] | stackoverflow_0006336093_element_list_python_sum.txt |
Q:
Python Time Problem
I'm having trouble figuring out how to do this.
I'm trying to run a python script for a set duration. And every 1/10 of the duration I need it to run something. The problem is this step can take any amount of time to complete. I cannot go over the maximum duration set at the start.
Example:
Du... | Python Time Problem | I'm having trouble figuring out how to do this.
I'm trying to run a python script for a set duration. And every 1/10 of the duration I need it to run something. The problem is this step can take any amount of time to complete. I cannot go over the maximum duration set at the start.
Example:
Duration 20 hours
Interval ... | [
"Perhaps you can use signals. The idea is you set a signal handler to get called when a SIGALRM is generated. In the signal handler you can call function. Then you reset the alarm and do it again. This is a basic example just to give you an idea.\nimport signal\n...\nsignal.signal(signal.SIGALRM, alarm_handler) # ... | [
2,
0
] | [] | [] | [
"python",
"time"
] | stackoverflow_0006335548_python_time.txt |
Q:
Python Audio Frame Pitch Change
I'm attempting to use pyaudio to make a voice masker. With the way I have it set up right now, the only thing I have to do is input the sound, change the pitch on the fly, and chunk it right back out. The first and last part are working, and I think I'm getting close to changing p... | Python Audio Frame Pitch Change | I'm attempting to use pyaudio to make a voice masker. With the way I have it set up right now, the only thing I have to do is input the sound, change the pitch on the fly, and chunk it right back out. The first and last part are working, and I think I'm getting close to changing pitch... emphasis on the "think".
Unfo... | [
"After the irfft line, and before the stream.write line, you need to convert the data back into 16-bit integers with a struct.pack call.\ndata = np.fft.irfft(data)\ndataout = np.array(data*0.5, dtype='int16') #undo the *2 that was done at reading\nchunkout = struct.pack(\"%dh\"%(len(dataout)), *list(dataout)) #conv... | [
5,
3
] | [] | [] | [
"audio",
"pitch",
"python"
] | stackoverflow_0006326822_audio_pitch_python.txt |
Q:
dealing with \n characters at end of multiline string in python
I have been using python with regex to clean up a text file. I have been using the following method and it has generally been working:
mystring = compiledRegex.sub("replacement",mystring)
The string in question is an entire text file that includes m... | dealing with \n characters at end of multiline string in python | I have been using python with regex to clean up a text file. I have been using the following method and it has generally been working:
mystring = compiledRegex.sub("replacement",mystring)
The string in question is an entire text file that includes many embedded newlines. Some of the compiled regex's cover multiple li... | [
"If i correctly undestood you and all that you need is to get a text without newline at the end of the each line and then iterate over this text in order to find a required word than you can try to use the following:\ndata = (line for line in text.split('\\n') if line.strip())# gives you all non empty lines without... | [
3,
2,
0,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0006335901_python_regex.txt |
Q:
Qt.QueuedConnection never sends message
Why does this program not print anything?
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class A(QObject):
def __init__(self):
super(A, self).__init__()
sig = pyqtSignal()
@pyqtSlot()
def slot(self):
print("received")
a = A()
a.sig.c... | Qt.QueuedConnection never sends message | Why does this program not print anything?
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class A(QObject):
def __init__(self):
super(A, self).__init__()
sig = pyqtSignal()
@pyqtSlot()
def slot(self):
print("received")
a = A()
a.sig.connect(a.slot, Qt.QueuedConnection)
a.sig.em... | [
"I'm not an expert with Python (or PyQt), but a queued connection only get's delivered once the application enters the event loop again, whereas a normal connection corresponds to a direct function call. So I guess in your case you have to wait until the application enters the event loop for the slot to be called (... | [
3
] | [] | [] | [
"pyqt",
"python",
"qt"
] | stackoverflow_0006336532_pyqt_python_qt.txt |
Q:
Django 1.3 - RequestContext not rendering to template
I am trying to simply render {{ request.user }} from my base template and for whatever reason it is not rendering anything. I have even tested trying to return {{ request }} to no avail.
I am currently using django-annoying to render to the template (render_to)... | Django 1.3 - RequestContext not rendering to template | I am trying to simply render {{ request.user }} from my base template and for whatever reason it is not rendering anything. I have even tested trying to return {{ request }} to no avail.
I am currently using django-annoying to render to the template (render_to) and have tried to switch back to using django.templates.Re... | [
"You need to add the django.core.context_processors.request context processor.\n"
] | [
4
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006336668_django_python.txt |
Q:
Py2Exe Location
Possible Duplicate:
how can i get the executable's current directory in py2exe?
Is there a way to get the path to the executable file currently running with py2exe? For example if I had an executable generated with py2exe stored in C:\Users\Desktop\John\myapp.exe, how can I get this path from wit... | Py2Exe Location |
Possible Duplicate:
how can i get the executable's current directory in py2exe?
Is there a way to get the path to the executable file currently running with py2exe? For example if I had an executable generated with py2exe stored in C:\Users\Desktop\John\myapp.exe, how can I get this path from within myapp.exe in Pyt... | [
"py2exe sets sys.executable to the full pathname of the executable. sys.argv[0] should also give this path. See Py2exeEnvironment for the official documentation.\n",
"The path to your .exe file should be stored in sys.executable.\nThe py2exe.org wiki WhereAmI page has some useful examples that you may find helpfu... | [
2,
1,
0
] | [] | [] | [
"path",
"py2exe",
"python",
"windows"
] | stackoverflow_0006336499_path_py2exe_python_windows.txt |
Q:
How to catch a pywin32com exception on opening files
I am trying to open an excel file in python using COM, and trying to catch the file not found error:
I first tried catching the IOError:
try:
output = xl.Workbooks.Open(Params.workbookName)
except IOError as reason:
print reason
exit()
But COM doesn't ... | How to catch a pywin32com exception on opening files | I am trying to open an excel file in python using COM, and trying to catch the file not found error:
I first tried catching the IOError:
try:
output = xl.Workbooks.Open(Params.workbookName)
except IOError as reason:
print reason
exit()
But COM doesn't raise an IO Error when it has a file not found problem, in... | [
"Try:\nfrom pythoncom import com_error\n\nand catch it in your except block\n"
] | [
2
] | [] | [] | [
"com",
"custom_exceptions",
"excel",
"python",
"winapi"
] | stackoverflow_0006336831_com_custom_exceptions_excel_python_winapi.txt |
Q:
Python separate matching string at the end of a string
I'm finding it difficult getting started with regular expressions in python.
I have a bunch of strings now that look like this:
<street address><SPACE><#><SPACE><Suite number or letter>
I need to separate the Suite number from the rest of the string and save... | Python separate matching string at the end of a string | I'm finding it difficult getting started with regular expressions in python.
I have a bunch of strings now that look like this:
<street address><SPACE><#><SPACE><Suite number or letter>
I need to separate the Suite number from the rest of the string and save it in another variable. I also need a copy of the street ... | [
"s.split()[-1]\n\nThis will return the entirety of the string after the last space.\nWith a few of your strings as examples:\n>>> L = [\"1111 19th St NW # 200\",\n \"1408 U St NW # A\",\n \"1509 17th St NW # 1\",\n \"1515 14th St NW # 1\"]\n>>> [s.split()[-1] for s in L]\n['200', 'A', '1', '1']\n\n",
"So... | [
2,
2,
2
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0006336911_python_regex.txt |
Q:
context menu "Open with IDLE" for Python .py files blown away
Somehow managed to blow this away, and can't figure out how to get it back
Tried un- and re-installing Python 3, but that didn't do it.
Any ideas??
A:
By default the python installation setup the actions on a .py file to be "Open" and "Edit with Idle"... | context menu "Open with IDLE" for Python .py files blown away | Somehow managed to blow this away, and can't figure out how to get it back
Tried un- and re-installing Python 3, but that didn't do it.
Any ideas??
| [
"By default the python installation setup the actions on a .py file to be \"Open\" and \"Edit with Idle\".\nThose settings are stored in the Windows registry in HKEY_CLASSES_ROOT\\.py\nIf you change those settings (by error or not), windows shall create a new entry in the registry with your new settings. This entry... | [
3,
1
] | [] | [] | [
"contextmenu",
"menuitem",
"python",
"python_idle"
] | stackoverflow_0004173667_contextmenu_menuitem_python_python_idle.txt |
Q:
Paramiko and Crypto Import Error: import winrandom (python)
Running on a windows machine python 2.7, whenever I try to run my script using the command line I receive the following error.
import winrandom
ImportError: DLL load failed: The specified module could not be found.
But this error does not happen when I r... | Paramiko and Crypto Import Error: import winrandom (python) | Running on a windows machine python 2.7, whenever I try to run my script using the command line I receive the following error.
import winrandom
ImportError: DLL load failed: The specified module could not be found.
But this error does not happen when I run my script through a python IDE
| [
"Make sure your PATH correctly includes your python2.7 and python2.7\\Scripts directories.\nSnippet on settings environment variables (if needed):\nhttp://msdn.microsoft.com/en-us/library/ms682653%28v=vs.85%29.aspx\n"
] | [
2
] | [] | [] | [
"paramiko",
"pycrypto",
"python"
] | stackoverflow_0006332653_paramiko_pycrypto_python.txt |
Q:
No Module named Contact Error-Chapter 7 Exercise in Django Book
I've received the following error when trying to set up a contact subdirectory inside the mysite directory.
Here is how I structured the urls.py script:
from mysite.contact import views as contact_views
(r'^contact/$', contact_views.contact),
Do I ... | No Module named Contact Error-Chapter 7 Exercise in Django Book | I've received the following error when trying to set up a contact subdirectory inside the mysite directory.
Here is how I structured the urls.py script:
from mysite.contact import views as contact_views
(r'^contact/$', contact_views.contact),
Do I need to change anything in the settings.py TEMPLATE_DIRS, so, I can c... | [
"Yes, template_dirs needs to contain the path to the templates folder.\n"
] | [
2
] | [] | [] | [
"django",
"forms",
"python"
] | stackoverflow_0006061208_django_forms_python.txt |
Q:
Google Checkout Notification API Python Example
Currently, there are absolutely no code snippets of the Notification API in Python. I am currently at a loss as the documentation, as thorough as it is, seems to be missing important information necessary to actually code a solution for myself.
Currently, I have a si... | Google Checkout Notification API Python Example | Currently, there are absolutely no code snippets of the Notification API in Python. I am currently at a loss as the documentation, as thorough as it is, seems to be missing important information necessary to actually code a solution for myself.
Currently, I have a single product that I wish to submit to Google Checkout... | [
"Have a look at Chippy's Shop:\nhttp://code.google.com/p/chippysshop/\nhttp://code.google.com/p/chippysshop/source/browse/googlecheckout.py\n"
] | [
1
] | [] | [] | [
"django",
"google_checkout",
"python"
] | stackoverflow_0004779591_django_google_checkout_python.txt |
Q:
Controlling size of swf file posted to wall using graph api
I am trying to use the Facebook graph api to publish a swf file on my wall, and was wondering if there is anyway I can control the height of the swf file. It looks like facebook sets the height to 259px automatically. Any help would be really appreciated!... | Controlling size of swf file posted to wall using graph api | I am trying to use the Facebook graph api to publish a swf file on my wall, and was wondering if there is anyway I can control the height of the swf file. It looks like facebook sets the height to 259px automatically. Any help would be really appreciated!
Thanks.
| [
"Facebook will automatically set the size to width:398px;height:259px.\nThe movie will be stretched to accomodate this.\nIf your movie is a different size, the best thing to do is to make sure it is at least the same aspect ratio.\n",
"The answer was to use the still not completely deprecated REST api, which has ... | [
1,
0
] | [] | [] | [
"facebook",
"facebook_graph_api",
"php",
"python"
] | stackoverflow_0006286449_facebook_facebook_graph_api_php_python.txt |
Q:
"Python quit unexpectedly" when running in 32-bit mode on Snow Leopard
I have been unable to force my python to run in 32 bit mode, which I need for it to import matplotlib. I got this information from my Apache log (the python script is being executed by a Perl CGI script) which says "no appropriate 64-bit archi... | "Python quit unexpectedly" when running in 32-bit mode on Snow Leopard | I have been unable to force my python to run in 32 bit mode, which I need for it to import matplotlib. I got this information from my Apache log (the python script is being executed by a Perl CGI script) which says "no appropriate 64-bit architecture (see "man python" for running in 32-bit mode)."
When I do "defaults ... | [
"The defaults write com.apple.versioner.python Prefer-32-Bit -bool yes only works when running under your username (and with the Apple-supplied Python in 10.6). If you can, change your CGI script to invoke Python this way:\narch -i386 /usr/bin/python2.6 ...\n\n"
] | [
0
] | [] | [] | [
"cgi",
"matplotlib",
"python"
] | stackoverflow_0006335578_cgi_matplotlib_python.txt |
Q:
Python Mysql Request with variables
I have used python for a long time but I have trouble with a particular string-variable manipulation case
I want to do something like this:
##################################
#sample
MYROW= 'ID_project'
result=curs.execute("""select %s FROM shotmanager_projects""",(MYROW))
#r... | Python Mysql Request with variables | I have used python for a long time but I have trouble with a particular string-variable manipulation case
I want to do something like this:
##################################
#sample
MYROW= 'ID_project'
result=curs.execute("""select %s FROM shotmanager_projects""",(MYROW))
#result=curs.execute("""select %s FROM shot... | [
"(x) is not a tuple with one element, it is a normal value. (x,) is a tuple with one element.\n",
"result = curs.execute(\"select %s FROM shotmanager_projects\", (MYROW,))\n"
] | [
3,
0
] | [] | [] | [
"mysql",
"python"
] | stackoverflow_0006337575_mysql_python.txt |
Q:
Python ctypes: WindowsError when using function pointer
I'm trying to use Python's ctypes to work with a DLL, but I occasionally run into a problem when I try to call a function that's passed as a pointer to another function.
A little background...I'm trying to build a userspace filesystem using Dokan (version 0.6... | Python ctypes: WindowsError when using function pointer | I'm trying to use Python's ctypes to work with a DLL, but I occasionally run into a problem when I try to call a function that's passed as a pointer to another function.
A little background...I'm trying to build a userspace filesystem using Dokan (version 0.6.0). Somewhat loosely stated, Dokan is basically FUSE for Wi... | [
"How do you instantiate and use your callback? A callback must remain in scope for the lifetime it may be called. See this answer. These \n\nEdit\nClarifying what I think the issue is...\nI see you have to implement a DOKAN_OPERATIONS structure that implements callbacks like FindFilesWithPattern, then call Dokan... | [
2
] | [] | [] | [
"ctypes",
"dokan",
"python",
"windows"
] | stackoverflow_0006333340_ctypes_dokan_python_windows.txt |
Q:
Trouble using PIL in Django app on Windows
I'm learning a little Django with the Python Web Development with Django book. All was going well until I tried to build the photos application which requires the PIL (Python Imaging Library). When I try to add an image through the admin interface I receive an error mes... | Trouble using PIL in Django app on Windows | I'm learning a little Django with the Python Web Development with Django book. All was going well until I tried to build the photos application which requires the PIL (Python Imaging Library). When I try to add an image through the admin interface I receive an error message pasted below.
I am running Windows 7, Pytho... | [
"I've answered this before here\nJust install pre-compiled binaries for Windows (for your python version) from http://www.lfd.uci.edu/~gohlke/pythonlibs/\n",
"This worked for me when the same installer (windows, Python2.7) downloaded from the official PIL site did not. Thanks!\n"
] | [
7,
1
] | [] | [] | [
"django",
"python",
"python_imaging_library",
"xampp"
] | stackoverflow_0005352968_django_python_python_imaging_library_xampp.txt |
Q:
GAE expanded log view
This might not be bug, but feature. I'm having problem views expanded logs when searching logs in dashboard on app engine.
Search results show first couple of logs in full detail, but rest of log entries are obscured. Every new entry in log is shown in full details, but older ones get obscur... | GAE expanded log view | This might not be bug, but feature. I'm having problem views expanded logs when searching logs in dashboard on app engine.
Search results show first couple of logs in full detail, but rest of log entries are obscured. Every new entry in log is shown in full details, but older ones get obscured over the time.
Same beh... | [
"App Engine stores logging information in a set of circular buffers. When it runs out of space, it overwrites older log entries with the new data. What you're seeing is requests for which the detailed logs have been overwritten by newer requests.\n"
] | [
1
] | [] | [] | [
"google_app_engine",
"logging",
"python"
] | stackoverflow_0006335248_google_app_engine_logging_python.txt |
Q:
How to specify the current user vairable name in the path to a file
I want to copy a file placed in the folder of the current user logged in.
so i have searched how to identify the user that is logged in, so i can point to the user folder in windows.
for example i want to copy the file "hi.txt" in the Microsoft fo... | How to specify the current user vairable name in the path to a file | I want to copy a file placed in the folder of the current user logged in.
so i have searched how to identify the user that is logged in, so i can point to the user folder in windows.
for example i want to copy the file "hi.txt" in the Microsoft folder.
"C:\Documents and Settings\john\Application Data\Microsoft\hi.txt"
... | [
"The home directory of the current user can be expanded using os.path.expanduser(). To open the file \"whatever\" in the current user's home directory, use\nwith open(os.path.expanduser(\"~/whatever\")) as f:\n # whatever\n\n",
"The follow codes are copied from python shell, perhaps it can help you.\n>>> impo... | [
5,
1
] | [] | [] | [
"copy",
"file",
"python",
"variables"
] | stackoverflow_0006337835_copy_file_python_variables.txt |
Q:
limits of bulk email in GAE
I'm working on a voting app where I need to send an email to each voter to inform him or her about the election. I see three methods for doing this and I'm curious what the approximate limits on the number of emails I could send with each method:
In a user request, add a task to a tas... | limits of bulk email in GAE | I'm working on a voting app where I need to send an email to each voter to inform him or her about the election. I see three methods for doing this and I'm curious what the approximate limits on the number of emails I could send with each method:
In a user request, add a task to a task queue where each task sends one... | [
"Enqueue a single task which sends emails sequentially, checking the wallclock time after each email. When the time approaches 10 minutes, chain another task to continue where the current task left off. If you want to send emails faster, parallelize this, and enqueue several tasks that each send emails to a subset ... | [
2
] | [] | [] | [
"backend",
"email",
"google_app_engine",
"python",
"task_queue"
] | stackoverflow_0006332562_backend_email_google_app_engine_python_task_queue.txt |
Q:
lisp interpreter in python
I'm curious how a part of Peter Norvig's Lisp interpreter works. One can define functions in this Lisp interpreter...how does this work? I'm a beginner, and just would like a simple explanation.
There's one part that might be related where it says
elif x[0] == 'define': # (define... | lisp interpreter in python | I'm curious how a part of Peter Norvig's Lisp interpreter works. One can define functions in this Lisp interpreter...how does this work? I'm a beginner, and just would like a simple explanation.
There's one part that might be related where it says
elif x[0] == 'define': # (define var exp)
(_, var, exp) ... | [
"In this case, x[0] is define, x[1] is the variable name, and x[2] is the expression. So, in Python, _, var, exp = x is a \"destructuring assignment\", which destructures the array x into its constituent elements, and assigns them to the variables on the left-hand side.\n"
] | [
3
] | [] | [] | [
"interpreter",
"lisp",
"python",
"scripting",
"shell"
] | stackoverflow_0006338011_interpreter_lisp_python_scripting_shell.txt |
Q:
How do I cause or create an invalid memory reference in Python on purpose?
How do I cause or create an invalid memory reference in Python on purpose?
This is a bit of a bar-bet. I'm told it can't be done. I don't believe that.
A:
>>> import ctypes
>>> p = ctypes.POINTER(ctypes.c_int)(ctypes.c_int())
>>> p[100000... | How do I cause or create an invalid memory reference in Python on purpose? | How do I cause or create an invalid memory reference in Python on purpose?
This is a bit of a bar-bet. I'm told it can't be done. I don't believe that.
| [
">>> import ctypes\n>>> p = ctypes.POINTER(ctypes.c_int)(ctypes.c_int())\n>>> p[100000000]\nSegmentation fault\n\n",
"Create a module in C:\n#include <Python.h>\n\nstatic PyMethodDef SpamMethods[] =\n{\n {NULL, NULL, 0, NULL}\n};\n\nPyMODINIT_FUNC\ninitspam(void)\n{\n (void)Py_InitModule(\"spam\", SpamMetho... | [
5,
3,
2
] | [] | [] | [
"python"
] | stackoverflow_0006338007_python.txt |
Q:
GAE mapreduce and missing properties
I've checked out mapreduce library for Python version of GAE today, and I can't seem to wrap my brain around it. I'm trying to iterate over datastore entities with missing properties, and add them. One of the properties has a default value, but other doesn't. The property that ... | GAE mapreduce and missing properties | I've checked out mapreduce library for Python version of GAE today, and I can't seem to wrap my brain around it. I'm trying to iterate over datastore entities with missing properties, and add them. One of the properties has a default value, but other doesn't. The property that doesn't have the default value is calculat... | [
"If you've added a new property and set it as required, but not supplied a default, loading existing entities will cause the exception you're seeing, because the entities are missing a required property. You need to start by adding the property without the required flag, run the mapreduce to update old entities, an... | [
0
] | [] | [] | [
"google_app_engine",
"mapreduce",
"python"
] | stackoverflow_0006323834_google_app_engine_mapreduce_python.txt |
Q:
jquery qrcode fails using more than 34 char long
I am using this jquery plugin to generate QR Codes from string:
https://github.com/jeromeetienne/jquery-qrcode
It works fine with strings with less than 35 chars, if the string is 35 o bigger qrCode simply doesn't get displayed.
My strings are 95 chars long.
Is thi... | jquery qrcode fails using more than 34 char long | I am using this jquery plugin to generate QR Codes from string:
https://github.com/jeromeetienne/jquery-qrcode
It works fine with strings with less than 35 chars, if the string is 35 o bigger qrCode simply doesn't get displayed.
My strings are 95 chars long.
Is this a logical limitation ? am I using the wrong library?... | [
"Having a look at the github site, there is a closed issue that seems to relate to this: https://github.com/jeromeetienne/jquery-qrcode/issues/2\nThere appears to be a typeNumber property that can be changed upon creation. It appears that changing this from it's default of 4 to higher numbers (ie. 8 or so) increase... | [
3
] | [] | [] | [
"django",
"javascript",
"jquery",
"python",
"qr_code"
] | stackoverflow_0006338106_django_javascript_jquery_python_qr_code.txt |
Q:
Problems with Forms, using POST method with Mechanize in Python
I was trying to fill a form using mechanize in python, it didn't work with normal submit(). Somehow mechanize didn't manage to parse the radio buttons and found only 1 instead of 4. After that I tried to write a POST request -
data = {
'lo... | Problems with Forms, using POST method with Mechanize in Python | I was trying to fill a form using mechanize in python, it didn't work with normal submit(). Somehow mechanize didn't manage to parse the radio buttons and found only 1 instead of 4. After that I tried to write a POST request -
data = {
'localid' : '11755',
'language' : '3',
'code' : 'hello w... | [
"sounds like mechanize is having trouble parsing the form, try something along these lines\nbr = mechanize.Browser()\nresp = br.open('your_url_here')\nprint resp.get_data() # if you want to see what's returned\n# if you want to see the forms, so you can find the index of the\n# form you want and check that is has a... | [
2
] | [] | [] | [
"forms",
"mechanize",
"post",
"python",
"radio_button"
] | stackoverflow_0006328502_forms_mechanize_post_python_radio_button.txt |
Q:
PyQuery for Python3
So according to this here PyQuery is "Python3 compatible", but I can't find any information about how to actually install it, since it still seems to be dependent on setuptools which is python2.x only.
I also tried to newest source from bitbucket that contains a bootstrap-py3k.py but that fails... | PyQuery for Python3 | So according to this here PyQuery is "Python3 compatible", but I can't find any information about how to actually install it, since it still seems to be dependent on setuptools which is python2.x only.
I also tried to newest source from bitbucket that contains a bootstrap-py3k.py but that fails just as well - actually ... | [
"Install distribute, which is a drop-in replacement for setuptools and has py3k support.\n"
] | [
4
] | [] | [] | [
"pyquery",
"python",
"python_3.x"
] | stackoverflow_0006338188_pyquery_python_python_3.x.txt |
Q:
How to use SQLAlchemy in this context
I want to do the following:
Have a software running written in Python 2.7
This software connects to a database (Currently a MySQL database)
This software listen for connections on a port X on TCP
When a connection is established, a client x request or command something, then ... | How to use SQLAlchemy in this context | I want to do the following:
Have a software running written in Python 2.7
This software connects to a database (Currently a MySQL database)
This software listen for connections on a port X on TCP
When a connection is established, a client x request or command something, then the software use the database to store, rem... | [
"What is the problem here? SQLAlchemy maintains a thread-local connection pool..what else do you need?\n"
] | [
1
] | [] | [] | [
"python",
"sqlalchemy"
] | stackoverflow_0006337812_python_sqlalchemy.txt |
Q:
Python - multiple HTML page parsing to a single TXT file
I'm trying to parse specific content from an X number of HTML files to a single TXT file.
I have dirtily coded the following:
#!/usr/bin/python
import sys, mechanize, BeautifulSoup
def parsedata():
##do stuff
prvitekst = soup.find(text='Random Numbe... | Python - multiple HTML page parsing to a single TXT file | I'm trying to parse specific content from an X number of HTML files to a single TXT file.
I have dirtily coded the following:
#!/usr/bin/python
import sys, mechanize, BeautifulSoup
def parsedata():
##do stuff
prvitekst = soup.find(text='Random Number')
prvikesh = prvitekst.findNextSiblings('td')
drugit... | [
"html='''\n<tr style=\"height:40px; background-color:#f0f0f0;\"><td colspan=\"4\" class=\"textLargeBold\" style=\"border-bottom: solid 1px #c4c4c4;\">Random Details</td></tr> <tr class=\"text\"> <td align=\"left\" valign=\"top\"><b>Type</b></td> <td align=\"left\" valign=\"top\">Color</td> <td align=\"left\" valig... | [
0
] | [] | [] | [
"beautifulsoup",
"csv",
"html_parsing",
"python"
] | stackoverflow_0006318283_beautifulsoup_csv_html_parsing_python.txt |
Q:
Is There a Way to Return a String Concatenation in Python?
I've been using Perl for some time and have gotten used to the syntax:
return "$var1$var2";
for easily returning a concatenation of two strings in one step. Is there a way to do something similar in Python? I'd love to avoid doing it in two steps, if poss... | Is There a Way to Return a String Concatenation in Python? | I've been using Perl for some time and have gotten used to the syntax:
return "$var1$var2";
for easily returning a concatenation of two strings in one step. Is there a way to do something similar in Python? I'd love to avoid doing it in two steps, if possible.
| [
"Simple:\n>>> \"a\" + \"b\"\n'ab'\n>>> \"%s%s\" % (\"a\", \"b\")\n'ab'\n>>> \"{a}{b}\".format(a=\"a\", b=\"b\")\n'ab'\n>>> \"{}{}\".format(\"a\", \"b\")\n'ab'\n>>> \"{0}{1}\".format(\"a\", \"b\")\n'ab'\n>>> \"a\" \"b\"\n'ab'\n>>> \"\".join((\"a\", \"b\"))\n'ab'\n\n",
"I don't see how addition is two steps.\nretur... | [
11,
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0006338910_python.txt |
Q:
App Engine query for all objects with an existing property
I'd like to do a query that returns all entities for which a particular property exists. I don't care about the vale of the property, just that it exists. What is a good way to do this on python for app engine?
Thanks!
A:
Filtering Or Sorting On a Prop... | App Engine query for all objects with an existing property | I'd like to do a query that returns all entities for which a particular property exists. I don't care about the vale of the property, just that it exists. What is a good way to do this on python for app engine?
Thanks!
| [
"\nFiltering Or Sorting On a Property Requires That the Property Exists\nIf a property has a query filter condition or sort order, the query returns only those datastore entities that have a value (including null) for that property.\n\nhttp://code.google.com/appengine/docs/python/datastore/queries.html#Restrictions... | [
2
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0006338959_google_app_engine_python.txt |
Q:
how to url-safe encode a string with python? and urllib.quote is wrong
Hello i was wondering if you know any other way to encode a string to a url-safe, because urllib.quote is doing it wrong, the output is different than expected:
If i try
urllib.quote('á')
i get
'%C3%A1'
But thats not the correct output, it sh... | how to url-safe encode a string with python? and urllib.quote is wrong | Hello i was wondering if you know any other way to encode a string to a url-safe, because urllib.quote is doing it wrong, the output is different than expected:
If i try
urllib.quote('á')
i get
'%C3%A1'
But thats not the correct output, it should be
%E1
As demostrated by the tool provided here this site
And this... | [
"According to RFC 3986, %C3%A1 is correct. Characters are supposed to be converted to an octet stream using UTF-8 before the octet stream is percent-encoded. The site you link is out of date.\nSee Why does the encoding's of a URL and the query string part differ? for more detail on the history of handling non-ASCII... | [
7,
3,
0,
0,
0
] | [] | [] | [
"encoding",
"python",
"url_rewriting"
] | stackoverflow_0006338469_encoding_python_url_rewriting.txt |
Q:
How do I get the actual cursor.rowcount upon .commit?
I'm using MySQLdb in Python.
I have an update that may succeed or fail:
UPDATE table
SET reserved_by = PID
state = "unavailable"
WHERE state = "available"
AND id = REQUESTED_ROW_ID
LIMIT 1;
As you may be able to infer, multiple proc... | How do I get the actual cursor.rowcount upon .commit? | I'm using MySQLdb in Python.
I have an update that may succeed or fail:
UPDATE table
SET reserved_by = PID
state = "unavailable"
WHERE state = "available"
AND id = REQUESTED_ROW_ID
LIMIT 1;
As you may be able to infer, multiple processes are using the database, and I need processes to be ab... | [
"Turn autocommit on. \nThe commit operation just \"confirms\" updates already done. The alternative is rollback, which \"undoes\" any updates already made.\n"
] | [
0
] | [] | [] | [
"connect",
"mysql",
"mysql_python",
"python",
"rowcount"
] | stackoverflow_0006337798_connect_mysql_mysql_python_python_rowcount.txt |
Q:
Python: Matplotlib - probability plot for several data set
I have several data sets (distribution) as follows:
set1 = [1,2,3,4,5]
set2 = [3,4,5,6,7]
set3 = [1,3,4,5,8]
How do I plot a scatter plot with the data sets above with the y-axis being the probability (i.e. the percentile of the distribution in set: 0%-10... | Python: Matplotlib - probability plot for several data set | I have several data sets (distribution) as follows:
set1 = [1,2,3,4,5]
set2 = [3,4,5,6,7]
set3 = [1,3,4,5,8]
How do I plot a scatter plot with the data sets above with the y-axis being the probability (i.e. the percentile of the distribution in set: 0%-100% ) and the x-axis being the data set names?
in JMP, it is call... | [
"I'm not entirely clear on what you want, so I'm going to guess, here...\nYou want the \"Probability/Percentile\" values to be a cumulative histogram?\nSo for a single plot, you'd have something like this? (Plotting it with markers as you've shown above, instead of the more traditional step plot...)\nimport scipy.s... | [
11
] | [] | [] | [
"matplotlib",
"numpy",
"percentile",
"probability",
"python"
] | stackoverflow_0006326360_matplotlib_numpy_percentile_probability_python.txt |
Q:
python split and evaluate
How might I split a string (with postfix) into one with parentheses? What I mean is, if the user inputs 3 (3 6 *) * I want the interpreter to be able to multiply 3 18 * and understand the parentheses in the text. Is this possible? Like a str.split() but with a start and end delimiter?
Am ... | python split and evaluate | How might I split a string (with postfix) into one with parentheses? What I mean is, if the user inputs 3 (3 6 *) * I want the interpreter to be able to multiply 3 18 * and understand the parentheses in the text. Is this possible? Like a str.split() but with a start and end delimiter?
Am I not being realistic? I found ... | [
"I don't think using re is such a bad idea. You could just go through replacing the nested parenthesis one at a time with the result of their operation. Seems pretty straight forward to me:\nimport re\nregex = re.compile(r'\\([^\\(\\)]+\\)')\n\ndef eval_expr(expr):\n match = regex.search(expr)\n if match:\n ... | [
3,
1,
0,
0,
0
] | [] | [] | [
"python",
"split",
"string"
] | stackoverflow_0006338061_python_split_string.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.