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:
PyQT call QDialog form QMainWidget
I need to open some dialogs in my MainWidget application. When I call exec_() function dialog window appears but has nothing. I cannot even set up the title. Here some example of problem:
import sys
from PyQt4 import QtGui, QtCore
class prceditor(QtGui.QDialog):
def __init__... | PyQT call QDialog form QMainWidget | I need to open some dialogs in my MainWidget application. When I call exec_() function dialog window appears but has nothing. I cannot even set up the title. Here some example of problem:
import sys
from PyQt4 import QtGui, QtCore
class prceditor(QtGui.QDialog):
def __init__(self, parent=None):
QtGui.QDia... | [
"Your problem is typo. You typed the overriden constructor of class prceditor with only one underscore after init instead of two underscores. The overriden version was never executed.\n"
] | [
2
] | [] | [] | [
"pyqt4",
"python"
] | stackoverflow_0005682934_pyqt4_python.txt |
Q:
How to correctly sort a string with a number inside?
I have a list of strings containing numbers and I cannot find a good way to sort them.
For example I get something like this:
something1
something12
something17
something2
something25
something29
with the sort() method.
I know that I probably need to extract th... | How to correctly sort a string with a number inside? | I have a list of strings containing numbers and I cannot find a good way to sort them.
For example I get something like this:
something1
something12
something17
something2
something25
something29
with the sort() method.
I know that I probably need to extract the numbers somehow and then sort the list but I have no ide... | [
"Perhaps you are looking for human sorting (also known as natural sorting):\nimport re\n\ndef atoi(text):\n return int(text) if text.isdigit() else text\n\ndef natural_keys(text):\n '''\n alist.sort(key=natural_keys) sorts in human order\n http://nedbatchelder.com/blog/200712/human_sorting.html\n (Se... | [
325
] | [] | [] | [
"python",
"regex",
"sorting",
"string"
] | stackoverflow_0005967500_python_regex_sorting_string.txt |
Q:
How can I remember which of list.append and list.extend is which in Python?
In Python, lists have two methods for adding elements to the end: "append" and "extend". One of them adds a single element to the list, and the other adds every element from an iterable to the end of the list. Do you know which is which? D... | How can I remember which of list.append and list.extend is which in Python? | In Python, lists have two methods for adding elements to the end: "append" and "extend". One of them adds a single element to the list, and the other adds every element from an iterable to the end of the list. Do you know which is which? Did you know without having to look it up? If so, could you please share your secr... | [
"At least for me their literal meaning itself is clear enough to make the distinction between them. \nOne of the dictionary definition for append : Add to the very end\nOne of the dictionary definition for extend : Stretch out over a distance, space, time, or scope; run or extend between two points or beyond a cert... | [
6,
1,
1,
0,
0
] | [] | [] | [
"list",
"methods",
"naming",
"python"
] | stackoverflow_0005958929_list_methods_naming_python.txt |
Q:
Google search Python script, without using APIs
Most of the Google search python scripts use either WWW::Mechanize or Google APIs.
How to write a script without using these and JSON objects?
A:
You can construct the URL for the query yourself, if you like, and then make a request using urllib2 or something of th... | Google search Python script, without using APIs | Most of the Google search python scripts use either WWW::Mechanize or Google APIs.
How to write a script without using these and JSON objects?
| [
"You can construct the URL for the query yourself, if you like, and then make a request using urllib2 or something of the like. The URLs for Google search queries are explained here.\nOf course, really, there's no shame in just using the APIs.\n"
] | [
0
] | [] | [] | [
"python",
"search"
] | stackoverflow_0005959749_python_search.txt |
Q:
Python wrapper to access Hg, Git and possibly Bazaar repositories?
I'm looking for a Python library that can do basic manipulation of repositories, but is independent of the backend version control system.
By basic manipulation, I'm referring to: initialize a repo, add files, commit, pull, push, get current revisi... | Python wrapper to access Hg, Git and possibly Bazaar repositories? | I'm looking for a Python library that can do basic manipulation of repositories, but is independent of the backend version control system.
By basic manipulation, I'm referring to: initialize a repo, add files, commit, pull, push, get current revision number.
Users of the library could do something this:
import dvcs_wra... | [
"There's also the VCS module, which advertises:\n\nvcs is abstraction layer over various version control systems. It is\n designed as feature-rich Python library with clean API.\n\n",
"I think you are out of luck.\nThere are Python wrappers for git but according to this the quality is still less than optimal. Hg... | [
5,
4
] | [] | [] | [
"dvcs",
"git",
"mercurial",
"python",
"wrapper"
] | stackoverflow_0005944390_dvcs_git_mercurial_python_wrapper.txt |
Q:
How to import a user module which has the same name with a system module?
I have a legacy python program which defined a module whose name conflict with a system module in the current python, what's the easiest method to fix this? This module has been imported in many place, so it would be great if no need to chan... | How to import a user module which has the same name with a system module? | I have a legacy python program which defined a module whose name conflict with a system module in the current python, what's the easiest method to fix this? This module has been imported in many place, so it would be great if no need to change the the old python source.
| [
"You could create a custom import routine using the imp module. For example, here I'm importing a module named string which shadows the real string module:\nimport imp\n\ndef user_import(name, path):\n mod_file, mod_path, mod_desc = imp.find_module(name, [path])\n return imp.load_module(name, mod_file, mod_p... | [
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0005967858_python.txt |
Q:
I want make a query in django opposing of where?
E.g I have the models
class Question(models.Model):
question = models.CharField(max_length="200")
class Answer(models.Model):
question= models.ForeignKey(Question)
So, I want all Question's that I don't have in Answers
E.g In answer I have
Question 1
Ques... | I want make a query in django opposing of where? | E.g I have the models
class Question(models.Model):
question = models.CharField(max_length="200")
class Answer(models.Model):
question= models.ForeignKey(Question)
So, I want all Question's that I don't have in Answers
E.g In answer I have
Question 1
Question 2
and in Question I have
Question 1
Question 2
Q... | [
"I think what you want is:\nunanswered_questions = Question.objects.filter(answer__isnull=True)\n\n",
"The easiest way is to first get a distinct list of all question IDs in Answer, then get all Questions that do not have one of those IDs\nids = Answer.objects.all().distinct().values_list('question', Flat=True)\n... | [
6,
0
] | [] | [] | [
"django",
"models",
"python"
] | stackoverflow_0005968030_django_models_python.txt |
Q:
Algorithm in Python To Solve This Problem
I have a list of lists such as: [[foo,1],[baz,1],[foo,0],[bar,3],[foo,1],[bar,2],[baz,2]].
I want to get all the different items in the inner lists and find the total number of them.
I mean the result should be like: [[foo,2],[bar,5],[baz,3]]. How can I do this task?
Thank... | Algorithm in Python To Solve This Problem | I have a list of lists such as: [[foo,1],[baz,1],[foo,0],[bar,3],[foo,1],[bar,2],[baz,2]].
I want to get all the different items in the inner lists and find the total number of them.
I mean the result should be like: [[foo,2],[bar,5],[baz,3]]. How can I do this task?
Thanks in advance.
| [
"Create a dictionary\nD = {}\nfor item in list:\n left,right=item\n D[left] = D.get(left, 0) + right\n\nThere may be faster ways to do this though.\nAs suggested in the comments by Joce, Gnibbler and Blair you coud do this to get a list again.\n# To get a list of lists\npairs = map(list, D.items()) \n# To get a l... | [
6,
4,
0,
0
] | [] | [] | [
"algorithm",
"python"
] | stackoverflow_0005945427_algorithm_python.txt |
Q:
Synchronized set in Python
Is there a synchronized set class in Python? Like Queue.Queue? I'm sending messages to a JMS queue and need to handle reciepts:
Keep track of sent messages in a set
When a receipt is received, removed it from the set
When the set is empty, set an Event
Something with the same interface... | Synchronized set in Python | Is there a synchronized set class in Python? Like Queue.Queue? I'm sending messages to a JMS queue and need to handle reciepts:
Keep track of sent messages in a set
When a receipt is received, removed it from the set
When the set is empty, set an Event
Something with the same interface as Queue would be perfect, but ... | [
"Look for object Locking.\nhttp://docs.python.org/library/threading.html\nBasicly, you lock the thread's execution based on an object. When you're done with the object, you release it and the thread continues.\n",
"Well Queue.Queue use a deque under the hood (and deque is not thread safe).\nSo what you can do is ... | [
2,
2
] | [] | [] | [
"multithreading",
"python"
] | stackoverflow_0005968513_multithreading_python.txt |
Q:
PIL problems: failed in loading any font library and using unicode
I newly installed PIL. But I find:
I can't load any font lib using
"ImageFont.truetype("xxx.ttc", 50)"
and the like.
When I render some text to image,
and the text is unicode containing
Chinese characters, I get
UnicodeEncodeError like:
UnicodeEn... | PIL problems: failed in loading any font library and using unicode | I newly installed PIL. But I find:
I can't load any font lib using
"ImageFont.truetype("xxx.ttc", 50)"
and the like.
When I render some text to image,
and the text is unicode containing
Chinese characters, I get
UnicodeEncodeError like:
UnicodeEncodeError: 'ascii' codec
can't encode character u'\u6211' in
positi... | [
"It works fine on Ubuntu10.10 with python 2.6.6\nPerhaps try using the absolute path to the tcc font?\nThis is the code that runs flawlessly:\n#! /usr/bin/python\n# -*- coding: utf-8 -*-\n\nimport Image\nimport ImageDraw\nimport ImageFont\n\nttfont = ImageFont.truetype ('/usr/share/fonts/truetype/wqy/wqy-microhei.t... | [
0
] | [] | [] | [
"fonts",
"python",
"python_imaging_library",
"unicode"
] | stackoverflow_0005962876_fonts_python_python_imaging_library_unicode.txt |
Q:
Roll-out of a python project
I'm looking for some information about the roll-out of a python project that uses several external libraries wrapped for python. Are there tools for this? What kind of external files do I need to use my project on anonther PC? Dlls? .pyd? What else? What to do with user- and pythonpath... | Roll-out of a python project | I'm looking for some information about the roll-out of a python project that uses several external libraries wrapped for python. Are there tools for this? What kind of external files do I need to use my project on anonther PC? Dlls? .pyd? What else? What to do with user- and pythonpath?
Background: I'm working on a C++... | [
"The answer is highly dependent on what libraries you are using, how they are installed, which platforms you will deploy to etc.\nTake a look at\n\nPip (dependency handling, installation)\nVirtualenv (python environment sandboxing)\nFabric (automation)\n\n"
] | [
4
] | [] | [] | [
"pyqt4",
"python",
"vtk"
] | stackoverflow_0005968951_pyqt4_python_vtk.txt |
Q:
How to set Selenium browsers to treat Selenium's hub as a proxy server in python on Selenium Grid?
I'm running Selenium 2.0b4dev on Selenium Grid in Ubuntu 10.04, using Python code to write test cases. I've been having trouble with getting basic HTTP authentication to a specific site working, and with a quick goog... | How to set Selenium browsers to treat Selenium's hub as a proxy server in python on Selenium Grid? | I'm running Selenium 2.0b4dev on Selenium Grid in Ubuntu 10.04, using Python code to write test cases. I've been having trouble with getting basic HTTP authentication to a specific site working, and with a quick google search found that my problem could be solved with the addition of the line self.selenium.add_custom_r... | [
"I wrote up an article on how to do this in Ruby. It links to a complementary article on testing self-signed certificates and gives you the set of flags you need to launch Selenium with.\nhttp://mogotest.com/blog/2010/06/23/how-to-perform-basic-auth-in-selenium\nTo pass args through from grid to the underlying RC ... | [
1
] | [] | [] | [
"proxy",
"python",
"selenium",
"selenium_grid"
] | stackoverflow_0005954704_proxy_python_selenium_selenium_grid.txt |
Q:
Python bytearray ignoring encoding?
I've got a chunk of code that reads binary data off a string buffer (StringIO object), and tries to convert it to a bytearray object, but it's throwing errors when the value is greater than 127, which the ascii encoding can't handle, even when I'm trying to override it:
file = ... | Python bytearray ignoring encoding? | I've got a chunk of code that reads binary data off a string buffer (StringIO object), and tries to convert it to a bytearray object, but it's throwing errors when the value is greater than 127, which the ascii encoding can't handle, even when I'm trying to override it:
file = open(filename, 'r+b')
file.seek(offset)
c... | [
"When converting a string to another encoding, its original encoding is taken to be ASCII if it is a str or Unicode if it is a unicode object. When creating the bytearray, the encoding parameter is required only if the string is unicode. Just don't specify an encoding and you will get the results you want.\n",
"I... | [
9,
2
] | [] | [] | [
"python"
] | stackoverflow_0005969014_python.txt |
Q:
Problem with django-avatar
I'm trying to implement django-avatar in my Django app on a production server.
The problem is that the form for upload images accepts every type of files! This means a user can upload also a file.php. So, I thought django-avatar handle this. How can I fix? I want the form accepts only im... | Problem with django-avatar | I'm trying to implement django-avatar in my Django app on a production server.
The problem is that the form for upload images accepts every type of files! This means a user can upload also a file.php. So, I thought django-avatar handle this. How can I fix? I want the form accepts only images.
| [
"The most current version of django-avatar contains the fix to only allow image uploads. What version are you using? The pypi version (currently 1.0) is old and does not contain the updates.\nDownload the newest version from https://github.com/ericflo/django-avatar\n"
] | [
2
] | [] | [] | [
"django",
"python"
] | stackoverflow_0005969246_django_python.txt |
Q:
Python sqlite index out of range error after table drop/add?
I've got a wrapper I wrote around the sqlite3 module that lets me serialize access from multiple threads. It also lets me automatically migrate tables when I change their definition. I noticed when I drop a table and re-add it with more columns, I get ... | Python sqlite index out of range error after table drop/add? | I've got a wrapper I wrote around the sqlite3 module that lets me serialize access from multiple threads. It also lets me automatically migrate tables when I change their definition. I noticed when I drop a table and re-add it with more columns, I get an index out of range error. Something like this:
conn = sqlite3.... | [
"Well, it works just fine for me\n[(u'deedle',)]\n[(u'deedle', None)]\n"
] | [
1
] | [] | [] | [
"python",
"python_2.5",
"sqlite"
] | stackoverflow_0005969399_python_python_2.5_sqlite.txt |
Q:
File input to gnuplot through python
I am trying to draw a graph of some data I pull out of a MySQL database through python with gnuplot and gnuplot.py.
I read the latest 10 lines of data from the MySQL database and store them in a temp file which is supposed to be read by gnuplot. I can do this the manual way by ... | File input to gnuplot through python | I am trying to draw a graph of some data I pull out of a MySQL database through python with gnuplot and gnuplot.py.
I read the latest 10 lines of data from the MySQL database and store them in a temp file which is supposed to be read by gnuplot. I can do this the manual way by setting through the terminal, but I simply... | [
"This doesn't work because after you write the file object's cursor is at the end of the file. If you want to really do this (you are better off not writing the data to a file at all), you need to move the cursor back to the beginning of the file:\ndatafile.seek(0)\n\nNow you can read() from the beginning of the fi... | [
2
] | [] | [] | [
"gnuplot",
"mysql",
"python"
] | stackoverflow_0005968721_gnuplot_mysql_python.txt |
Q:
Simple string match
I want to do a simple string match, searching from the -front- of the string. Are there easier ways to do this with maybe a builtin? (re seems like overkill)
def matchStr(ipadr = '10.20.30.40', matchIP = '10.20.'):
if ipadr[0:len(matchIP)] == matchIP: return True
return False
A:
def ... | Simple string match | I want to do a simple string match, searching from the -front- of the string. Are there easier ways to do this with maybe a builtin? (re seems like overkill)
def matchStr(ipadr = '10.20.30.40', matchIP = '10.20.'):
if ipadr[0:len(matchIP)] == matchIP: return True
return False
| [
"def matchStr(ipadr = '10.20.30.40', matchIP = '10.20.'):\n return ipadr.startswith(matchIP)\n\n",
">>> 'abcde'.startswith('abc')\nTrue\n\n",
"'10.20.30.40'.startswith('10.20.')\n>>>True\n\n"
] | [
7,
1,
1
] | [] | [] | [
"python",
"string_matching"
] | stackoverflow_0005969465_python_string_matching.txt |
Q:
Dumping a subclass of gtk.ListStore using pickle
I am trying to dump a custom class using pickle. The class was subclassed from gtk.ListStore, since that made it easier to store particular data and then display it using gtk. This can be reproduced as shown here.
import gtk
import pickle
import os
class foo(gtk.... | Dumping a subclass of gtk.ListStore using pickle | I am trying to dump a custom class using pickle. The class was subclassed from gtk.ListStore, since that made it easier to store particular data and then display it using gtk. This can be reproduced as shown here.
import gtk
import pickle
import os
class foo(gtk.ListStore):
pass
if __name__=='__main__':
x =... | [
"With this method you can even use json instead of pickle for your purpose.\nHere is a quick working example to show you the steps you need to employ to pickle \"unpicklable types\" like gtk.ListStore. Essentially you need to do a few things:\n\nDefine __reduce__ which returns a function and arguments needed to rec... | [
1,
0
] | [] | [] | [
"getstate",
"gtk",
"pickle",
"python"
] | stackoverflow_0005968204_getstate_gtk_pickle_python.txt |
Q:
ValueError occurs when I try to use CG algorithm of MaxentClassifier in nltk
When I tried the examples of MaxentClassifier from http://nltk.googlecode.com/svn/trunk/doc/howto/classify.html, I got the error below:
Grad eval #0
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
classifi... | ValueError occurs when I try to use CG algorithm of MaxentClassifier in nltk | When I tried the examples of MaxentClassifier from http://nltk.googlecode.com/svn/trunk/doc/howto/classify.html, I got the error below:
Grad eval #0
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
classifier = MaxentClassifier.train(train)
File "C:\Python27\lib\site-packages\nltk\clas... | [
"It works if you set the algorithm:\n>>> algorithm = nltk.classify.MaxentClassifier.ALGORITHMS[0]\n>>> algorithm\n'GIS'\n>>> classifier = nltk.MaxentClassifier.train(train, algorithm)\n\n ==> Training (100 iterations)\n\n Iteration Log Likelihood Accuracy\n ---------------------------------------\n... | [
3
] | [] | [] | [
"classification",
"nltk",
"python"
] | stackoverflow_0005754492_classification_nltk_python.txt |
Q:
Django IntegrityError
I have a little project I am working. I am writing django database to hold some data. I have one ManyToManyField.
I am using my own Manager and adding methods for convience. I have one that adds different tasks to the users to do list. These items can be assigned to many people and so on.
W... | Django IntegrityError | I have a little project I am working. I am writing django database to hold some data. I have one ManyToManyField.
I am using my own Manager and adding methods for convience. I have one that adds different tasks to the users to do list. These items can be assigned to many people and so on.
When I do this I am getting ... | [
"Turns out all I needed to do was clean out my database with a python manage.py sqlflush Everything was fine afterwards. I then added south to help with migrations in the future. \nI would advise caution since sqlflush will return your database to back the state of the last syncdb.\n",
"Create and add items to th... | [
3,
0
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0005450881_django_django_models_python.txt |
Q:
Removing redundancy when adding items to Python dictionaries
Suppose you have a dictionary like:
my_dict = {'foo' : {'bar' : {}}}
And you want to make the following sequence of assignments:
my_dict['foo']['bar']['first'] = 1
my_dict['foo']['bar']['second'] = 2
Clearly there is some redundancy in the fact that my... | Removing redundancy when adding items to Python dictionaries | Suppose you have a dictionary like:
my_dict = {'foo' : {'bar' : {}}}
And you want to make the following sequence of assignments:
my_dict['foo']['bar']['first'] = 1
my_dict['foo']['bar']['second'] = 2
Clearly there is some redundancy in the fact that my_dict['foo']['bar'] is repeated. Is there any way to prevent this ... | [
"Not really, save of course the obvious intermediate variable:\nfoo_bar = my_dict['foo']['bar']\nfoo_bar['first'] = 1\nfoo_bar['second'] = 2\n\nHow is Python supposed to know you want to refer to the same dictionary twice unless you tell it like this?\n",
"You could do:\nmy_dict['foo']['bar'].update({'first': 1, ... | [
8,
5,
3
] | [] | [] | [
"python"
] | stackoverflow_0005970161_python.txt |
Q:
Sqlalchemy: Get some columns aliased
I have a question that I'm sure it's very quick to answer, but I haven't been able to find it googling...
I have a class Product defined with declarative SqlAlchemy:
class Product(declarativeBase):
__tablename__ = "products"
_brand = Column("brand", Unicode(128))
_s... | Sqlalchemy: Get some columns aliased | I have a question that I'm sure it's very quick to answer, but I haven't been able to find it googling...
I have a class Product defined with declarative SqlAlchemy:
class Product(declarativeBase):
__tablename__ = "products"
_brand = Column("brand", Unicode(128))
_series = Column("series", String(128))
... | [
"Actually... I think \"label\" may work.\nHow do I put a SQLAlchemy label on the result of an arithmetic expression?\nIf it does, I'll detail it here\n"
] | [
0
] | [] | [] | [
"python",
"sqlalchemy"
] | stackoverflow_0005970112_python_sqlalchemy.txt |
Q:
Problem When Using More Than Two Wildcards
I am trying to write a program that will take specified letters and wildcard characters('*') and check them against words in a list to print all available matches. I have written the below code which will work when two wildcard characters are used:
def wildcard_search(let... | Problem When Using More Than Two Wildcards | I am trying to write a program that will take specified letters and wildcard characters('*') and check them against words in a list to print all available matches. I have written the below code which will work when two wildcard characters are used:
def wildcard_search(letters, count):
alpha = 'abcdefghijklmnopqrstu... | [
"Use fnmatch.filter. Basically, it implements shell-like pattern matching using the re module, and does exactly what you want.\n"
] | [
1
] | [] | [] | [
"python"
] | stackoverflow_0005707931_python.txt |
Q:
Cleaner assignment in for loop (python)
I have a nodelist object that yields a bunch of node objects on iteration. I need to increment these nodes based on some random condition (like node.x > 17). Here's what I'm doing right now:
for node in nodelist:
if node.x > 17:
node.x += 1
I can't do map(lam... | Cleaner assignment in for loop (python) | I have a nodelist object that yields a bunch of node objects on iteration. I need to increment these nodes based on some random condition (like node.x > 17). Here's what I'm doing right now:
for node in nodelist:
if node.x > 17:
node.x += 1
I can't do map(lambda node: node.x += 1, nodelist) because lamb... | [
"I think it's already pretty short and clean. Python provides some powerful tools, but sometimes simple is best; this seems like one of those times. \nI also think what you have is more readable than any equivalent one-liner (that I can come up with).\n\nOk, that said, you could do this:\nfor node in (n for n in no... | [
7,
3,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0005969110_python.txt |
Q:
Convert type into python
I'm using boost python. I've exported some function which takes class CL_DomElement in arguments. Now, when I run app I have:
TypeError: No to_python (by-value) converter found for C++ type: CL_DomElement
So what about code. I've exported function which takes function-pointer in arguments... | Convert type into python | I'm using boost python. I've exported some function which takes class CL_DomElement in arguments. Now, when I run app I have:
TypeError: No to_python (by-value) converter found for C++ type: CL_DomElement
So what about code. I've exported function which takes function-pointer in arguments. Here is the code:
typedef bo... | [
"Boost.Python call by reference : TypeError: No to_python (by-value) converter found for C++ type:\n"
] | [
1
] | [] | [] | [
"boost",
"c++",
"export",
"python",
"types"
] | stackoverflow_0005500952_boost_c++_export_python_types.txt |
Q:
Working with tags in Tkinter text widget using python
I'm trying color the text in the Tkinter text widget with help of tags in this way:
text = self.text_field.get(1.0, 'end') #text_field is a text widget
s = re.findall("\d+", text)
for i in s:
self.text_field.tag_add(i, '1.0', 'end')
self.text_field.tag_... | Working with tags in Tkinter text widget using python | I'm trying color the text in the Tkinter text widget with help of tags in this way:
text = self.text_field.get(1.0, 'end') #text_field is a text widget
s = re.findall("\d+", text)
for i in s:
self.text_field.tag_add(i, '1.0', 'end')
self.text_field.tag_configure(i, background='yellow',
... | [
"When you do\ntag_add(i, '1.0', 'end')\n\nYou're making a tag that covers the whole text field. You need to just add the text on the numbers, using the .start() and .stop() methods of the regex match.\nThere's an example for doing syntax highlighting here:\nhttp://forums.devshed.com/python-programming-11/syntax-hig... | [
4,
4
] | [] | [] | [
"python",
"tags",
"text",
"tkinter"
] | stackoverflow_0005967621_python_tags_text_tkinter.txt |
Q:
Testing Django database manipulation scripts with test database
I am attempting to setup the django testing environment to test a script we use to load data into our data visualization web app. It is "external" to the actual django app, so it doesn't seem appropriate or clean to use the manage.py test facility.
I... | Testing Django database manipulation scripts with test database | I am attempting to setup the django testing environment to test a script we use to load data into our data visualization web app. It is "external" to the actual django app, so it doesn't seem appropriate or clean to use the manage.py test facility.
I have followed the instructions found in the django docs to write my ... | [
"Strictly speaking, test databases are intended to be created, used to run unit tests and then destroyed. They're not really a place to \"test\" a data loading script. Why not just use your standard dev database? There shouldn't be anything there that you can't get back, have a backup for, etc., and it's pretty muc... | [
1,
0
] | [] | [] | [
"django",
"python",
"unit_testing"
] | stackoverflow_0005970377_django_python_unit_testing.txt |
Q:
Problem with Python and IP camera
I'm having problems to get a video stream from a IP camera I have. I'm using opencv to get the images from it. Here's the code i have:
import sys
import cv
video="http://prot-on.dyndns.org:8080/video2.mjpeg"
capture =cv.CaptureFromFile(video)
cv.NamedWindow('Video Stream', 1 )
wh... | Problem with Python and IP camera | I'm having problems to get a video stream from a IP camera I have. I'm using opencv to get the images from it. Here's the code i have:
import sys
import cv
video="http://prot-on.dyndns.org:8080/video2.mjpeg"
capture =cv.CaptureFromFile(video)
cv.NamedWindow('Video Stream', 1 )
while True:
# capture the current frame... | [
"First, mjpeg is a relatively simple video format. If you read your IP camera's manual, it's very like that you can find how to display the video in browser with a bit JavaScript code. In fact, if you open link of http://prot-on.dyndns.org:8080/video2.mjpeg in Google Chrome, you would see the video without any pro... | [
1
] | [] | [] | [
"opencv",
"python"
] | stackoverflow_0005968508_opencv_python.txt |
Q:
Reading and writing environment variables in Python?
My python script which calls many python functions and shell scripts. I want to set a environment variable in Python (main calling function) and all the daughter processes including the shell scripts to see the environmental variable set.
I need to set some envi... | Reading and writing environment variables in Python? | My python script which calls many python functions and shell scripts. I want to set a environment variable in Python (main calling function) and all the daughter processes including the shell scripts to see the environmental variable set.
I need to set some environmental variables like this:
DEBUSSY 1
FSDB 1
1 is a nu... | [
"Try using the os module.\nimport os\n\nos.environ['DEBUSSY'] = '1'\nos.environ['FSDB'] = '1'\n\n# Open child processes via os.system(), popen() or fork() and execv()\n\nsomeVariable = int(os.environ['DEBUSSY'])\n\nSee the Python docs on os.environ. Also, for spawning child processes, see Python's subprocess docs.\... | [
340,
39,
3,
1
] | [] | [] | [
"environment_variables",
"python"
] | stackoverflow_0005971635_environment_variables_python.txt |
Q:
I'm trying to get all the processes and applications that are currently running using Python on Windows 7
I'm currently running Windows 7, and I'd like to be able to check whats going on programaticly using Python. How would I go about getting all the currently runing processes and applications?
A:
Get the WMI m... | I'm trying to get all the processes and applications that are currently running using Python on Windows 7 | I'm currently running Windows 7, and I'd like to be able to check whats going on programaticly using Python. How would I go about getting all the currently runing processes and applications?
| [
"Get the WMI module and then check out this cookbook for some simple examples. Note this is not the most efficient way, talking to the win32 api with ctypes is faster but much much more legwork.\nTo list all currently running processes:\nimport wmi\nc = wmi.WMI ()\n\nfor process in c.Win32_Process ():\n print pr... | [
1,
1
] | [] | [] | [
"process",
"python",
"windows_7"
] | stackoverflow_0005971743_process_python_windows_7.txt |
Q:
Windows 7 and git: how to invoke git from a system() call in a script
I am on a windows 7 box that has msysgit installed. I also have a ruby script where I am trying to invoke git using a system() call.
system("C:/Programs/msysgit/bin/git.exe")
This does not work. Does anyone know how to get this running? I've d... | Windows 7 and git: how to invoke git from a system() call in a script | I am on a windows 7 box that has msysgit installed. I also have a ruby script where I am trying to invoke git using a system() call.
system("C:/Programs/msysgit/bin/git.exe")
This does not work. Does anyone know how to get this running? I've done it on Win XP before, but cannot seem to get it working. Any example wit... | [
"you need to be in a working tree of a repository. Or, some git commands allow --git-dir parameter to indicate where the repository is. The current directory that git.exe is running in is probably not a repository.\n",
"If it is in PATH:\n`git subcommand`\n\nshould work in ruby\n",
"It turned out to be a missin... | [
1,
1,
0
] | [] | [] | [
"git",
"python",
"ruby",
"windows_7"
] | stackoverflow_0005971372_git_python_ruby_windows_7.txt |
Q:
Troubleshoot python daemon that quits unexpectedly?
What's the best way to monitor a python daemon to determine the cause of it quitting unexpectedly? Is strace my best option or is there something Python specific that does the job?
A:
I would generally start by adding logging to it. At a minimum, have whatever ... | Troubleshoot python daemon that quits unexpectedly? | What's the best way to monitor a python daemon to determine the cause of it quitting unexpectedly? Is strace my best option or is there something Python specific that does the job?
| [
"I would generally start by adding logging to it. At a minimum, have whatever is launching it capture stdout/stderr so that any stack traces are saved. Examine your except blocks to make sure you're not capturing exceptions silently.\n",
"You can use pdb:\npython -m pdb myscript.py\nRunning your program like this... | [
1,
0,
0
] | [] | [] | [
"python",
"strace"
] | stackoverflow_0005969337_python_strace.txt |
Q:
Adding constant acceleration to this pendulum code
How can I add constant acceleration to this pendulum as a whole while using this code? The code right now is describing a pendulum, how would I alter it to describe a pendulum in a moving train (where the train has a constant acceleration)? Any help would be appre... | Adding constant acceleration to this pendulum code | How can I add constant acceleration to this pendulum as a whole while using this code? The code right now is describing a pendulum, how would I alter it to describe a pendulum in a moving train (where the train has a constant acceleration)? Any help would be appreciated, thank you in advance.
from math import sin, pi
... | [
"For constant angular acceleration w(t):\nacc = 1\nwhile total_time < 30.0:\n ...\n angle += acc * speed * time_step\n acc += 0.1\n\nТhere is a good Simple harmonic motion wikipedia article, that describes pendulum motion.\n",
"It seems to me that you just need to specify the horizontal position ( assumi... | [
0,
0
] | [] | [] | [
"acceleration",
"performance",
"python"
] | stackoverflow_0005971291_acceleration_performance_python.txt |
Q:
How can I compute elements from two different lists in python?
I have two lists of ints, and I want systematically operate their objects. For example I have:
A = [ a1, a2, a3, a4 ...]
B = [ b1, b2, b3 ...]
and I want to print something like this:
a1+b1 a2
a2+b2 a3
a3+b3 a4
I think there are a "for loop" wa... | How can I compute elements from two different lists in python? | I have two lists of ints, and I want systematically operate their objects. For example I have:
A = [ a1, a2, a3, a4 ...]
B = [ b1, b2, b3 ...]
and I want to print something like this:
a1+b1 a2
a2+b2 a3
a3+b3 a4
I think there are a "for loop" way, but I don't know how use two variables in a "for loop".
| [
"You could use zip: \n>>> A = ['a1', 'a2', 'a3', 'a4']\n>>> B = ['b1', 'b2', 'b3']\n>>> zip(A[:3], B, A[1:])\n[('a1', 'b1', 'a2'), ('a2', 'b2', 'a3'), ('a3', 'b3', 'a4')]\n>>> for a, b, c in zip(A[:3], B, A[1:]):\n... print a + '+' + b + ' ' + c\n... \na1+b1 a2\na2+b2 a3\na3+b3 a4\n\n",
"Are you looki... | [
3,
2,
2,
1,
1,
1
] | [] | [] | [
"list",
"object",
"python",
"variables"
] | stackoverflow_0005970296_list_object_python_variables.txt |
Q:
starting and stopping using a regular expression
In my program I use a regular expression until the word break then I use it again until the word stop. The first part of the program takes the matches and converts it from military time to regular time. The second part divides the military time by a number the use... | starting and stopping using a regular expression | In my program I use a regular expression until the word break then I use it again until the word stop. The first part of the program takes the matches and converts it from military time to regular time. The second part divides the military time by a number the user inputs. My code works, but I use my regular express... | [
"Firstly, your regex r'((((2)([0-3]))|(([0-1])([0-9])))([0-5])([0-9]))' has a preposterous number of parentheses in it.\nPresumably you are not using the capturing groups so created. You appear to want to match HHMM where HH is 00 to 23 and MM is 00 to 59.\nr'(2[0-3]|[01][0-9])[0-5][0-9] will do the same job. You c... | [
5,
2
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0005971733_python_regex.txt |
Q:
Django; How can i change the table name used by i.e django.contrib.sessions?
How can i change the info in the Meta class in i.e 'django.contrib.sessions.models' , so that my project can have somewhat uniform table names, but so that the functionality of the app is the same?
Thanks
A:
You can try this:
from djang... | Django; How can i change the table name used by i.e django.contrib.sessions? | How can i change the info in the Meta class in i.e 'django.contrib.sessions.models' , so that my project can have somewhat uniform table names, but so that the functionality of the app is the same?
Thanks
| [
"You can try this:\nfrom django.contrib.sessions.models import Session\nSession.Meta.db_table = 'my_session'\n\nEDITED\nThe above solution throws an error but the following works:\nfrom django.contrib.sessions.models import Session\nSession._meta.db_table = \"my_session\"\n\n"
] | [
5
] | [] | [] | [
"django",
"frameworks",
"python"
] | stackoverflow_0005972426_django_frameworks_python.txt |
Q:
problem with pickle and tkinter
To learn tkinter I'm making a simple Go game program. I now would like to be able to save a game using pickle, but when I try to pickle my GoBoardModel object I get:
PicklingError: Can't pickle 'tkapp' object: <tkapp object at 0x01FCB090>
I guess that comes from the fact that while... | problem with pickle and tkinter | To learn tkinter I'm making a simple Go game program. I now would like to be able to save a game using pickle, but when I try to pickle my GoBoardModel object I get:
PicklingError: Can't pickle 'tkapp' object: <tkapp object at 0x01FCB090>
I guess that comes from the fact that while the GUI and the model of the go boar... | [
"Yep, look into the __getstate__ method.\nFor example, if you want pickle to ignore the 'view' attribute, you'd do the following:\nclass Whatever(object):\n\n def __getstate__(self):\n state = self.__dict__.copy()\n del state['view']\n return state\n\n"
] | [
4
] | [] | [] | [
"pickle",
"python",
"tkinter"
] | stackoverflow_0005972445_pickle_python_tkinter.txt |
Q:
django order_by value not stored in database
I have a model, Rating, which looks something like this:
class Rating(models.Model):
upvotes = models.IntegerField(default=0)
downvotes = models.IntegerField(default=0)
@property
def total(self):
return self.upvotes - self.downvotes
I have a gro... | django order_by value not stored in database | I have a model, Rating, which looks something like this:
class Rating(models.Model):
upvotes = models.IntegerField(default=0)
downvotes = models.IntegerField(default=0)
@property
def total(self):
return self.upvotes - self.downvotes
I have a group of ratings which I need to order by their total... | [
"This is because the database has no idea about the total property. It only exists in python. You can replicate the same behavior by using extra to have it calculated and sorted by the database. Like so:\nRating.objects.extra(select={'total': \"upvotes - downvotes\"}).order_by('-total')\n\n"
] | [
1
] | [] | [] | [
"django",
"django_models",
"performance",
"python"
] | stackoverflow_0005972464_django_django_models_performance_python.txt |
Q:
How would I go about killing a process/application?
I'd like to be able to kill various programs mid-run using python. How would I go about this?
Something like this:
module.end_process('chrome.exe')
This little bit of code would shut down Google Chrome.
This is in Windows 7, BTW.
A:
http://docs.python.org/lib... | How would I go about killing a process/application? | I'd like to be able to kill various programs mid-run using python. How would I go about this?
Something like this:
module.end_process('chrome.exe')
This little bit of code would shut down Google Chrome.
This is in Windows 7, BTW.
| [
"http://docs.python.org/library/os.html#os.kill\nos.kill()\n\nAlthough, you have to have the PID to use os.kill()- I'm not sure how to find a PID from a proc name with windows.\n",
"You need to use Python Win32 Extensions to handle Win32 processes from Python. You can use the approach explained in this mail threa... | [
3,
2
] | [] | [] | [
"kill",
"process",
"python",
"windows_7"
] | stackoverflow_0005972176_kill_process_python_windows_7.txt |
Q:
Import and process text file within MySQL
I'm working on a research project that requires me to process large csv files (~2-5 GB) with 500,000+ records. These files contain information on government contracts (from USASpending.gov). So far, I've been using PHP or Python scripts to attack the files row-by-row, pa... | Import and process text file within MySQL | I'm working on a research project that requires me to process large csv files (~2-5 GB) with 500,000+ records. These files contain information on government contracts (from USASpending.gov). So far, I've been using PHP or Python scripts to attack the files row-by-row, parse them, and then insert the information into ... | [
"load the file into a temporary/staging table using load data infile and then use a stored procedure to process the data - shouldnt take more than 1-2 mins at the most to completely load and process the data.\nyou might also find some of my other answers of interest:\nOptimal MySQL settings for queries that deliver... | [
1,
0
] | [] | [] | [
"csv",
"mysql",
"php",
"python"
] | stackoverflow_0005971965_csv_mysql_php_python.txt |
Q:
Django: allow safe html tags
Im looking into XSS with various frameworks and CMS and whether they provide methods in protecting against it (not just programmaticly avoiding the situation).
I know that in Djangos templating language you can specify a variable as |safe I want to be able to allow actually safe html t... | Django: allow safe html tags | Im looking into XSS with various frameworks and CMS and whether they provide methods in protecting against it (not just programmaticly avoiding the situation).
I know that in Djangos templating language you can specify a variable as |safe I want to be able to allow actually safe html tags so the user can format text (s... | [
"One of the core concepts of Django is that it's Python, and any Python lib should be usable with Django. They won't recreate the wheel unless there is good reason to. I believe HTML scrubbing/sanitizing is one of the things they've decided not to recreate.\nBeautifulSoup is the python library you want to look into... | [
1
] | [] | [] | [
"django",
"python",
"security",
"xss"
] | stackoverflow_0005972469_django_python_security_xss.txt |
Q:
Loading an image using QPixmap
I have an image file , as C:/44637landscapes-2007.jpg
I want to load this file using QPixmap using PySide
I tried as following .
pixmap = QPixmap('C:/44637landscapes-2007.jpg')
But documentation says like QPixmap(':/xxxxxx.jpeg') . What does ':' means ?
How do I load an image at 'C:... | Loading an image using QPixmap | I have an image file , as C:/44637landscapes-2007.jpg
I want to load this file using QPixmap using PySide
I tried as following .
pixmap = QPixmap('C:/44637landscapes-2007.jpg')
But documentation says like QPixmap(':/xxxxxx.jpeg') . What does ':' means ?
How do I load an image at 'C:\' ?
EDIT : The problem was with try... | [
"Qt does something a little weird with images. If you are using only pngs you will never have a problem. The handling of other image formats is handled a little differently.\nIf you take a look in your Qt directory (where all the binaries and source is) you will find a directory called: plugins\\imageformats\nIn ... | [
5,
4,
3
] | [] | [] | [
"pyside",
"python",
"qt"
] | stackoverflow_0005953352_pyside_python_qt.txt |
Q:
python exec problem: why cannot concatenate 'str' and 'int' objects
I tested these under python 2.6 and 2.7.
See this is OK:
>>> exec 'e=1'
>>> exec 'f=2'
>>> exec 'g=e+f'
>>> print g
3
But this returns error:
>>> cont=['e=1','f=2','g=e+f']
>>> for e in cont:
... try:
... exec e
... except Exce... | python exec problem: why cannot concatenate 'str' and 'int' objects | I tested these under python 2.6 and 2.7.
See this is OK:
>>> exec 'e=1'
>>> exec 'f=2'
>>> exec 'g=e+f'
>>> print g
3
But this returns error:
>>> cont=['e=1','f=2','g=e+f']
>>> for e in cont:
... try:
... exec e
... except Exception,em:
... print em
...
cannot concatenate 'str' and 'int'... | [
"You've chosen your variable names poorly. You're using e as both the for loop variable and the int variable in cont[0]. What happens is that the first time through the loop, e == 'e=1'; then exec e is called and e == 1; then the next time through the loop, e == 'f=2', and so on. By the time the last expression 'g=... | [
5,
2
] | [] | [] | [
"exec",
"python"
] | stackoverflow_0005972807_exec_python.txt |
Q:
Python Float to Ord values
I have an array of float that I need to send over TCP/IP, the protocol is text based so basically I cannot send directly binary.
What Im trying to do is to convert the Float values to 4 Ord
So ex:
""" Initialize the float """
a = 3.14159
""" Final result should be a string containing th... | Python Float to Ord values | I have an array of float that I need to send over TCP/IP, the protocol is text based so basically I cannot send directly binary.
What Im trying to do is to convert the Float values to 4 Ord
So ex:
""" Initialize the float """
a = 3.14159
""" Final result should be a string containing the 4 Ord, 1 for each byte the of ... | [
">>> import struct\n>>> struct.pack(\"!f\",3.14159)\nb'@I\\x0f\\xd0'\n\nnot sure where you arrived at \"\\123\\23\\22\\245\"\nIf you wish to convert a list of floats\n>>> a=[3.14159, 2.71828]\n>>> struct.pack(\"!{}f\".format(len(a)), *a)\n\nwill give you a single string. No need for an explicit loop and join\n"
] | [
4
] | [] | [] | [
"python",
"python_3.x"
] | stackoverflow_0005972816_python_python_3.x.txt |
Q:
Interpreting objgraph numbers: memory leak?
I have a Python client-server application and its server has been running for about 4 days... Its memory usage (as reported by /proc/PID/status -> VmSize) has grown to about 660Mb, and I was wondering if there could be a memory leak, so I used objgraph to print out its m... | Interpreting objgraph numbers: memory leak? | I have a Python client-server application and its server has been running for about 4 days... Its memory usage (as reported by /proc/PID/status -> VmSize) has grown to about 660Mb, and I was wondering if there could be a memory leak, so I used objgraph to print out its memory usage (first 20 object types):
58524 tup... | [
"To acquire more meaningful data, keep the server running for several days, and pull this summary once per day. The key will be to see which kinds of objects are accumulating from one day to the next; those object types will be the most likely candidates for your memory leak! Let us know what you find.\n"
] | [
1
] | [] | [] | [
"memory_leaks",
"objgraph",
"python"
] | stackoverflow_0005223060_memory_leaks_objgraph_python.txt |
Q:
Registry Entries for all users in Python
I wrote an application that stores several things in the registry. When I first started, I added them to HKEY_LOCAL_MACHINE, but kept getting permission errors writing to the. So, it was suggested that I use HKEY_CURRENT_USER, that worked until I realized that I am not able... | Registry Entries for all users in Python | I wrote an application that stores several things in the registry. When I first started, I added them to HKEY_LOCAL_MACHINE, but kept getting permission errors writing to the. So, it was suggested that I use HKEY_CURRENT_USER, that worked until I realized that I am not able to access them from another account. How can ... | [
"HKEY_LOCAL_MACHINE/Software/YourSoftware, needs Admin permissions and is for install-time data, or HKEY_CURRENT_USER/Software/YourSoftware, which is for data pertinent to this environment only (this user, this profile etc.)\nEDIT: An alternative would be storing a config file and setting the right permissions at i... | [
2,
0,
0,
0
] | [] | [] | [
"permissions",
"python",
"registry",
"windows",
"winreg"
] | stackoverflow_0004010108_permissions_python_registry_windows_winreg.txt |
Q:
Problems running built PyTables on Mac
I built numpy 1.5.1, numexpr 1.4.2, and PyTables 2.2.1 on a Mac, and am getting the following error. I googled it, but found only 1 place where someone mentions this specific error, and found no resolution.
Does anyone know what this means?
Thanks,
Dave
Python 2.6.1 (r261:675... | Problems running built PyTables on Mac | I built numpy 1.5.1, numexpr 1.4.2, and PyTables 2.2.1 on a Mac, and am getting the following error. I googled it, but found only 1 place where someone mentions this specific error, and found no resolution.
Does anyone know what this means?
Thanks,
Dave
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Appl... | [
"Well, I was able to solve my problem by blowing everything away and making a clean build. So I'm not exactly sure what the problem was, but I think I must have been mixing up versions somehow.\n"
] | [
1
] | [] | [] | [
"macos",
"pytables",
"python"
] | stackoverflow_0005957211_macos_pytables_python.txt |
Q:
Pylab Histogram show all bins on x axis
Im writing a small python program to do a frequency analysis, and I was wondering how you might get all the bins to show on the x axis rather then just in increments of 5. Also is there a way you can display a string value like "A" on the x axis instead of a number?
Code:
pr... | Pylab Histogram show all bins on x axis | Im writing a small python program to do a frequency analysis, and I was wondering how you might get all the bins to show on the x axis rather then just in increments of 5. Also is there a way you can display a string value like "A" on the x axis instead of a number?
Code:
print "Please specify the file to analyse."
Fil... | [
"You can use xticks. \nxticks(arange(len(AlphaNum)),AlphaNum)\n\n"
] | [
1
] | [] | [] | [
"graph",
"histogram",
"matplotlib",
"python"
] | stackoverflow_0005972328_graph_histogram_matplotlib_python.txt |
Q:
Problem on the management of django static file
I am using apache+mod_wsgi+django. I come across with this situation. I have a webpage shown in the browser but without the css style which ought to be there supposedly. Here is my configuration on the setting.py and apache_django_wsgi.conf.
setting py:
import os.pa... | Problem on the management of django static file | I am using apache+mod_wsgi+django. I come across with this situation. I have a webpage shown in the browser but without the css style which ought to be there supposedly. Here is my configuration on the setting.py and apache_django_wsgi.conf.
setting py:
import os.path
import posixpath
PROJECT_ROOT = os.path.abspath(o... | [
"Your traceback has nothing to do with static files. Check your DATABASE_* or DATABASES settings to match your environment. Check also if you mysql daemon is running (ps aux | grep mysql in ubuntu). After this traceback is gone, you have to do python manage.py collectstatic which will copy all your static files int... | [
0
] | [] | [] | [
"apache",
"django",
"mod_wsgi",
"python"
] | stackoverflow_0005973141_apache_django_mod_wsgi_python.txt |
Q:
Unexpected import behavior, treating integers and lists differently
I have a problem with my program and I was able to reproduce this unexpected (at least unexpected to me) behavior in a small scale so now I'm certain it is not another bug.
Lets say I have 3 python modules: one, two and three.
In three we have:
va... | Unexpected import behavior, treating integers and lists differently | I have a problem with my program and I was able to reproduce this unexpected (at least unexpected to me) behavior in a small scale so now I'm certain it is not another bug.
Lets say I have 3 python modules: one, two and three.
In three we have:
var = 0
list = []
So there we have a integer that is equal to zero and and... | [
"This is nothing to do with import, and everything to do with the different types involved.\nlist is a mutable type. list.append modifies the object in place, and returns None.\nint is an immutable type. Its += operator returns a new object.\nLearn more about mutable and immutable types at the Python documentation ... | [
2,
2
] | [
"Importing a name copies the reference the name contains to your module. In your code, the integer gets rebound, but the list gets mutated. Since the list reference never changes, the original object is mutated. Hence different integer, same list.\n"
] | [
-1
] | [
"import",
"integer",
"list",
"module",
"python"
] | stackoverflow_0005973315_import_integer_list_module_python.txt |
Q:
How to call a method from an inherit class
I'm working on a project wich consist on testing a board connection with a JTAG connector and OpenOCD server.
Here is the connection class I've coded, it's simply using pexpect :
"""
Communication with embedded board
"""
import sys
import time
import threading
import Que... | How to call a method from an inherit class | I'm working on a project wich consist on testing a board connection with a JTAG connector and OpenOCD server.
Here is the connection class I've coded, it's simply using pexpect :
"""
Communication with embedded board
"""
import sys
import time
import threading
import Queue
import pexpect
import serial
import fdpexpec... | [
"try \n'send' in dir(tn)\n\nif it's False, you haven't implemented the send method.\n",
"The problem was the syntax of my class definition :\nclass ModTelnet:\n\nAnd not :\nclass ModTelnet():\n\nwich is a useless because I don't inherit from an other class ... :D \nThanks anyway !\n"
] | [
0,
0
] | [] | [] | [
"jtag",
"python",
"serial_port"
] | stackoverflow_0005953988_jtag_python_serial_port.txt |
Q:
Bulkloader CSV size error
Bulkloader raises the following error when importing a CSV file with large cells:
[ERROR ] Error in data source thread: field larger than field limit (131072)
This is a common problem for the csv module, which can be fixed with:
csv.field_size_limit(sys.maxint)
How can I make bulkload... | Bulkloader CSV size error | Bulkloader raises the following error when importing a CSV file with large cells:
[ERROR ] Error in data source thread: field larger than field limit (131072)
This is a common problem for the csv module, which can be fixed with:
csv.field_size_limit(sys.maxint)
How can I make bulkloader execute this?
| [
"Try this:\nIn bulkloader.yaml add:\npython_preamble:\n- import: csv_fix\n... # the rest of your imports\n\nIn csv_fix.py add:\nimport csv, sys\ncsv.field_size_limit(sys.maxint)\n\n"
] | [
8
] | [] | [] | [
"bulkloader",
"google_app_engine",
"python"
] | stackoverflow_0005973363_bulkloader_google_app_engine_python.txt |
Q:
Tool to inspect Python objects without changing them
While trying to track down a resource leak in a Python program this evening, it occurred to me that modern ORMs make the job quite difficult. An object which is, in fact, sitting alone in memory with no children will suddenly appear to have a dozen associated ob... | Tool to inspect Python objects without changing them | While trying to track down a resource leak in a Python program this evening, it occurred to me that modern ORMs make the job quite difficult. An object which is, in fact, sitting alone in memory with no children will suddenly appear to have a dozen associated objects as you start checking its attributes because, of cou... | [
"Python 3.2 now provides inspect.getattr_static() for precisely this kind of use case:\nhttp://docs.python.org/py3k/library/inspect#fetching-attributes-statically\nThe source code link from the top of the docs page should make it fairly easy to backport that functionality to earlier versions (although keep in mind ... | [
5,
0
] | [] | [] | [
"python"
] | stackoverflow_0005973048_python.txt |
Q:
Which Technology Trend In Development Is Promising To Follow In 2011?
Dear guys
I am going switch to java , i want to know which development technology is promising for future development of apps , is my choose reliable
My top keys are multi platform , wider community , support of latest technologies like smart ... | Which Technology Trend In Development Is Promising To Follow In 2011? | Dear guys
I am going switch to java , i want to know which development technology is promising for future development of apps , is my choose reliable
My top keys are multi platform , wider community , support of latest technologies like smart devices , ...
Also i am not satisfied with adobe ( flex / air ) i think i t... | [
"Yes Java is suitable for your requirement. Still in Java, you have to choose framework like struts, spring... very carefully. But there are lot of forums and blogs are availables. They will guide you.\n",
"\nFor UI, SpringMVC is gaining\nmore and more supports from the\ncommunity. Struts is a bit old.\nFor the ... | [
1,
1
] | [] | [] | [
"apache_flex",
"java",
"python"
] | stackoverflow_0005974027_apache_flex_java_python.txt |
Q:
How can Python detect that my RabbitMQ password failed?
I am trying to write a Python application that uses RabbitMQ by means of the Pika library. I am using the latest version, 0.9.5. My problem is that my Python code cannot detect when its RabbitMQ username and password are incorrect, because I cannot figure out... | How can Python detect that my RabbitMQ password failed? | I am trying to write a Python application that uses RabbitMQ by means of the Pika library. I am using the latest version, 0.9.5. My problem is that my Python code cannot detect when its RabbitMQ username and password are incorrect, because I cannot figure out how to register a Pika callback that would inform me of the ... | [
"Initially, I thought pika.exceptions.LoginError is raised if login fails. However, it is only raised if the authentication type provided is not supported by the AMQP broker. It is not raised on unsuccessful authentication.\nAfter some hacking around in the Pika source (printing in-bound frames), it seems that afte... | [
1,
1
] | [] | [] | [
"amqp",
"pika",
"python",
"rabbitmq"
] | stackoverflow_0005918316_amqp_pika_python_rabbitmq.txt |
Q:
Pickling a list consisting of 'n' 2-tuple values
I want to pickle a list as it takes a long time for me to create the list. The list consists of "n" 2-tuple values where the first tuple value is a large dictionary(1k to 10k keys) and the second value is a string. N can be as large as 100s to 1000s. I would like to... | Pickling a list consisting of 'n' 2-tuple values | I want to pickle a list as it takes a long time for me to create the list. The list consists of "n" 2-tuple values where the first tuple value is a large dictionary(1k to 10k keys) and the second value is a string. N can be as large as 100s to 1000s. I would like to save such a data structure so that I may load it on c... | [
"I would use cPickle, this works fine,\n# Dummy data\nfrom random import randint as r\n\na,b = 97,123\n\nd = [(dict([(chr(r(a,b)),j) for j in range(1000)]),\n ''.join([chr(r(a,b)) for i in range(5)])) \n for j in range(100)]\n\n# Pickle it\nimport cPickle as pickle\n\nf = open('stor... | [
1
] | [] | [] | [
"pickle",
"python",
"pyyaml"
] | stackoverflow_0005974380_pickle_python_pyyaml.txt |
Q:
How use openurl & multiprocessing get URL different data in the same time?
This loop help get some text data from web service:
while True:
u = urllib2.urlopen('http://url/%d.csv' %inputd)
f=open('/folder/%s.csv' $inputd,'a')
csvread = csv.reader(u)
csvwrite = csv.writer(f)
csvwrite.writerows(cs... | How use openurl & multiprocessing get URL different data in the same time? | This loop help get some text data from web service:
while True:
u = urllib2.urlopen('http://url/%d.csv' %inputd)
f=open('/folder/%s.csv' $inputd,'a')
csvread = csv.reader(u)
csvwrite = csv.writer(f)
csvwrite.writerows(csvread)
print 'OK','%e'%inputd
time.sleep(30)
now I try to get different... | [
"Your multiprocess implementation will do the url grabbing only once.\nIf you want that your dataget do the stuff again and again, you missed the While True. \nMaybe like this it will work :\nimport multiprocessing as mp\nimport urllib2,csv,random,logging,csv,time\n\ninputd=(abc,def,ghi)\n\ndef dataget(param):\n ... | [
3
] | [] | [] | [
"csv",
"multiprocessing",
"python",
"urlopen"
] | stackoverflow_0005974785_csv_multiprocessing_python_urlopen.txt |
Q:
Associate files with specific extension to my own application in Python
I have created an app. It uses some database file to show its contents in a wxpython frame.
Let us assume the database file extension is .xyz. When I double-click on an .xyz file, I want to open that file in my application and call a function ... | Associate files with specific extension to my own application in Python | I have created an app. It uses some database file to show its contents in a wxpython frame.
Let us assume the database file extension is .xyz. When I double-click on an .xyz file, I want to open that file in my application and call a function inside my app to process it. How can I do it in Python and in Windows.
Thanks... | [
"It is not related to Python itself, but it is Windows configuration. You have to assign file type to the application. I guess the method how you do that depends on Windows version. Here is example for Vista: http://windows.microsoft.com/en-US/windows-vista/Change-which-programs-Windows-uses-by-default\n",
"ftype... | [
3,
2
] | [] | [] | [
"python",
"windows",
"wxpython"
] | stackoverflow_0005974052_python_windows_wxpython.txt |
Q:
mod_python unable to locate the web.py module under a virtual environment
I have a small web.py Python application that I would like to serve under Apache using mod_python. The web.py framework, as well as other third-party Python modules the application in question relies upon, are installed in a virtual environ... | mod_python unable to locate the web.py module under a virtual environment | I have a small web.py Python application that I would like to serve under Apache using mod_python. The web.py framework, as well as other third-party Python modules the application in question relies upon, are installed in a virtual environment. The virtual environment is created inside: /home/ayaz/Sandbox/Scrapper/... | [
"Could it be a file or directory permission problem? Verify that the all of the files and directories in your virtualenv site-packages are accessible from the user name that Apache and mod_python are running under.\n",
"So as to answer this question, I am going to copy the update paragraphs from my question and ... | [
1,
1
] | [] | [] | [
"apache",
"mod_python",
"python",
"web.py"
] | stackoverflow_0004384946_apache_mod_python_python_web.py.txt |
Q:
SQLAlchemy ordering by count on a many to many relationship
This is a simplified example of my current models (I'm using the Flask SQLAlchemy extension):
like = db.Table(
'like',
db.Column('uid', db.Integer, db.ForeignKey('users.id')),
db.Column('pid', db.Integer, db.ForeignKey('posts.id'))
)
class Us... | SQLAlchemy ordering by count on a many to many relationship | This is a simplified example of my current models (I'm using the Flask SQLAlchemy extension):
like = db.Table(
'like',
db.Column('uid', db.Integer, db.ForeignKey('users.id')),
db.Column('pid', db.Integer, db.ForeignKey('posts.id'))
)
class User(db.Model):
__tablename__ = 'users'
id = db.Column(db.... | [
"I haven't used SQLAlchemy much so I figured I'd give it a shot. I didn't try to use your models, I just wrote some new ones (similar enough though):\nlikes = db.Table('likes',\n db.Column('user_id', db.Integer, db.ForeignKey('user.id')),\n db.Column('post_id', db.Integer, db.ForeignKey('post.id'))\n)\n\nclas... | [
57
] | [] | [] | [
"flask",
"flask_sqlalchemy",
"orm",
"python",
"sqlalchemy"
] | stackoverflow_0005973553_flask_flask_sqlalchemy_orm_python_sqlalchemy.txt |
Q:
Using matplotlib to plot a 3d plot, draw() takes an additional argument
Dear all. I was exploring matplotlib's 3d plot capabilities yesterday (and was pleasantly surprised, it looks good). Just to be clear, with
from mpl_toolkits.mplot3d import Axes3D
However, when I try to continuously redraw the plot with draw(... | Using matplotlib to plot a 3d plot, draw() takes an additional argument | Dear all. I was exploring matplotlib's 3d plot capabilities yesterday (and was pleasantly surprised, it looks good). Just to be clear, with
from mpl_toolkits.mplot3d import Axes3D
However, when I try to continuously redraw the plot with draw(), I get the error that draw() (for 3d plots) takes an additional argument as... | [
"EDIT: I take it back. You can get it from fig.canvas.renderer. I'll leave the example below, though.\n\nThere does not appear to be a documented way to get the renderer, but you can probably just peek within the axes structure at the _cachedRenderer. Note that you have to cause a plot to draw before this is set... | [
0
] | [] | [] | [
"matplotlib",
"python"
] | stackoverflow_0005974658_matplotlib_python.txt |
Q:
PySide packaging error (macholib) python setup.py py2app
I am quite new to Python and PySide and trying to package a very simplified test case into an standalone app OS X. I put the test on github https://github.com/eerne/pyside-py2app-test
Python 2.6.1 that is shipped with OS X 10.6.7
Qt 4.7.3 from http://qt.nok... | PySide packaging error (macholib) python setup.py py2app | I am quite new to Python and PySide and trying to package a very simplified test case into an standalone app OS X. I put the test on github https://github.com/eerne/pyside-py2app-test
Python 2.6.1 that is shipped with OS X 10.6.7
Qt 4.7.3 from http://qt.nokia.com/downloads/qt-for-open-source-cpp-development-on-mac-os-... | [
"My guess is that you need to upgrade macholib. That load command (0x22) is defined in the version here, which is the dev version.\n"
] | [
1
] | [] | [] | [
"packaging",
"py2app",
"pyside",
"python",
"qt"
] | stackoverflow_0005974096_packaging_py2app_pyside_python_qt.txt |
Q:
MongoEngine specifying an ID
I'm having trouble getting MongoEngine to accept specific IDs. It seems absolutely determined to use (and only use) ObjectIds. I'm more than able to generate my own IDs in this instance, thanks.
How can I get MongoEngine to play nice?
A:
I managed to solve this by adding the followin... | MongoEngine specifying an ID | I'm having trouble getting MongoEngine to accept specific IDs. It seems absolutely determined to use (and only use) ObjectIds. I'm more than able to generate my own IDs in this instance, thanks.
How can I get MongoEngine to play nice?
| [
"I managed to solve this by adding the following to the class:\nid = mongoengine.StringField(required=True, primary_key=True)\n\nNot sure if this is the \"proper\" way of doing things, so ill leave this unanswered for a bit.\n"
] | [
-2
] | [] | [] | [
"mongodb",
"mongoengine",
"nosql",
"python"
] | stackoverflow_0005975576_mongodb_mongoengine_nosql_python.txt |
Q:
How do I slice a string every 3 indices?
I'm using Python to program for the lab I work at. How can I slice out every 3 characters in a given string and append it to a list?
i.e. XXXxxxXXXxxxXXXxxxXXXxxxXXX (where X or x is any given letter)
string = 'XXXxxxXXXxxxXXXxxxXXXxxxXXX'
mylist = []
for x in string:
... | How do I slice a string every 3 indices? | I'm using Python to program for the lab I work at. How can I slice out every 3 characters in a given string and append it to a list?
i.e. XXXxxxXXXxxxXXXxxxXXXxxxXXX (where X or x is any given letter)
string = 'XXXxxxXXXxxxXXXxxxXXXxxxXXX'
mylist = []
for x in string:
string[?:?:?]
mylist.append(string)
I wan... | [
"In short, you can't.\nIn longer, you'll need to write your own function, possibly:\ndef split(str, num):\n return [ str[start:start+num] for start in range(0, len(str), num) ]\n\nFor example:\n\n>>> split(\"xxxXXX\", 3)\n['xxx', 'XXX']\n>>> split(\"xxxXXXxx\", 3)\n['xxx', 'XXX', 'xx']\n\n",
"one difference be... | [
20,
7,
4,
1
] | [] | [] | [
"python",
"slice",
"string"
] | stackoverflow_0005711452_python_slice_string.txt |
Q:
Bring the current Python program to background
A python script prints information to screen and then should go to background.
How to do that from within the script itself?
A:
Copying related code from Creating a daemon the Python way; please read the comments as to why that code is quite thought-out.
def create... | Bring the current Python program to background | A python script prints information to screen and then should go to background.
How to do that from within the script itself?
| [
"Copying related code from Creating a daemon the Python way; please read the comments as to why that code is quite thought-out.\ndef createDaemon():\n \"\"\"Detach a process from the controlling terminal and run it in the\n background as a daemon.\n \"\"\"\n\n try:\n # Fork a child process so the paren... | [
25,
20
] | [] | [] | [
"background",
"linux",
"python"
] | stackoverflow_0005975124_background_linux_python.txt |
Q:
Download all the links(related documents) on a webpage using Python
I have to download a lot of documents from a webpage. They are wmv files, PDF, BMP etc. Of course, all of them have links to them. So each time, I have to RMC a file, select 'Save Link As' Then save then as type All Files. Is it possible to do thi... | Download all the links(related documents) on a webpage using Python | I have to download a lot of documents from a webpage. They are wmv files, PDF, BMP etc. Of course, all of them have links to them. So each time, I have to RMC a file, select 'Save Link As' Then save then as type All Files. Is it possible to do this in Python? I search the SO DB and folks have answered question of how t... | [
"Here is an example of how you could download some chosen files from http://pypi.python.org/pypi/xlwt\nyou will need to install mechanize first: http://wwwsearch.sourceforge.net/mechanize/download.html\nimport mechanize\nfrom time import sleep\n#Make a Browser (think of this as chrome or firefox etc)\nbr = mechaniz... | [
25,
6
] | [] | [] | [
"python"
] | stackoverflow_0005974595_python.txt |
Q:
Python not able to open file with non-english characters in path
I have a file with the following path : D:/bar/クレイジー・ヒッツ!/foo.abc
I am parsing the path from a XML file and storing it in a variable called path in the form of file://localhost/D:/bar/クレイジー・ヒッツ!/foo.abc
Then, the following operations are being done:
... | Python not able to open file with non-english characters in path | I have a file with the following path : D:/bar/クレイジー・ヒッツ!/foo.abc
I am parsing the path from a XML file and storing it in a variable called path in the form of file://localhost/D:/bar/クレイジー・ヒッツ!/foo.abc
Then, the following operations are being done:
path=path.strip()
path=path[17:] #to remove the file://localhost/ par... | [
"The path in your error is:\n'\\xe3\\x82\\xaf\\xe3\\x83\\xac\\xe3\\x82\\xa4\\xe3\\x82\\xb8\\xe3\\x83\\xbc\\xe3\\x83\\xbb\\xe3\\x83\\x92\\xe3\\x83\\x83\\xe3\\x83\\x84\\xef\\xbc\\x81'\n\nI think this is the UTF8 encoded version of your filename.\nI've created a folder of the same name on Windows7 and placed a file ca... | [
6,
2,
1
] | [] | [] | [
"file",
"path",
"python",
"python_2.7",
"urlencode"
] | stackoverflow_0005974585_file_path_python_python_2.7_urlencode.txt |
Q:
Setting window styles with Tkinter/Tcl: no exit button
I know that Tkinter is just a thin layer over Tcl/Tk. Tkinter you can do a few things to change the windows styling. One example would be root.attributes('-toolwindow', True). This would change the window style, to that of a tool window. However, I'm looking t... | Setting window styles with Tkinter/Tcl: no exit button | I know that Tkinter is just a thin layer over Tcl/Tk. Tkinter you can do a few things to change the windows styling. One example would be root.attributes('-toolwindow', True). This would change the window style, to that of a tool window. However, I'm looking to go a little bit lower level.
I suspect at some point Tcl/... | [
"The following option instructs the window manager not to decorate the window (i.e no title bar and window buttons, plus no borders)\nroot.overrideredirect(True)\n\nA false argument restores the decorations.\n",
"If you are familiar with C, download Tk source code.\nI've looked quickly, and in this file:\n./win/t... | [
5,
3
] | [] | [] | [
"python",
"tcl",
"tkinter",
"window_style",
"windows_7"
] | stackoverflow_0005973371_python_tcl_tkinter_window_style_windows_7.txt |
Q:
A python web framework that works well with Sybase?
I have found lots that work well with any other datastore, but none that work well with Sybase. Please advise !! Thanks, Richard.
[ Edit: http://code.google.com/p/sqlany-django/ isn't sufficient - I need Sybase support,not SQL Anywhere ]
A:
I am guessing that w... | A python web framework that works well with Sybase? | I have found lots that work well with any other datastore, but none that work well with Sybase. Please advise !! Thanks, Richard.
[ Edit: http://code.google.com/p/sqlany-django/ isn't sufficient - I need Sybase support,not SQL Anywhere ]
| [
"I am guessing that what you are actually asking for is Web Framework that has database abstraction layer supporting Sybase. Am I right? For starters you could have a look at SQLAlchemy, which is an ORM used by some of the web frameworks and can be used with others (web.py, CherryPy, etc.).\n"
] | [
0
] | [] | [] | [
"python",
"sybase_asa",
"template_engine"
] | stackoverflow_0005976104_python_sybase_asa_template_engine.txt |
Q:
How to extract HTTP message body in BaseHTTPRequestHandler.do_POST()?
In the do_POST() method of BaseHTTPRequestHandler I can access the headers of the POST request simply via the property self.headers. But I can't find a similar property for accessing the body of the message. How do I then go about doing that?
A... | How to extract HTTP message body in BaseHTTPRequestHandler.do_POST()? | In the do_POST() method of BaseHTTPRequestHandler I can access the headers of the POST request simply via the property self.headers. But I can't find a similar property for accessing the body of the message. How do I then go about doing that?
| [
"You can access POST body in do_POST method like this:\nfor python 2\ncontent_len = int(self.headers.getheader('content-length', 0))\n\nfor python 3\ncontent_len = int(self.headers.get('Content-Length'))\n\nand then read the data\npost_body = self.rfile.read(content_len)\n\n"
] | [
110
] | [] | [] | [
"basehttprequesthandler",
"basehttpserver",
"http",
"post",
"python"
] | stackoverflow_0005975952_basehttprequesthandler_basehttpserver_http_post_python.txt |
Q:
Testing Python Scripts
How do I test the STDOUT output of a Python script with a testing framework like doctest, unittest, nose, etc? For example, say running my script "todo.py --list" should return "take out the garbage".
I've read someone who separates out the STDOUT printing part of the script from the part th... | Testing Python Scripts | How do I test the STDOUT output of a Python script with a testing framework like doctest, unittest, nose, etc? For example, say running my script "todo.py --list" should return "take out the garbage".
I've read someone who separates out the STDOUT printing part of the script from the part that generates the output to b... | [
"I see two ways :\n\nRedirect stdout during the unittest:\nclass YourTest(TestCase):\n def setUp(self):\n self.output = StringIO()\n self.saved_stdout = sys.stdout\n sys.stdout = self.output\n\n def tearDown(self):\n self.output.close()\n sys.stdout = self.saved_stdout\n\n ... | [
10,
8,
3,
1,
0
] | [] | [] | [
"python",
"tdd",
"unit_testing"
] | stackoverflow_0005974557_python_tdd_unit_testing.txt |
Q:
ssh client with paramiko
import paramiko
import os
def connection():
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
privatekey = os.path.expanduser('/home/rabia/private')
mkey = paramiko.RSAKey.from_private_key_file(privatekey)
ssh.connect('78.46.172.47', ... | ssh client with paramiko | import paramiko
import os
def connection():
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
privatekey = os.path.expanduser('/home/rabia/private')
mkey = paramiko.RSAKey.from_private_key_file(privatekey)
ssh.connect('78.46.172.47', port=22, username='s0urd', pas... | [
"If I'm understanding you correctly, then you should add something like this to your code:\nimport threading\n\n_paramikoThread = threading.Thread(target=doParamikoConnection)\n_paramikoThread.start()\n# The following code is executed by parent thread.\n_ans = \"\"\nwhile _ans != \"nay\":\n _ans = raw_input(\"Sh... | [
1
] | [] | [] | [
"multithreading",
"paramiko",
"python",
"ssh"
] | stackoverflow_0005974463_multithreading_paramiko_python_ssh.txt |
Q:
How to improve this tail-like Python code
I just want to know if you guys have better ways of doing this than the one I came up with. What I want is to make a "tail -f"-like script, but one that will look actively for a string and print only the text related to that string, in real time. As you can see from the co... | How to improve this tail-like Python code | I just want to know if you guys have better ways of doing this than the one I came up with. What I want is to make a "tail -f"-like script, but one that will look actively for a string and print only the text related to that string, in real time. As you can see from the code I'm looking for MAC addresses, but I guess i... | [
"Are you doing this as a Python exercise or can you use the shell?\nCan you simply pipe the tail output into a grep?\ntail -F myfile.txt | egrep --line-buffered myPattern\n\nYou could put this into a script and make the file and pattern args.\nUsing grep you can also add context to your output by using the -A and -... | [
1
] | [] | [] | [
"optimization",
"python",
"tail"
] | stackoverflow_0005976327_optimization_python_tail.txt |
Q:
Python: How to deal with non-subscriptable objects?
I've read a thread on what a (non)subscriptable object is but it doesn't tell me what i can do about it.
I have a code calling a mypost private module. The aim is to set up mail accounts and to do this i create MailAccounts() objects defined in the mypost module.... | Python: How to deal with non-subscriptable objects? | I've read a thread on what a (non)subscriptable object is but it doesn't tell me what i can do about it.
I have a code calling a mypost private module. The aim is to set up mail accounts and to do this i create MailAccounts() objects defined in the mypost module. Quantity of accounts and their respective details are de... | [
"The way to fix it is to use dictionaries properly.\nfor service in accounts:\n for account, creds in accounts[service].iteritems():\n account.setupAccount(creds['username'], creds['password'])\n\n",
"The problem is that when you iterate over a dictionary, you get the keys of that dictionary, no... | [
5,
0
] | [] | [] | [
"dictionary",
"methods",
"python",
"subscript"
] | stackoverflow_0005977165_dictionary_methods_python_subscript.txt |
Q:
How to filter by name of ReferenceProperty's model?
I have the following 3 classes:
class Locality(db.Model):
location = db.ReferenceProperty()
class Organisation(db.Model):
locality = db.ReferenceProperty(Locality)
class Position(db.Model):
locality = db.ReferenceProperty(Locality)
Locality.location prop... | How to filter by name of ReferenceProperty's model? | I have the following 3 classes:
class Locality(db.Model):
location = db.ReferenceProperty()
class Organisation(db.Model):
locality = db.ReferenceProperty(Locality)
class Position(db.Model):
locality = db.ReferenceProperty(Locality)
Locality.location property is reference to Organisation or Position object.
I n... | [
"In this line:\nLocality.all().filter(\"location =\", Organisation)\n\nYou should be passing in an instance of Organisation rather then the class itself, e.g.:\norg = Organisation.get(some_org_key)\nLocality.all().filter(\"location =\", org)\n\n",
"class Locality(db.Model):\n location = db.ReferenceProperty()\n\... | [
1,
0,
0,
0
] | [] | [] | [
"google_app_engine",
"google_cloud_datastore",
"python"
] | stackoverflow_0005947955_google_app_engine_google_cloud_datastore_python.txt |
Q:
How to call javascript function from PyQT
I'm trying to interact with a google map using python. I've built an application in PyQT with a QWebView. The QWebView loads a local html page as shown here:
browser = QwebView()
browser.load(QUrl("file:///c:/main.html"))
frame = browser.page().currentFrame()
frame.evalu... | How to call javascript function from PyQT | I'm trying to interact with a google map using python. I've built an application in PyQT with a QWebView. The QWebView loads a local html page as shown here:
browser = QwebView()
browser.load(QUrl("file:///c:/main.html"))
frame = browser.page().currentFrame()
frame.evaluateJavaScript(QString("addMarker(-33.89, 151.27... | [
"The error was that I needed to wait for the page to load. I added a button that was connected to the evaluateJavaScript(\"addMarker(-33.89,151.275)\") call. When I clicked the button (after the page loaded), the marker was added as expected.\n",
"http://pysnippet.blogspot.com/2010/01/more-fun-with-qwebkit.html m... | [
4,
2
] | [] | [] | [
"google_maps",
"javascript",
"python",
"qt"
] | stackoverflow_0005885290_google_maps_javascript_python_qt.txt |
Q:
Google App Engine Bulk download
I was downloading data(more than 1 GB) from datastore using bulk download. Suddenly, my internet stopped working and download process stopped in middle. I want to resume from where it stopped. When I try, I get the following error
File "/Users/FYP/GoogleAppEngineLauncher.app/Content... | Google App Engine Bulk download | I was downloading data(more than 1 GB) from datastore using bulk download. Suddenly, my internet stopped working and download process stopped in middle. I want to resume from where it stopped. When I try, I get the following error
File "/Users/FYP/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.b... | [
"Just re-run the same command. Per the docs:\n\nIf the transfer is interrupted, you\n can resume the transfer from where it\n left off using the --db_filename=...\n argument. The value is the name of the\n progress file created by the tool,\n which is either a name you provided\n with the --db_filename argume... | [
1,
0
] | [] | [] | [
"bulk",
"download",
"google_app_engine",
"python"
] | stackoverflow_0005840352_bulk_download_google_app_engine_python.txt |
Q:
size of a python file object and seek()
I created a file with the following entry, returned by file.read()
'abcd\nefgh\n1234\nijkl\n5678\n\nend'
I open the file to read now, with 'f' as handler.
f.read() returns the above.
f.tell() returns 35L
sys.getsizeof(f) returns 76.
Trying to call f.seek(offset) with offset ... | size of a python file object and seek() | I created a file with the following entry, returned by file.read()
'abcd\nefgh\n1234\nijkl\n5678\n\nend'
I open the file to read now, with 'f' as handler.
f.read() returns the above.
f.tell() returns 35L
sys.getsizeof(f) returns 76.
Trying to call f.seek(offset) with offset any higher than 35 returns nothing.
Python do... | [
"sys.getsizeof returns a size of an object (i.e. how many bytes a file class instance takes up in the memory), and has nothing to do with the size of the file contents.\n",
"# size of the file in bytes\nsize = os.path.getsize(pathname)\n# another way\nf = file(pathname)\nsize = os.fstat(f.fileno()).st_size\n\nRef... | [
7,
4,
3
] | [] | [] | [
"file",
"python",
"sys"
] | stackoverflow_0005977648_file_python_sys.txt |
Q:
SQL Alchemy performance
I'm working on a project that will need a huge database. Currently we are using SQLAlchemy but I'm concerned a little about performance issues. My question is , having a query like:
session.query(DataStorage).filter(DataStorage.storage_path.startswith(path)).all()
How does SQLAlchemy does ... | SQL Alchemy performance | I'm working on a project that will need a huge database. Currently we are using SQLAlchemy but I'm concerned a little about performance issues. My question is , having a query like:
session.query(DataStorage).filter(DataStorage.storage_path.startswith(path)).all()
How does SQLAlchemy does the actual translation and fi... | [
"SqlAlchemy uses your code to generate an SQL statement. In your case, you up with something like:\nSELECT * FROM DataStorage WHERE DataStorage.storage_path LIKE 'path%';\n\nThe query is run against the database once you use the .all(). So in this case, it would get all of the rows in a resultset iterator and retur... | [
2,
1
] | [] | [] | [
"python",
"sqlalchemy"
] | stackoverflow_0005977501_python_sqlalchemy.txt |
Q:
Why doesn't xpath work when processing an XHTML document with lxml (in python)?
I am testing against the following test document:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="... | Why doesn't xpath work when processing an XHTML document with lxml (in python)? | I am testing against the following test document:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>hi there</title>
</head>
... | [
"The problem is the namespaces. When parsed as XML, the img tag is in the http://www.w3.org/1999/xhtml namespace since that is the default namespace for the element. You are asking for the img tag in no namespace.\nTry this:\n>>> tree.getroot().xpath(\n... \"//xhtml:img\", \n... namespaces={'xhtml':'http... | [
27,
7,
2
] | [] | [] | [
"lxml",
"python",
"xhtml",
"xml",
"xpath"
] | stackoverflow_0000297239_lxml_python_xhtml_xml_xpath.txt |
Q:
Association between naming classes and naming their files in python (convention?)
In python (and some other languages) I have learned, that the name of a class should be written in small letters except for the first letter of each word, which should be a capital letter. Example:
class FooBar:
...
A class shou... | Association between naming classes and naming their files in python (convention?) | In python (and some other languages) I have learned, that the name of a class should be written in small letters except for the first letter of each word, which should be a capital letter. Example:
class FooBar:
...
A class should go in a file, named the same as the class. In this example it would be a file foobar... | [
"What you have presented is the standard convention.\n\nPackage and Module Names\nModules should have short, all-lowercase names. Underscores can\n be used in the module name if it improves readability. Python packages\n should also have short, all-lowercase names, although the use of underscores\n is discoura... | [
67,
16
] | [] | [] | [
"classname",
"filenames",
"naming_conventions",
"python"
] | stackoverflow_0005978557_classname_filenames_naming_conventions_python.txt |
Q:
Where to save CONSUMER_SECRET and CONSUMER_KEY for oAuth app
I am working on a python program that runs as an svn post-commit hook. It posts your commit message to Twitter.
It works great, but I just realized something. My CONSUMER_SECRET and CONSUMER_KEY are right there in the source code. That's probably a ba... | Where to save CONSUMER_SECRET and CONSUMER_KEY for oAuth app | I am working on a python program that runs as an svn post-commit hook. It posts your commit message to Twitter.
It works great, but I just realized something. My CONSUMER_SECRET and CONSUMER_KEY are right there in the source code. That's probably a bad thing.
I'm new to python, and I was actually just converting som... | [
"Keep such things in a settings file that you do not commit to your versioning system or code repository in any way. Rather provide a template for the file with documentation on how to populate it with the needed settings (such as their application credentials).\n"
] | [
6
] | [] | [] | [
"oauth",
"python",
"svn",
"twitter"
] | stackoverflow_0005978637_oauth_python_svn_twitter.txt |
Q:
BeautifulSoup: using strings to get a value
Is it possible to use a string to get a value of a tag?
XML structure:
book
title
titletext
book
title
titletext
Code:
books = BeautifulStoneSoup().findAll('book')
for book in books:
book.title.titletext.string
#book.get_by_string('title.titlet... | BeautifulSoup: using strings to get a value | Is it possible to use a string to get a value of a tag?
XML structure:
book
title
titletext
book
title
titletext
Code:
books = BeautifulStoneSoup().findAll('book')
for book in books:
book.title.titletext.string
#book.get_by_string('title.titletext').string is this possible?
If it's not possi... | [
"I would suggest looking into ElementTree. It has what you need. As a quick example:\nimport xml.etree.cElementTree\n\ndoc = xml.etree.cElementTree.parse( filename )\nfor e in doc.getiterator( 'title' ):\n book_title = e.attrib[ 'titletext' ]\n\nObviously I'm not handling error conditions, but using try/except... | [
2
] | [] | [] | [
"beautifulsoup",
"python"
] | stackoverflow_0005976927_beautifulsoup_python.txt |
Q:
Python: detect duplicates using a set
I have a large number of objects I need to store in memory for processing in Python. Specifically, I'm trying to remove duplicates from a large set of objects. I want to consider two objects "equal" if a certain instance variable in the object is equal. So, I assumed the ea... | Python: detect duplicates using a set | I have a large number of objects I need to store in memory for processing in Python. Specifically, I'm trying to remove duplicates from a large set of objects. I want to consider two objects "equal" if a certain instance variable in the object is equal. So, I assumed the easiest way to do this would be to insert all... | [
"You forgot to also define __eq__().\n\nIf a class does not define a __cmp__() or __eq__() method it should not define a __hash__() operation either; if it defines __cmp__() or __eq__() but not __hash__(), its instances will not be usable in hashed collections. If a class defines mutable objects and implements a __... | [
14,
4,
2,
1,
0
] | [] | [] | [
"python",
"python_3.x",
"set"
] | stackoverflow_0005979071_python_python_3.x_set.txt |
Q:
How to assign variable to python using GDB's new python support?
Recently I came across with surprise the the current version of GDB support python scrippting, which very likely means I can plot variables while debugging the program -- something I dreamed about a long time ago. However, I quickly get stuck because... | How to assign variable to python using GDB's new python support? | Recently I came across with surprise the the current version of GDB support python scrippting, which very likely means I can plot variables while debugging the program -- something I dreamed about a long time ago. However, I quickly get stuck because I can't get a variable's value "out of" GDB and assign it to a python... | [
"To access the variable x in the currently selected gdb frame, you can use\nx = gdb.selected_frame().read_var(\"x\")\n\nThis will assign a gdb.Value instance to x.\n"
] | [
3
] | [] | [] | [
"gdb",
"python"
] | stackoverflow_0005978426_gdb_python.txt |
Q:
Facebook status update using pyfacebook
Update status Facebook using Python
I am using this answer to solve my problem.
But this thing asks to authenticate the app , that is ok. But every time I run the script it again opens the browser .. what I want is to post it silently without opening the browser once I hav... | Facebook status update using pyfacebook | Update status Facebook using Python
I am using this answer to solve my problem.
But this thing asks to authenticate the app , that is ok. But every time I run the script it again opens the browser .. what I want is to post it silently without opening the browser once I have given all the permissions to the app.
| [
"PyFacebook is deprecated. Use the new Oauth REST Api.\n"
] | [
2
] | [] | [] | [
"facebook",
"pyfacebook",
"python"
] | stackoverflow_0005978497_facebook_pyfacebook_python.txt |
Q:
Python twisted: iterators and yields/inlineCallbacks
Folks,
Am thoroughly confused, so it's possible I am not even asking things correctly, but here goes:
I have a twisted application using inlineCallbacks. Now I need to define an iterator which will mean a generator is returned to the caller. However, the iterato... | Python twisted: iterators and yields/inlineCallbacks | Folks,
Am thoroughly confused, so it's possible I am not even asking things correctly, but here goes:
I have a twisted application using inlineCallbacks. Now I need to define an iterator which will mean a generator is returned to the caller. However, the iterator cannot be inlineCallbacks decorated, can it be? If not, ... | [
"You're right that you can't express what you want to express in cacheiter. The inlineCallbacks decorator won't let you have a function that returns an iterator. If you decorate a function with it, then the result is a function that always returns a Deferred. That's what it is for.\nPart of what makes this diffi... | [
13,
1
] | [
"Try writing your iterator as a DeferredGenerator.\n"
] | [
-1
] | [
"python",
"twisted"
] | stackoverflow_0005972664_python_twisted.txt |
Q:
PyQt tableview and edits to multiple selected cells
Ive been working on a simple tableview model, ive hit a stumbling block when i want to edit multiple cells.
Specifically I need to be able to change the checkstate on my cells checkboxes. When i select more then one cell and toggle the check boxes only the click... | PyQt tableview and edits to multiple selected cells | Ive been working on a simple tableview model, ive hit a stumbling block when i want to edit multiple cells.
Specifically I need to be able to change the checkstate on my cells checkboxes. When i select more then one cell and toggle the check boxes only the clicked cell updates its checkboxes.
Any help would be great.... | [
"I guess you have a variable to store your selected cells. Then for all selected cells you force the checking by calling the setCheckedState() method.\nLet me know if I'm mistaken.\n"
] | [
0
] | [] | [] | [
"pyqt",
"python",
"qt",
"qtableview"
] | stackoverflow_0005966852_pyqt_python_qt_qtableview.txt |
Q:
Python to Jython Gotchas?
I am starting migration process from python to jython. Has anyone done this with ease before?
What are the gotchas? Should I build first inside Jython IDE then deploy or what?
A:
Keep in mind that in jython, while running under Java everything thing is 'Big-Endian' no matter what platf... | Python to Jython Gotchas? | I am starting migration process from python to jython. Has anyone done this with ease before?
What are the gotchas? Should I build first inside Jython IDE then deploy or what?
| [
"Keep in mind that in jython, while running under Java everything thing is 'Big-Endian' no matter what platform you're on, whereas on a PC/Linux/Mac(x86) platform python is Little Endian. Make sure that when you're using struct.pack and struct.unpack you use the appropriate prefix\nwithout prefix\nwrite data (en... | [
4,
2
] | [] | [] | [
"jython",
"migration",
"python"
] | stackoverflow_0005812362_jython_migration_python.txt |
Q:
Python: Retrieve items from a set
In general, Python sets don't seem to be designed for retrieving items by key. That's obviously what dictionaries are for. But is there anyway that, given a key, you can retrieve an instance from a set which is equal to the key?
Again, I know this is exactly what dictionaries ar... | Python: Retrieve items from a set | In general, Python sets don't seem to be designed for retrieving items by key. That's obviously what dictionaries are for. But is there anyway that, given a key, you can retrieve an instance from a set which is equal to the key?
Again, I know this is exactly what dictionaries are for, but as far as I can see, there a... | [
"I'd definitely use a dictionary here. Reusing the firstname instance variable as a dictionary key won't copy it -- the dictionary will simply use the same object. I doubt a dictionary will use significantly more memory than a set.\nTo actually save memory, add a __slots__ attribute to your classes. This will pr... | [
8,
3,
2
] | [] | [] | [
"python",
"python_3.x",
"set"
] | stackoverflow_0005979861_python_python_3.x_set.txt |
Q:
django-avatar strange error
I'm using django-avatar and my template have:
{% load i18n avatar_tags %}
{% render_avatar avatar 100 %}
and I get this error:
Environment:
Request Method: GET
Request URL: http://test.me/profile/myuser
Django Version: 1.3
Python Version: 2.6.6
Installed Applications:
['django.contri... | django-avatar strange error | I'm using django-avatar and my template have:
{% load i18n avatar_tags %}
{% render_avatar avatar 100 %}
and I get this error:
Environment:
Request Method: GET
Request URL: http://test.me/profile/myuser
Django Version: 1.3
Python Version: 2.6.6
Installed Applications:
['django.contrib.auth',
'django.contrib.conten... | [
"From the django-avatar docs:\n{% render_avatar avatar [size in pixels] %}\nGiven an actual avatar.models.Avatar object instance, renders an HTML img tag to represent that avatar at the requested size.\nSo, in your view, you need to get the avatar associated with the user:\navatar = Avatar.objects.get(user=request.... | [
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0005971951_django_python.txt |
Q:
wx.TreeCtrl item
I'm trying to use a TreeCtrl to represent a folder structure. For each folder I need to know it's absolute path and name. I'm currently doing something like this:
self.root = self.tree.AddRoot(project.name)
self.tree.SetPyData(self.root, None)
self.root.path = root
---- other code -----
childIt... | wx.TreeCtrl item | I'm trying to use a TreeCtrl to represent a folder structure. For each folder I need to know it's absolute path and name. I'm currently doing something like this:
self.root = self.tree.AddRoot(project.name)
self.tree.SetPyData(self.root, None)
self.root.path = root
---- other code -----
childItem = self.tree.AppendI... | [
"What is the .path property? Is this something you are creating or an actual member of the TreeItemId object (this is the object returned from the \"AppendItem\" method)? I do not see any docs on it.\nIf you want to store arbitrary data in the child items use SetPyData/GetPyData methods.\nchildItem = self.tree.Ap... | [
1
] | [] | [] | [
"python",
"wxpython",
"wxtextctrl"
] | stackoverflow_0005980067_python_wxpython_wxtextctrl.txt |
Q:
How to install lxml for python without administative rights on linux?
I just need some packages which dont present at the host machine (and I and linux... we... we didn't spend much time together...).
I used to install them like:
# from the source
python setup.py install --user
or
# with easy_install
easy_install... | How to install lxml for python without administative rights on linux? | I just need some packages which dont present at the host machine (and I and linux... we... we didn't spend much time together...).
I used to install them like:
# from the source
python setup.py install --user
or
# with easy_install
easy_install prefix=~/.local package
But it doesn't work with lxml. I get a lot of err... | [
"If you have no admin rights, and cannot convince the administrator to install the relevant packages for you, you have two options:\nOption 1 - Download sources for libxml2 and libxslt and compile and install them under your $HOME somewhere, then build python-lxml against those copies.\nThis is a pretty involved ex... | [
11
] | [] | [] | [
"linux",
"lxml",
"python"
] | stackoverflow_0005976030_linux_lxml_python.txt |
Q:
Userfriendly way of handling config files in python?
I want to write a program that sends an e-mail to one or more specified recipients when a certain event occurs. For this I need the user to write the parameters for the mail server into a config. Possible values are for example: serveradress, ports, ssl(true/fal... | Userfriendly way of handling config files in python? | I want to write a program that sends an e-mail to one or more specified recipients when a certain event occurs. For this I need the user to write the parameters for the mail server into a config. Possible values are for example: serveradress, ports, ssl(true/false) and a list of desired recipients.
Whats the user-frien... | [
"Are you saying that the fact that the config file would need to be valid Python makes it unfriendly? It seems like having lines in a file like: \n server = 'mail.domain.com'\n port = 25\n\n...etc would be intuitive enough while still being valid Python. If you don't want the user to have to know that they have to ... | [
4,
2,
1,
1
] | [] | [] | [
"configuration",
"python"
] | stackoverflow_0005980101_configuration_python.txt |
Q:
Django admin choice field dynamically populated by generic foreign key's model fields
Say I have the following simple models for some tagging application (this is simplified from the actual code):
# Model of tag templates
class TagTemplate(models.Model):
name = models.CharField()
content_type = models.Fore... | Django admin choice field dynamically populated by generic foreign key's model fields | Say I have the following simple models for some tagging application (this is simplified from the actual code):
# Model of tag templates
class TagTemplate(models.Model):
name = models.CharField()
content_type = models.ForeignKey(ContentType)
class Tag(models.Model):
template = models.ForeignKey(TagTemplate)... | [
"You can subclass the form for that model\nclass TagTemplateForm(forms.ModelForm):\n def __init__(self, *args, **kwargs):\n super(TagTemplateForm, self).__init__(*args, **kwargs)\n if self.instance.content_type == SomeContentType:\n **dynamically create your fields here**\n elif s... | [
1
] | [] | [] | [
"django",
"django_admin",
"django_models",
"python"
] | stackoverflow_0001444587_django_django_admin_django_models_python.txt |
Q:
wxpython - Binding events in external files
I am trying to bind events from a GUI file to use code from another file (effectively a "front end" and a "back end"). I can get the back end and front end working within the same file, but when I try to move them into separate files, I have issues getting the back end t... | wxpython - Binding events in external files | I am trying to bind events from a GUI file to use code from another file (effectively a "front end" and a "back end"). I can get the back end and front end working within the same file, but when I try to move them into separate files, I have issues getting the back end to see parts (labels, buttons, etc.) of the front ... | [
"One solution is to modify change_label to accept an argument that identifies the label to change. For example:\ndef change_label(event, label):\n label.SetLabel(\"barfoo\")\n\nThen, use lambda to create a callback that passes that argument in:\nbtn.Bind(wx.EVT_BUTTON, label_changer, \n lambda event, label=se... | [
2,
1,
0
] | [] | [] | [
"python",
"wxpython"
] | stackoverflow_0005974428_python_wxpython.txt |
Q:
Craiglist Email Anonymizing for Python/Django
My goal here is to allow users to email each other without disclosing anyone's email addresses on my website.
My initial choice was to create a form which sent mail through my SMTP server (I'm using gmail), spoofing the FROM field to make it look like it's sent by one... | Craiglist Email Anonymizing for Python/Django | My goal here is to allow users to email each other without disclosing anyone's email addresses on my website.
My initial choice was to create a form which sent mail through my SMTP server (I'm using gmail), spoofing the FROM field to make it look like it's sent by one user to another user.
That seemed fairly simple a... | [
"Why don't you set up at Catch-All email address python's imaplib.\nIf you generated a unique token that was connected to the user's email address, then when someone sent an email to @your-domain.com you could catch the message, see if it related to a token in the db and if it did, forward the email on to the users... | [
1
] | [] | [] | [
"django",
"email",
"python"
] | stackoverflow_0005951907_django_email_python.txt |
Q:
Select the closest pair from a list
I have a list(s),take an example
[(35.9879845760485, -4.74093235801354), (35.9888687992442, -4.72708076713794),
(35.9889733432982, -4.72758983150694), (35.9915751019521, -4.72772881198689),
(35.9935223025608, -4.72814213543564), (35.9941433944962, -4.72867416528065),
(35.99466... | Select the closest pair from a list | I have a list(s),take an example
[(35.9879845760485, -4.74093235801354), (35.9888687992442, -4.72708076713794),
(35.9889733432982, -4.72758983150694), (35.9915751019521, -4.72772881198689),
(35.9935223025608, -4.72814213543564), (35.9941433944962, -4.72867416528065),
(35.9946670576458, -4.72915181755908), (35.9959465... | [
"Write a distance function and use builtin min function with key parameter.\n>>> from functools import partial\n>>> dist=lambda s,d: (s[0]-d[0])**2+(s[1]-d[1])**2 #a little function which calculates the distance between two coordinates\n>>> a=[(35.9879845760485, -4.74093235801354), (35.9888687992442, -4.72708076713... | [
7,
7,
2
] | [] | [] | [
"list",
"python"
] | stackoverflow_0005981502_list_python.txt |
Q:
What are some good beginner’s guides to web development with frameworks (particularly Django)?
I have been wanting to do some web based development project. Basically, I want to learn it. I want to basically run, how to create my own site with a backend database and stuff. For example, as most of you might have se... | What are some good beginner’s guides to web development with frameworks (particularly Django)? | I have been wanting to do some web based development project. Basically, I want to learn it. I want to basically run, how to create my own site with a backend database and stuff. For example, as most of you might have seen the movie by now, how "Facebook" was made from scratch- it is sort of a web development project. ... | [
"My recommendation is to start very simple. Think of a small app you might find useful, or you'd just like to make, say a contact manager.\nStep one is to get your Django dev server running. After that you need to have an understanding of what MVT (model, view, template) is, and what it means to how your site/app f... | [
6,
3,
1
] | [
"http://www.google.com/search?q=django+tutorials\nFrom the first two pages of the SERPs\n\nGet Started With Django\nLearn Django: Create a Wiki in 20 minutes video tutorial\nDjango Beginner Tutorial: Blog in 8 minutes\n10 Django Trouble Spots for Beginners\n\n"
] | [
-1
] | [
"django",
"python"
] | stackoverflow_0005981454_django_python.txt |
Q:
How do you write a cron job to backup a MySQL database?
UPDATE: I do not know Perl or Python as I have said. Don't give me examples because I don't understand it!
I have looked at other posts here, but do not see any real answer. I use Go Daddy and would like to backup my MySQL database every day, and if possible ... | How do you write a cron job to backup a MySQL database? | UPDATE: I do not know Perl or Python as I have said. Don't give me examples because I don't understand it!
I have looked at other posts here, but do not see any real answer. I use Go Daddy and would like to backup my MySQL database every day, and if possible only allow 7 backups in the folder at once.
Folder: _db_backu... | [
"here's what I use\n#!/bin/bash \nDATE_NOW=$(date +%Y%m%d)\nBACKUP_DIR=/Users/nico/${DATE_NOW}\n\nmkdir -p ${BACKUP_DIR}\n\necho \"Dumping data ...\"\nmysqldump -ume -hlocalhost -ppass db > ${BACKUP_DIR}/${DATE_NOW}-mybackup.sql ... | [
2
] | [] | [] | [
"cron",
"mysql",
"perl",
"php",
"python"
] | stackoverflow_0005981774_cron_mysql_perl_php_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.