content stringlengths 85 101k | title stringlengths 0 150 | question stringlengths 15 48k | answers list | answers_scores list | non_answers list | non_answers_scores list | tags list | name stringlengths 35 137 |
|---|---|---|---|---|---|---|---|---|
Q:
How to import part of a module in python?
I need to use a python module (available in some library). The module looks like this:
class A:
def f1():
...
print "Done"
...
I need only the functionality of class A. However, when I import the module, the code at bottom (print and others) gets executed. Is there a... | How to import part of a module in python? | I need to use a python module (available in some library). The module looks like this:
class A:
def f1():
...
print "Done"
...
I need only the functionality of class A. However, when I import the module, the code at bottom (print and others) gets executed. Is there a way to avoid that? Essentially I need to impor... | [
"Yes, sure:\nfrom module1 import A\n\nIs the general syntax. For example:\nfrom datetime import timedelta\n\nThe code at the bottom should be protected from running at import time by being wrapped like so:\nif __name__ == \"__main__\":\n # Put code that should only run when the module\n # is used as a stand-alone... | [
11,
3,
0
] | [] | [] | [
"import",
"module",
"python"
] | stackoverflow_0004283876_import_module_python.txt |
Q:
Error messages in Python board game - defining global variables
Hey, I'm making a board game in python and i'm having a bit of trouble with the errors
For example:
ERROR_MOVE_CANT = "Error: %s %s can't move in direction %s" %(player, piece, direction)
When I try and raise this error later in my program I use:
if ... | Error messages in Python board game - defining global variables | Hey, I'm making a board game in python and i'm having a bit of trouble with the errors
For example:
ERROR_MOVE_CANT = "Error: %s %s can't move in direction %s" %(player, piece, direction)
When I try and raise this error later in my program I use:
if board[newch[1]][newch[0]] != '.':
return ((ERROR_MOVE_CANT)%(play... | [
"global is merely the last place that is looked; you probably want to make it a local variable when you are using it, or correctly refer to it if it is an instance variable: self.player.\n",
"You probably set the error message inside a function, creating a local variable instead of a global one:\ndef f():\n ER... | [
0,
0
] | [] | [] | [
"error_handling",
"grid",
"python"
] | stackoverflow_0006173599_error_handling_grid_python.txt |
Q:
ffmpeg get meta data in php or python
I am trying to parse ffmpeg output in php to extract all meta data of a mp3 URL.
Is there any pre-written API or something in php or python?
We can use this command to generate a new mp3 file with specified tags:
ffmpeg -i inputfile -metadata title="Movie Title" -metadata yea... | ffmpeg get meta data in php or python | I am trying to parse ffmpeg output in php to extract all meta data of a mp3 URL.
Is there any pre-written API or something in php or python?
We can use this command to generate a new mp3 file with specified tags:
ffmpeg -i inputfile -metadata title="Movie Title" -metadata year="2010" outputfile
But how can we extract... | [
"I think this is what you are looking for.\nFrom the API documentation:\n$movie->getTitle()\n$movie->getArtist()\n$movie->getTrackNumber()\n$movie->getYear()\n$movie->getFrameHeight()\n$movie->getFrameWidth()\n$movie->getPixelFormat()\n$movie->getBitRate()\n\nand so on\n"
] | [
1
] | [] | [] | [
"ffmpeg",
"id3_tag",
"mp3",
"php",
"python"
] | stackoverflow_0006178301_ffmpeg_id3_tag_mp3_php_python.txt |
Q:
GAE - django manage.py problem
Hello i am trying to use GAE with django but i am facing a problem.
I used the testapp and i made a new app. Lets say it test, with the command manage.py startapp test.
Then i made some models and i tried to use the command manage.py sql test.
The problem is that it does not work and... | GAE - django manage.py problem | Hello i am trying to use GAE with django but i am facing a problem.
I used the testapp and i made a new app. Lets say it test, with the command manage.py startapp test.
Then i made some models and i tried to use the command manage.py sql test.
The problem is that it does not work and gives me this.
WARNING 2011-05-26 ... | [
"That's not an error, that's a warning. Assuming your models are correct, the message will go away after you actually store something into your backend (That's when your .gaedata\\datastore will get populated).\n"
] | [
0
] | [] | [] | [
"django",
"google_app_engine",
"python"
] | stackoverflow_0006143952_django_google_app_engine_python.txt |
Q:
Monthly total function for different object properties
I have the following function that calculates the total widgets manufactured each month for the given year:
def get_monthly_totals(year):
queryset = Widget.objects.filter(manufactured__year=year)
totals = [0] * 12
for widget in queryset:
... | Monthly total function for different object properties | I have the following function that calculates the total widgets manufactured each month for the given year:
def get_monthly_totals(year):
queryset = Widget.objects.filter(manufactured__year=year)
totals = [0] * 12
for widget in queryset:
totals[widget.manufactured.month -1] += 1
return total... | [
"One option is to use getattr():\ndef get_monthly_totals(year, attr):\n queryset = Widget.objects.filter(**{attr + \"__year\": year})\n totals = [0] * 12\n for widget in queryset:\n totals[getattr(widget, attr).month -1] += 1\n return totals\n\ntotals_manufactured = gtotalset_monthly_totals(y... | [
0
] | [] | [] | [
"python"
] | stackoverflow_0006178680_python.txt |
Q:
Is it possible to retrieve a value in a child class generated by a decorator defined in a base class?
I have a child class method I want to conditionally short circuit. What I'm trying to do is something like this except I want to put the validation logic into the base class.
class BaseClass(object):
def getva... | Is it possible to retrieve a value in a child class generated by a decorator defined in a base class? | I have a child class method I want to conditionally short circuit. What I'm trying to do is something like this except I want to put the validation logic into the base class.
class BaseClass(object):
def getvalue(self):
return True
def validate(self):
validated = self.getvalue()
return v... | [
"@tponthieux, what you can do is setting the attribute of the called function (method) and then retrieving it:\nSimple example (updated):\ndef validate(func): \n def wrapped(self, *args, **kwargs):\n self.valid = True\n func(self, *args, **kwargs)\n return wrapped\n\nclass TestClass(object):\... | [
1,
1
] | [] | [] | [
"decorator",
"python"
] | stackoverflow_0006174003_decorator_python.txt |
Q:
Category recursion in Django
Ok I have been searching everywhere for this and can't seem to find anyway to do it elegantly. Basically I have a Category model that has a category field that a book belongs to and then a parent for the category.
I am trying to create a template to display:
Parent1
Category1
-- booka... | Category recursion in Django | Ok I have been searching everywhere for this and can't seem to find anyway to do it elegantly. Basically I have a Category model that has a category field that a book belongs to and then a parent for the category.
I am trying to create a template to display:
Parent1
Category1
-- booka
-- bookb
Category2
--bookb
--book... | [
"<ul>\n{% for parent in categories %}\n <li>{{ parent.category }}\n <ul>\n {% for category in parent.children.all %}\n <li>{{ category.category }}\n <ul>\n {% for book in category.book_set.all %}\n <li>{{ book.bookname }}</li>\n {% endfor %}\n ... | [
2,
2
] | [] | [] | [
"django",
"python",
"recursion"
] | stackoverflow_0006179194_django_python_recursion.txt |
Q:
Extending Numpy with C function
I am trying to speed up my Numpy code and decided that I wanted to implement one particular function where my code spent most of the time in C.
I'm actually a rookie in C, but I managed to write the function which normalizes every row in a matrix to sum to 1. I can compile it and I ... | Extending Numpy with C function | I am trying to speed up my Numpy code and decided that I wanted to implement one particular function where my code spent most of the time in C.
I'm actually a rookie in C, but I managed to write the function which normalizes every row in a matrix to sum to 1. I can compile it and I tested it with some data (in C) and i... | [
"Unless you have a really good reason not to, you should use cython to interface C and python. (We are starting to use cython instead of raw C inside numpy/scipy themselves).\nYou can see a simple example in my scikits talkbox (since cython has improved quite a bit since then, I think you could write it better toda... | [
8,
3,
2,
2,
1
] | [] | [] | [
"c",
"cython",
"numpy",
"python",
"swig"
] | stackoverflow_0004320133_c_cython_numpy_python_swig.txt |
Q:
tkinter canvas item configure
I'm trying to make a dice object, and I want to be able to control the pip colors. I created the pips with a black fill, and I tried to change one to red using
self.canvas.itemconfigure(self.pip1, fill='red')
but it seems to have no effect. There is no error so I'm wondering why th... | tkinter canvas item configure | I'm trying to make a dice object, and I want to be able to control the pip colors. I created the pips with a black fill, and I tried to change one to red using
self.canvas.itemconfigure(self.pip1, fill='red')
but it seems to have no effect. There is no error so I'm wondering why the change doesn't show up.
Minimum ... | [
"First rule of debugging: examine your data. If you put a print statement or stop the debugger just before the call to itemconfigure you will see that self.pip1 has a value of None. So the first thing you should ask yourself is, \"why is it None?\"\nThe reason it is None is that you create it in a method but neglec... | [
1
] | [] | [] | [
"python",
"tkinter",
"tkinter_canvas"
] | stackoverflow_0006179630_python_tkinter_tkinter_canvas.txt |
Q:
What exactly is happening in this piece of code?
I attempted to recreate a piece of code which is basically a minimalist Tomagatchi like thing. However when it is fed, and listened to, it's "mood" value does not change. It remains "mad". Any help would be greatly appreciated!
{#Create name, hunger, boredom attribu... | What exactly is happening in this piece of code? | I attempted to recreate a piece of code which is basically a minimalist Tomagatchi like thing. However when it is fed, and listened to, it's "mood" value does not change. It remains "mad". Any help would be greatly appreciated!
{#Create name, hunger, boredom attributes. Hunger and Boredom are numberical attributes
cla... | [
"In _getMood, there should be elifs.\n if unhappiness < 5:\n mood = \"happy\"\n elif 5 <= unhappiness <= 10:\n mood = \"okay\"\n elif 11 <= unhappiness <= 15:\n mood = \"frustrated\"\n else:\n mood = \"mad\"\n\nWithout them, it was actually only checking if unhappiness was be... | [
7,
2
] | [] | [] | [
"debugging",
"python"
] | stackoverflow_0006179327_debugging_python.txt |
Q:
Can't change objects passed to python functions with boost::python
I have some class functions that takes in parameters by pointer. However, when I expose and override these functions in boost::python, any changes I make to the parameters are not reflected back to the original, meaning it isn't being passed by poi... | Can't change objects passed to python functions with boost::python | I have some class functions that takes in parameters by pointer. However, when I expose and override these functions in boost::python, any changes I make to the parameters are not reflected back to the original, meaning it isn't being passed by pointer as I expected. For an example of what I mean, here's some of my cod... | [
"The behavior you're seeing is because Boost Python copies the C++ instance and would then be disconnected from the instance you hold in your C++ lib. This is customizable by changing the \"HeldType\" in the class_<T, Bases, HeldType, NonCopyable> instantiation. See the Boost documentation for more information. Not... | [
2,
0
] | [] | [] | [
"boost_python",
"c++",
"python"
] | stackoverflow_0006118719_boost_python_c++_python.txt |
Q:
SWIG C-to-Python Int Array
I am trying to access a C function with the following prototype from python using swig:
int cosetCoding(int writtenDataIn, int newData, const int memoryCells, int *cellFailure, int failedCell);
Swig creates the .so with no problems and I can import it into python, but when I try to acce... | SWIG C-to-Python Int Array | I am trying to access a C function with the following prototype from python using swig:
int cosetCoding(int writtenDataIn, int newData, const int memoryCells, int *cellFailure, int failedCell);
Swig creates the .so with no problems and I can import it into python, but when I try to access it with the following:
coset... | [
"Use ctypes if you can. It is simpler. However, since you asked for SWIG, what you need is a typemap describing how to handle the int*. SWIG doesn't know how many integers may be pointed to. Below is hacked from an example in the SWIG documentation on multi-argument typemaps:\n%typemap(in) (const int memoryCell... | [
14,
8,
2
] | [] | [] | [
"c",
"linux",
"python",
"swig"
] | stackoverflow_0005778500_c_linux_python_swig.txt |
Q:
strange IPython behavior: "pass", "return", or "raise" in variable name terminates function/class definition
I have been working through the SQLAlchemy ORM tutorial in an IPython shell and got to the point where I had to put password = Column(String) in a class definition. Oddly, the class definition terminated as... | strange IPython behavior: "pass", "return", or "raise" in variable name terminates function/class definition | I have been working through the SQLAlchemy ORM tutorial in an IPython shell and got to the point where I had to put password = Column(String) in a class definition. Oddly, the class definition terminated as soon as I entered it.
After playing around a bit, I've found that any line starting with pass, return, or raise i... | [
"It does not work that way on my system.\nIn [1]: def f(x):\n ...: returnfoo = None\n ...: return returnfoo\n ...: \n\nMy version:\n$ ipython -V\n0.10.2\n\n",
"Don't have that issue:\n>>> def f(x):\n returnfoo = None\n return x\n...: \n\n>>> f(1)\n<<< 1\n\n"
] | [
1,
0
] | [] | [] | [
"definition",
"function_declaration",
"ipython",
"python",
"reserved_words"
] | stackoverflow_0006180040_definition_function_declaration_ipython_python_reserved_words.txt |
Q:
What to return after a django form has failed validation?
How shall I return to my page after a django form has failed validation?
This is what I have at the moment, I return a render_to_response after it has failed with my form objects and all the other objects I need to pass back in. But The url in the browser h... | What to return after a django form has failed validation? | How shall I return to my page after a django form has failed validation?
This is what I have at the moment, I return a render_to_response after it has failed with my form objects and all the other objects I need to pass back in. But The url in the browser has the value of the form action and so this seems to me as if I... | [
"Sessions would be good for this, or if you use AJAX you can validate the form, then return your object or some sort of error message or whatever you want after a failure. One or the other would probably be best. You could also pass params from the POST request along as GET query params to the redirected view, or p... | [
0
] | [] | [] | [
"django",
"django_forms",
"django_validation",
"python"
] | stackoverflow_0006180119_django_django_forms_django_validation_python.txt |
Q:
Interactive movie / video processing with PyQT / OpenCV
I am starting out on a project in which I need to build a customized annotation tool for movies and video. Some person (not technically minded) will need to pop open a GUI that I create, open either a video file or a directory of frames that result from chopp... | Interactive movie / video processing with PyQT / OpenCV | I am starting out on a project in which I need to build a customized annotation tool for movies and video. Some person (not technically minded) will need to pop open a GUI that I create, open either a video file or a directory of frames that result from chopping up a video file, and then use a window (much like QuickTi... | [
"Qt(PyQt) has a good multimedia support via Phonon module. You can easily use that module to achieve Video window, it can provide an easy-to-use video player and you can get playing position etc.\n"
] | [
1
] | [] | [] | [
"opencv",
"pyqt",
"python",
"video_processing"
] | stackoverflow_0006179780_opencv_pyqt_python_video_processing.txt |
Q:
Shortcut to print only 1 item from list of dictionaries
l = [
{'bob':'hello','jim':'thanks'},
{'bob':'world','jim':'for'},
{'bob':'hey','jim':'the'},
{'bob':'mundo','jim':'help'}
]
for dict in l:
print dict['jim']
Is there a one liner or pythonic way of doing this?
I'm trying to retrieve a li... | Shortcut to print only 1 item from list of dictionaries | l = [
{'bob':'hello','jim':'thanks'},
{'bob':'world','jim':'for'},
{'bob':'hey','jim':'the'},
{'bob':'mundo','jim':'help'}
]
for dict in l:
print dict['jim']
Is there a one liner or pythonic way of doing this?
I'm trying to retrieve a list of just 1 item in a list of dictionaries
| [
"[d['jim'] for d in l]\n\nAnd don't use dict as a variable name. It masks the dict() built-in.\n",
"Yes, with good ol' functional programming:\nmap(lambda d: d['jim'], l)\n\n",
"Sure, for example:\nIn []: l\nOut[]: \n[{'bob': 'hello', 'jim': 'thanks'},\n {'bob': 'world', 'jim': 'for'},\n {'bob': 'hey', 'jim': '... | [
5,
2,
2
] | [] | [] | [
"python"
] | stackoverflow_0006180218_python.txt |
Q:
Why does PIL thumbnail not resizing correctly?
I am trying to create and save a thumbnail image when saving the original user image in the userProfile model in my project, below is my code:
def save(self, *args, **kwargs):
super(UserProfile, self).save(*args, **kwargs)
THUMB_SIZE = 45, 45
image = Image... | Why does PIL thumbnail not resizing correctly? | I am trying to create and save a thumbnail image when saving the original user image in the userProfile model in my project, below is my code:
def save(self, *args, **kwargs):
super(UserProfile, self).save(*args, **kwargs)
THUMB_SIZE = 45, 45
image = Image.open(join(MEDIA_ROOT, self.headshot.name))
fn,... | [
"The image.thumbnail() function will maintain the aspect ratio of the original image.\nUse image.resize() instead.\nUPDATE\nimage = image.resize(THUMB_SIZE, Image.ANTIALIAS) \nthumb_fn = fn + '-thumb' + ext\ntf = NamedTemporaryFile()\nimage.save(tf.name, 'JPEG')\n\n",
"Given:\nimport Image # Python Imaging... | [
13,
6
] | [] | [] | [
"django",
"django_models",
"python",
"python_imaging_library"
] | stackoverflow_0006177532_django_django_models_python_python_imaging_library.txt |
Q:
Efficient incremental implementation of poset
I'm implementing in terms of SQLAlchemy a structure that has the mathematical characteristic of Partially Ordered Set, in which I need to be able to add and remove edges one at a time.
In my current, best design, I use two adjacency lists, one being the assignment list... | Efficient incremental implementation of poset | I'm implementing in terms of SQLAlchemy a structure that has the mathematical characteristic of Partially Ordered Set, in which I need to be able to add and remove edges one at a time.
In my current, best design, I use two adjacency lists, one being the assignment list (approximately edges in the Hass Diagram), since I... | [
"Well, I went and worked out the solution to my own problem. The crude part of it is to apply the Floyd-Warshall algorithm on the intersection of the descendents of the ancestors of the parent node with the ancestors of the descendents of the child node, but only apply the output to the union of the parent's ances... | [
1,
0
] | [] | [] | [
"poset",
"python",
"sql",
"sqlalchemy"
] | stackoverflow_0006131098_poset_python_sql_sqlalchemy.txt |
Q:
web2py with configuration per environment
Does web2py support, out of the box, configuration per environment (development, staging, production, etc.)? Something similar to Grails and Ruby on Rails.
I read/skimmed through official book but could not find anything.
A:
The web2py developers do not believe that is a... | web2py with configuration per environment | Does web2py support, out of the box, configuration per environment (development, staging, production, etc.)? Something similar to Grails and Ruby on Rails.
I read/skimmed through official book but could not find anything.
| [
"The web2py developers do not believe that is a good approach. \nWe do not believe in the sharp distinction between development and production.\nFor eaxmple, if an app has a bug, the bug is always recorded and logged, never shown to the user, only shown to the administrator.\nMoreover web2py does not have a configu... | [
4
] | [] | [] | [
"python",
"web2py"
] | stackoverflow_0006180592_python_web2py.txt |
Q:
Is it Possible to rewrite the getter of a property in a subclass?
For example:
class Example:
def __init__(self):
self.v = 0
@property
def value(self):
return self.v
@value.setter
def value(self, v):
self.v = v
class SubExample(Example):
pass
Would it be possible ... | Is it Possible to rewrite the getter of a property in a subclass? | For example:
class Example:
def __init__(self):
self.v = 0
@property
def value(self):
return self.v
@value.setter
def value(self, v):
self.v = v
class SubExample(Example):
pass
Would it be possible to rewrite just the getter to value in SubExample?
| [
"You can do so like this\nclass DoubleExample(Example):\n @Example.value.getter\n def value(self):\n return self.v * 2\n\no = Example()\no.value = 1\nprint o.value # prints \"1\"\n\np = DoubleExample()\np.value = 1\nprint p.value # prints \"2\"\n\nHowever, this only works if Example is a new-style clas... | [
4,
3,
0
] | [] | [] | [
"inheritance",
"python"
] | stackoverflow_0006180812_inheritance_python.txt |
Q:
Group and Check-mark using Python
I have several files, each of which has data like this (filename:data inside separated by newline):
Mike: Plane\nCar
Paula: Plane\nTrain\nBoat\nCar
Bill: Boat\nTrain
Scott: Car
How can I create a csv file using python that groups all the different vehicles and then puts a X on t... | Group and Check-mark using Python | I have several files, each of which has data like this (filename:data inside separated by newline):
Mike: Plane\nCar
Paula: Plane\nTrain\nBoat\nCar
Bill: Boat\nTrain
Scott: Car
How can I create a csv file using python that groups all the different vehicles and then puts a X on the applicable person, like:
| [
"Assuming those line numbers aren't in there (easy enough to fix if they are), and with an input file like following:\nMike: Plane\nCar\nPaula: Plane\nTrain\nBoat\nCar\nBill: Boat\nTrain\nScott: Car\n\nSolution can be found here : https://gist.github.com/999481\nimport sys\nfrom collections import defaultdict\nimpo... | [
1,
0,
0,
0
] | [] | [] | [
"csv",
"python"
] | stackoverflow_0006180609_csv_python.txt |
Q:
What does --enable-profiling option do when compiling Python?
I'm buildinng my own Python-2.6 in linux. There's an option in configure for enabling C-level code profiling. I've never used that before; so just out of curiousity, what does that option do? what is it for?
A:
Google tells me this:
Python can now be... | What does --enable-profiling option do when compiling Python? | I'm buildinng my own Python-2.6 in linux. There's an option in configure for enabling C-level code profiling. I've never used that before; so just out of curiousity, what does that option do? what is it for?
| [
"Google tells me this:\n\nPython can now be built with\n additional profiling for the\n interpreter itself, intended as an aid\n to people developing the Python core.\n Providing\n ---enable-profiling to the configure script will let you profile the\n interpreter with gprof\n\nIf you are unfamiliar with gprof... | [
5
] | [] | [] | [
"python"
] | stackoverflow_0006180985_python.txt |
Q:
How to install a Swig enabled Python extension (QuickFix)
QuickFix includes bindings for Python. How do I install QuickFix so that I can import quickfix in Python on Windows?
easy_install quickfix doesn't work
both binary and source downloads don't include setup.py
The source download has the following folder cal... | How to install a Swig enabled Python extension (QuickFix) | QuickFix includes bindings for Python. How do I install QuickFix so that I can import quickfix in Python on Windows?
easy_install quickfix doesn't work
both binary and source downloads don't include setup.py
The source download has the following folder called python (amongst many others) - how do I use it?
Even less... | [
"http://www.lfd.uci.edu/~gohlke/pythonlibs/#quickfix\n",
"I don't see any Windows project files, and SWIG implies that there is some native (i.e. C/C++) code to be compiled. Odds are fairly good that this simply won't work under Windows, although you may try Cygwin if it's really important to get this working.\n"... | [
9,
0
] | [] | [] | [
"installation",
"python",
"quickfix",
"windows"
] | stackoverflow_0006179527_installation_python_quickfix_windows.txt |
Q:
Correlation of Two Variables in a Time Series in Python?
If I have two different data sets that are in a time series, is there a simple way to find the correlation between the two sets in python?
For example with:
# [ (dateTimeObject, y, z) ... ]
x = [ (8:00am, 12, 8), (8:10am, 15, 10) .... ]
How might I get the ... | Correlation of Two Variables in a Time Series in Python? | If I have two different data sets that are in a time series, is there a simple way to find the correlation between the two sets in python?
For example with:
# [ (dateTimeObject, y, z) ... ]
x = [ (8:00am, 12, 8), (8:10am, 15, 10) .... ]
How might I get the correlation of y and z in Python?
| [
"Little slow on the uptake here. pandas (http://github.com/wesm/pandas and pandas.sourceforge.net) is probably your best bet. I'm biased because I wrote it but:\nIn [7]: ts1\nOut[7]: \n2000-01-03 00:00:00 -0.945653010936\n2000-01-04 00:00:00 0.759529904445\n2000-01-05 00:00:00 0.177646448683\n2000-01-06 00... | [
38,
10,
4,
1
] | [
"I would recommend the pandas library http://pandas.sourceforge.net/generated/pandas.DataFrame.corr.html?highlight=corr#pandas.DataFrame.corr\n"
] | [
-1
] | [
"python",
"statistics"
] | stackoverflow_0004809577_python_statistics.txt |
Q:
The Tkinter Text Widget Insertion Cursor
Is it possible to get the x y coordinates of the insertion cursor in a Tkinter Text widget? I'm trying to make a popup menu that pops up next to the insertion cursor.
A:
The bbox method can be used to get the bounding box of an index. You can use that to get the position... | The Tkinter Text Widget Insertion Cursor | Is it possible to get the x y coordinates of the insertion cursor in a Tkinter Text widget? I'm trying to make a popup menu that pops up next to the insertion cursor.
| [
"The bbox method can be used to get the bounding box of an index. You can use that to get the position relative to the window. You can use the winfo method to get the x/y of the window. \nTypically popups appear next to the mouse rather than the insertion point (though typically, right-clicking first sets the inser... | [
3
] | [] | [] | [
"popup",
"python",
"text",
"tkinter"
] | stackoverflow_0006180944_popup_python_text_tkinter.txt |
Q:
Migrating from Stata to Python
Some coworkers who have been struggling with Stata 11 are asking for my help to try to automate their laborious work. They mainly use 3 commands in Stata:
tsset (sets a time series analysis)
as in: tsset year_column, yearly
varsoc (Obtain lag-order selection statistics for VARs)
... | Migrating from Stata to Python | Some coworkers who have been struggling with Stata 11 are asking for my help to try to automate their laborious work. They mainly use 3 commands in Stata:
tsset (sets a time series analysis)
as in: tsset year_column, yearly
varsoc (Obtain lag-order selection statistics for VARs)
as in: varsoc column_a column_b
ve... | [
"I believe both scikits.timeseries and econpy / pytrix implement vector autoregression methods, but I haven't put either through their paces. \n",
"scikits.timeseries is mainly for data handling and has only some statistical, econometric analysis and no vectorautoregression. pytrix has some econometrics function... | [
7,
5,
4,
2,
0
] | [] | [] | [
"numpy",
"python",
"stata",
"statistics"
] | stackoverflow_0003946219_numpy_python_stata_statistics.txt |
Q:
Memory usage of file versus database for simple data storage
I'm writing the server for a Javascript app that has a syncing feature. Files and directories being created and modified by the client need to be synced to the server (the same changes made on the client need to be made on the server, including deletes).... | Memory usage of file versus database for simple data storage |
I'm writing the server for a Javascript app that has a syncing feature. Files and directories being created and modified by the client need to be synced to the server (the same changes made on the client need to be made on the server, including deletes).
Since every file is on the server, I'm debating the need for a M... | [
"Probably the filesystem variant will be more efficient memory wise as long as the number of files is low, but that solution probably won't scale. Databases are optimized to do exactly that. Searching the filesystem, opening the file, searching the document, will be expensive as the number of files and requests inc... | [
1,
0,
0
] | [] | [] | [
"django",
"memory",
"python"
] | stackoverflow_0006180732_django_memory_python.txt |
Q:
Python Equivalents of field.getInt(obj)
I'm wondering how is the python equivalent of this code:
Object owner;
Object target
String fieldname;
Field field = owner.getClass().getField(fieldname);
int i = field.getInt(target);
Thanks
A:
i = getattr(target, fieldname)
See the documentation for getattr.
| Python Equivalents of field.getInt(obj) | I'm wondering how is the python equivalent of this code:
Object owner;
Object target
String fieldname;
Field field = owner.getClass().getField(fieldname);
int i = field.getInt(target);
Thanks
| [
"i = getattr(target, fieldname)\n\nSee the documentation for getattr.\n"
] | [
2
] | [] | [] | [
"python"
] | stackoverflow_0006181173_python.txt |
Q:
Python loop that shouldn't work but does anyways
So I decided to learn python this weekend and I started with my default hello world, the prime solver. This code shouldn't work... But for whatever reason it does (for numbers 5 and higher.)
#!/usr/bin/python
a = 2
while a < 65535:
c = 0
a = a + 1
b = 2... | Python loop that shouldn't work but does anyways | So I decided to learn python this weekend and I started with my default hello world, the prime solver. This code shouldn't work... But for whatever reason it does (for numbers 5 and higher.)
#!/usr/bin/python
a = 2
while a < 65535:
c = 0
a = a + 1
b = 2
while b != a:
if a % b == 0:
... | [
"If a is not prime, it has atleast two proper divisors, and of one of them must be smaller than the square root (or both are the square root). If b reaches sqrt(a)+1, then a must be prime. So if b reaches a - 1, you can be pretty sure it's prime. You could also replace it by if a - 3 == b, or a / 2 (but this might ... | [
1,
0
] | [] | [] | [
"loops",
"python"
] | stackoverflow_0006181157_loops_python.txt |
Q:
What's the easiest way to download the source of a webpage in python? (After javascript has been applied)
In python:
I want to download the source of a webpage, after the javascript has been applied. What's the easiest way to do that?
A:
splinter is the easiest way to do this:
from splinter.browser import Brows... | What's the easiest way to download the source of a webpage in python? (After javascript has been applied) | In python:
I want to download the source of a webpage, after the javascript has been applied. What's the easiest way to do that?
| [
"splinter is the easiest way to do this:\nfrom splinter.browser import Browser\nbrowser = Browser()\nbrowser.visit('http://google.com')\n\nsplinter is a tool that makes using several mature products much easier to use. Things like Selenium require lots of getting used to. splinter allows you to learn one API to use... | [
6
] | [] | [] | [
"html",
"http",
"javascript",
"python",
"rest"
] | stackoverflow_0006181382_html_http_javascript_python_rest.txt |
Q:
Parsing python grammar with boost::spirit - problem
I am trying to write a python parser with boost::spirit library. Here is the code:
template <typename Iterator>
class Parser : public qi::grammar<Iterator, space_type>
{
public:
Parser() : Parser::base_type(small_stmt)
{
NEWLINE = lit("<NEWLINE>")... | Parsing python grammar with boost::spirit - problem | I am trying to write a python parser with boost::spirit library. Here is the code:
template <typename Iterator>
class Parser : public qi::grammar<Iterator, space_type>
{
public:
Parser() : Parser::base_type(small_stmt)
{
NEWLINE = lit("<NEWLINE>");
INDENT = lit("<INDENT>");
DEDENT = lit(... | [
"I'd suggest you enable debugging as explained here. This will give you insights what's actually happening. Generally, I suggest building grammars step by step and not trying to implement everything in one big leap. \nThe code you provided above is very difficult to understand for un-unitiated readers as it is very... | [
6
] | [] | [] | [
"boost_spirit",
"c++",
"parsing",
"python"
] | stackoverflow_0006178348_boost_spirit_c++_parsing_python.txt |
Q:
How to get all strings from all nested tags of a xml tag with python's lxml.etree library?
I have an xml file in which it is possible that the following occurs:
...
<a><b>This is</b> some text about <c>some</c> issue I have, parsing xml</a>
...
Edit: Let's assume, the tags could be nested more than only level, me... | How to get all strings from all nested tags of a xml tag with python's lxml.etree library? | I have an xml file in which it is possible that the following occurs:
...
<a><b>This is</b> some text about <c>some</c> issue I have, parsing xml</a>
...
Edit: Let's assume, the tags could be nested more than only level, meaning
<a><b><c>...</c>...</b>...</a>
I came up with this using the python lxml.etree library.
c... | [
"This question has been asked many times.\nYou can use lxml.html.text_content() method.\nimport lxml.html\nt = lxml.html.fromstring(\"...\")\nt.text_content()\n\nREF: Filter out HTML tags and resolve entities in python\nOR use lxml.etree.strip_tags() method.\nREF: In lxml, how do I remove a tag but retain all conte... | [
2
] | [] | [] | [
"elementtree",
"lxml",
"python",
"string",
"xml"
] | stackoverflow_0006180616_elementtree_lxml_python_string_xml.txt |
Q:
manage.py runserver fails
OS X, Python 2.7, a fresh virtualenv:
virtualenv bar
source bar/bin/activate
pip install django --upgrade
django-admin.py startproject foo
cd foo
python manage.py runserver
Then I immediately get this:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_mana... | manage.py runserver fails | OS X, Python 2.7, a fresh virtualenv:
virtualenv bar
source bar/bin/activate
pip install django --upgrade
django-admin.py startproject foo
cd foo
python manage.py runserver
Then I immediately get this:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/Users/xyz/... | [
"This issue seems somehow related to virtualenvwrapper, and my own stupidity; creating a virtualenv manually has resolved it.\n"
] | [
0
] | [] | [] | [
"django",
"macos",
"python"
] | stackoverflow_0006181391_django_macos_python.txt |
Q:
Socket error after Django site deployed using apache and mod_wsgi?
There is a backend function in my site that will call urllib.urlopen(url)) to retrieve data from url. After deploying, all other functions worked well except this one. Calling this function results in [Errno socket error] [Errno -2] Name or service... | Socket error after Django site deployed using apache and mod_wsgi? | There is a backend function in my site that will call urllib.urlopen(url)) to retrieve data from url. After deploying, all other functions worked well except this one. Calling this function results in [Errno socket error] [Errno -2] Name or service not known. It seems that it can't find the host.
But if I use python ma... | [
"It's possible that this could be a permission issue or something else with your Apache environment. Try using a simple WSGI script as a baseline to test URL fetching:\nimport sys\nimport urllib \n\ndef application(environ, start_response):\n page_text = urllib.urlopen(\"http://www.google.com/\").read()\n st... | [
0
] | [] | [] | [
"apache",
"django",
"mod_wsgi",
"python"
] | stackoverflow_0006181531_apache_django_mod_wsgi_python.txt |
Q:
shell script remote execution using python
Is there a way that I can use Python on Windows to execute shell scripts which are located on a remote Unix machine?
P.S: Sorry about the late edit. I do know of Paramiko, but I wanted to know if there is way of doing it without it. For starters, could it be done with sub... | shell script remote execution using python | Is there a way that I can use Python on Windows to execute shell scripts which are located on a remote Unix machine?
P.S: Sorry about the late edit. I do know of Paramiko, but I wanted to know if there is way of doing it without it. For starters, could it be done with subprocess()?
| [
"You will need to ssh into the remote machine and if you have appropriate credentials, you can invoke the shell scripts.\nFor using ssh, you can easily use paramiko module that provides ssh automation\n\nhttp://www.lag.net/paramiko/\n\nA typical example:\nimport paramiko\nimport sys\nimport os\nimport os.path\npass... | [
15,
3,
2,
1,
1,
0,
0
] | [] | [] | [
"python",
"shell",
"unix"
] | stackoverflow_0003781087_python_shell_unix.txt |
Q:
How can I get Vim to highlight syntax as well as textmate
I like the idea of the of editing inside the terminal and like the key bindings of Vim, but the text highlighting in my Vim is much worse than in Textmate. The comparison (textmate is first):
Obviously Vim is much worse. I've turned on syntax highlightin... | How can I get Vim to highlight syntax as well as textmate | I like the idea of the of editing inside the terminal and like the key bindings of Vim, but the text highlighting in my Vim is much worse than in Textmate. The comparison (textmate is first):
Obviously Vim is much worse. I've turned on syntax highlighting in my .vimrc, and have installed python.vim (not sure if thi... | [
"EDIT 2:\nIf you edit python.vim, you'll find the following line:\nsyn keyword pythonStatement def class nextgroup=pythonFunction skipwhite\n\nThat's the crucial line for you. So basically, it styles def and class with pythonStatement and anything that follows it is styled with pythonFunction. You might want to rew... | [
4
] | [] | [] | [
"python",
"textmate",
"vim"
] | stackoverflow_0006181929_python_textmate_vim.txt |
Q:
executing a subprocess from python
I think something is getting subtly mangeled when I attempt to execute a subprocess from a python script
I attempt to execute vlc with some (a lot) of arguments.
the instance of vlc that arises complains:
Your input can't be opened:
VLC is unable to open the MRL ' -vvv rtsp:/... | executing a subprocess from python | I think something is getting subtly mangeled when I attempt to execute a subprocess from a python script
I attempt to execute vlc with some (a lot) of arguments.
the instance of vlc that arises complains:
Your input can't be opened:
VLC is unable to open the MRL ' -vvv rtsp://192.168.1.201:554/ch0_multicast_one --s... | [
"Since you're passing a list to subprocess.Popen, each parameter must be in its own element. So you'd want something like:\npid = subprocess.Popen([\n \"vlc\",\n \"-vvv\",\n \"rtsp://%s:554/ch0_multicast_one\" % target_nvc.ip_address,\n # etc\n], ...)\n\nEach parameter (that the shell would normally par... | [
2,
0
] | [] | [] | [
"python",
"subprocess",
"vlc"
] | stackoverflow_0006182094_python_subprocess_vlc.txt |
Q:
Initialize Python variable from possible missing dict value
What is the Pythonic way to do this?
value = (mydict.has_key('index') and mydict['index']) or 1024
Initialize from a dict's value, if present, otherwise use default value.
Got some answers on LBYL and EAFP, but too verbose code :p
I want some one-line-in... | Initialize Python variable from possible missing dict value | What is the Pythonic way to do this?
value = (mydict.has_key('index') and mydict['index']) or 1024
Initialize from a dict's value, if present, otherwise use default value.
Got some answers on LBYL and EAFP, but too verbose code :p
I want some one-line-initialize.
PS: python-2.4 only (running CentOS5)
| [
"value = mydict.get('index', 1024)\n\n(Note that this is not exactly equivalent to your code, since it will use 1024 only if the key index is not present, while your code also uses 1024 when the value corresponding to key index is falsy. From your explanation I infer the former is what you actually want.)\n",
"A... | [
11,
2,
1,
1
] | [] | [] | [
"dictionary",
"indexing",
"initialization",
"python"
] | stackoverflow_0006181532_dictionary_indexing_initialization_python.txt |
Q:
Python socket server and client, keeps losing connection
I am expanding on a GUI program for a remotely controlled robot. The idea is to program a simple GUI client in Python that connects to a remote server, also written in Python. The client would send simple messages to the server, the server would receive the... | Python socket server and client, keeps losing connection | I am expanding on a GUI program for a remotely controlled robot. The idea is to program a simple GUI client in Python that connects to a remote server, also written in Python. The client would send simple messages to the server, the server would receive the message, and then transmit it via serial to an Arduino Mega t... | [
"You are calling accept() inside the loop, which will block for another connection. The original connection will be dereferenced and automatically closed when/if another connection comes in. Normally, you spawn an independent handler (fork, thread, or add to async event handler) to handle new connections that does ... | [
3
] | [] | [] | [
"arduino",
"pyserial",
"python",
"serial_port",
"sockets"
] | stackoverflow_0006182252_arduino_pyserial_python_serial_port_sockets.txt |
Q:
Using multiprocessing in Python ends in ImportError
I'm trying to run simple programs from Python doc using multiprocessing, however I always get errors like:
Traceback (most recent call last):
File "Poolexample.py", line 1, in <module>
from multiprocessing import Pool
ImportEr... | Using multiprocessing in Python ends in ImportError | I'm trying to run simple programs from Python doc using multiprocessing, however I always get errors like:
Traceback (most recent call last):
File "Poolexample.py", line 1, in <module>
from multiprocessing import Pool
ImportError: cannot import name Pool
or similarly, cannot import... | [
"As @ahojnnes said, multiprocessing was introduced in Python 2.6. So, be sure to use Python 2.6+ if you need this module with painless integration.\nHowever, you could use python-multiprocessing, which is a backport of multiprocessing for Python 2.4 and 2.5.\n"
] | [
1
] | [] | [] | [
"python"
] | stackoverflow_0006167869_python.txt |
Q:
Reading from a text file python
I have a text file which contains a matrix of numbers:
999 999 10 8
3 4 999 999 999
6 999 2 7 999
999 6 3 5 6
999 9 1 10 999
10 6 999 2 2 999
I'm trying to read each line and store it into an array in Python but
I'm having trouble changing each value into an int from a string. ... | Reading from a text file python | I have a text file which contains a matrix of numbers:
999 999 10 8
3 4 999 999 999
6 999 2 7 999
999 6 3 5 6
999 9 1 10 999
10 6 999 2 2 999
I'm trying to read each line and store it into an array in Python but
I'm having trouble changing each value into an int from a string. I tried using the int() when parsing ... | [
"try that:\nmatrix = [[int(i) for i in line.split()] for line in open('myfile.txt')]\n\n[edit]\nif you don't want the first line just read it before.\nwith open('myfile') as f:\n f.readline()\n matrix = ....\n\n",
"Using map() to get a list of lists:\n>>> with open('myfile.txt') as matrix:\n... [map(int... | [
3,
2,
0
] | [
"nums = []\nwith open('file.txt') as f:\n for line in f:\n nums.append([int(n) for n in line.split()])\n\nYou could write that as one list comprehension, but that could get nasty.\n"
] | [
-1
] | [
"parsing",
"python"
] | stackoverflow_0006182504_parsing_python.txt |
Q:
siginterrupt() only works for the first signal? (Python)
For some reason, siginterrupt() only seems to set the behaviour for the first signal received.
In this example program, the first SIGQUIT appears to do nothing, but the second sigquit prints "SIGQUIT Handler" and s.accept() throws an Interrupted system call ... | siginterrupt() only works for the first signal? (Python) | For some reason, siginterrupt() only seems to set the behaviour for the first signal received.
In this example program, the first SIGQUIT appears to do nothing, but the second sigquit prints "SIGQUIT Handler" and s.accept() throws an Interrupted system call exception.
from signal import *
from socket import *
import sy... | [
"It's a bug of python. \"siginterrupt with flag=False is reset when signal received\", which has been fixed in later python2.6 release. (2.6.6+, 2.7+)\nFor the second one, siginterrupt doesn't affect select(). \nsee http://lkml.org/lkml/2005/7/23/119\n",
"Which unix are you using? At the C level, there are differ... | [
4,
2
] | [] | [] | [
"linux",
"python",
"signals",
"unix"
] | stackoverflow_0001664195_linux_python_signals_unix.txt |
Q:
Python web framework + [a]sync tasks; long polling: not Django
I need to create a project that has a web frontend to manage synchronous task execution (ala fabric), async tasks (AMQP), and long-polling/ajax for tabular viewing of results and queues/large, frequently changing datasets (think tail -f syslog). I hav... | Python web framework + [a]sync tasks; long polling: not Django | I need to create a project that has a web frontend to manage synchronous task execution (ala fabric), async tasks (AMQP), and long-polling/ajax for tabular viewing of results and queues/large, frequently changing datasets (think tail -f syslog). I have an existing Python codebase for a lot of the implementation-specif... | [
"I don't have a full vision of python web frameworks but just want to share my point of view on 2 of them : \n\nBottle is light and works fine. If you want something easy to learn and easy to use that may be the right choice. I used it for quite simple front-end apps running locally and i liked it very much.\nTorna... | [
2,
1
] | [
"A couple of suggestions.\nCherryPy is a great low level framework. It doesn't provide a lot of functionality, but it provide a very easy system for mapping http requests to function calls.\nweb.py is another extremely lightweight and easy to use framework. It is more comprehensive than CherryPy, including templa... | [
-1
] | [
"amqp",
"frameworks",
"python"
] | stackoverflow_0006144309_amqp_frameworks_python.txt |
Q:
How come I have this simple error in Selenium?
I'm on AWS micro instance. There is no GUI. I SSH'ed into it.
pip install selenium
sudo apt-get install firefox
Then, I do this in the python shell:
>>> from selenium.webdriver.firefox.webdriver import WebDriver
>>> driver = WebDriver()
Error: cannot open display: :0... | How come I have this simple error in Selenium? | I'm on AWS micro instance. There is no GUI. I SSH'ed into it.
pip install selenium
sudo apt-get install firefox
Then, I do this in the python shell:
>>> from selenium.webdriver.firefox.webdriver import WebDriver
>>> driver = WebDriver()
Error: cannot open display: :0
How do I make this error go away?
| [
"Set up your SSH session to allow X11 forwarding, and run your client from an X windows session. On the server, the config /etc/ssh/sshd_config should have the line X11Forwarding yes. and your client side should have ForwardX11 yes. Then just to be sure invoke ssh with the -X option. The server side should have the... | [
3,
1
] | [] | [] | [
"firefox",
"python",
"selenium",
"user_interface"
] | stackoverflow_0006182913_firefox_python_selenium_user_interface.txt |
Q:
How to write a post to my facebook app's wall from app engine using python?
I have an app engine web app that would like to automatically write a post to the wall of a facebook application I control (i.e. every time a particular event occurs on the website I would like to update the wall of my facebook application... | How to write a post to my facebook app's wall from app engine using python? | I have an app engine web app that would like to automatically write a post to the wall of a facebook application I control (i.e. every time a particular event occurs on the website I would like to update the wall of my facebook application).
This code will be called from a deferred task on the server.
I have been unab... | [
"As an administrator you can grant access to third party apps (e.g. your python app) to post onto your App's Profile Page (http://www.facebook.com/apps/application.php?id=YOUR_APP_ID) using OAuth:\nhttp://developers.facebook.com/docs/authentication/ (Section Page Login)\nOnce you received an access token you should... | [
3,
0
] | [] | [] | [
"facebook",
"google_app_engine",
"python"
] | stackoverflow_0006156052_facebook_google_app_engine_python.txt |
Q:
PHP passing a class as a reference?
in Python, you could do something like this:
class SomeClass(object): pass
s = SomeClass
someClassInstance = s()
How could you accomplish the same effect in PHP? From what I understand, you cannot do this? Is this true?
A:
You can create instances of dynamic class names; simp... | PHP passing a class as a reference? | in Python, you could do something like this:
class SomeClass(object): pass
s = SomeClass
someClassInstance = s()
How could you accomplish the same effect in PHP? From what I understand, you cannot do this? Is this true?
| [
"You can create instances of dynamic class names; simply pass the name of the class as a string:\nclass SomeClass {}\n$s = 'SomeClass';\n$someClassInstance = new $s();\n\n",
"Using reflection:\nclass SomeClass {}\n$s = new ReflectionClass('SomeClass');\n$someClassInstance = $s->newInstance();\n\nThe nice thing ab... | [
7,
1
] | [] | [] | [
"php",
"python"
] | stackoverflow_0006182993_php_python.txt |
Q:
problem: Socket error [Address already in use] in python/selenium
I have a troublesome problem socket.error error: [Errno 10048]: Address already in use. Only one usage of each socket address (protocol/IP address/port) is normally permitted during automated tests using Selenium with Python. The problem is so inter... | problem: Socket error [Address already in use] in python/selenium | I have a troublesome problem socket.error error: [Errno 10048]: Address already in use. Only one usage of each socket address (protocol/IP address/port) is normally permitted during automated tests using Selenium with Python. The problem is so interesting that it runs on one machine (Linux) works correctly, but on anot... | [
"If you open/close the socket multiple times, it could be in the TIME_WAIT state. This would explain why it acts differently on separate platforms (different TIME_WAIT settings and TCP stack). If you're controlling the socket object, you can set SO_REUSEADDR before binding to fix the problem.\nFor example:\nsock = ... | [
1,
1,
0,
0
] | [] | [] | [
"python",
"selenium_rc",
"socketexception"
] | stackoverflow_0006176445_python_selenium_rc_socketexception.txt |
Q:
django-piston generated documentation for several handlers
I'm having a problem regarding the automagic documentation generated in django-pyston. Right now I have this and works:
from piston.handler import BaseHandler
from piston.doc import generate_doc
class FirstHandler(BaseHandler):
...
doc = generated_doc(... | django-piston generated documentation for several handlers | I'm having a problem regarding the automagic documentation generated in django-pyston. Right now I have this and works:
from piston.handler import BaseHandler
from piston.doc import generate_doc
class FirstHandler(BaseHandler):
...
doc = generated_doc(FirstHandler)
And is working fine. The problem is when I add a ... | [
"You don't have to have the line\ndoc = generated_doc(FirstHandler)\n\nwithin the module containing the Handlers. It's just a smaple from the poor documentation.\nThe documentation view fetches all handlers automatically and then generated the documentation. Remove the line and it should work.\n"
] | [
1
] | [] | [] | [
"django",
"django_piston",
"python"
] | stackoverflow_0005804201_django_django_piston_python.txt |
Q:
How to deal with unstable data received from RFID reader?
My application has to connect and receive data from RFID reader for every 2 seconds so it has developed on django framework. Here are related lines in views.py:
HOST = '192.168.0.1'
PORT = 50007
soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
soc.se... | How to deal with unstable data received from RFID reader? | My application has to connect and receive data from RFID reader for every 2 seconds so it has developed on django framework. Here are related lines in views.py:
HOST = '192.168.0.1'
PORT = 50007
soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
soc.settimeout(2)
soc.connect((HOST, PORT))
soc.send('tag.db.scan_tag... | [
"One of the easier things to do would be to use Django's cache framework, and store the data in local memory, or memcached, or the database, etc. You could cache any data recieved, and used the cached data if you don't recieve data, or it's erroneous or whatever:\nfrom django.core.cache import cache\n\n# set cached... | [
1
] | [] | [] | [
"django",
"python",
"rfid"
] | stackoverflow_0006183633_django_python_rfid.txt |
Q:
Problem with get_absolute_url based on entry type
I have one model for different types of entries:
POST = 1
PAGE = 2
ARTICLE = 3
ENTRY_TYPE = (
(POST, "Blog Post"),
(PAGE, "Page"),
(ARTICLE, "Article"),
)
entry_type = models.IntegerField(choices=ENTRY_TYPE, default=POST)
And function to find out abs... | Problem with get_absolute_url based on entry type | I have one model for different types of entries:
POST = 1
PAGE = 2
ARTICLE = 3
ENTRY_TYPE = (
(POST, "Blog Post"),
(PAGE, "Page"),
(ARTICLE, "Article"),
)
entry_type = models.IntegerField(choices=ENTRY_TYPE, default=POST)
And function to find out absolute url for different types of entries based on it ty... | [
"You should be looking at the value of self.entry_type, e.g.:\nif self.entry_type == self.PAGE:\n return '/%s/' % (self.slug)\n\n"
] | [
2
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0006184037_django_django_models_python.txt |
Q:
Complete log management (python)
Similar questions have been asked, but I have not come across an easy-to-do-it way
We have some application logs of various kinds which fill up the space and we face other unwanted issues. How do I write a monitoring script(zipping files of particular size, moving them, watching th... | Complete log management (python) | Similar questions have been asked, but I have not come across an easy-to-do-it way
We have some application logs of various kinds which fill up the space and we face other unwanted issues. How do I write a monitoring script(zipping files of particular size, moving them, watching them, etc..) for this maintenance? I am ... | [
"The \"standard\" way of doing this (atleast on most Gnu/Linux distros) is to use logrotate. I see a /etc/logrotate.conf on my Debian machine which has details on which files to rotate and at what frequency. It's triggered by a daily cron entry. This is what I'd recommend. \nIf you want your application itself to d... | [
7,
0
] | [] | [] | [
"linux",
"logging",
"monitoring",
"python"
] | stackoverflow_0006184079_linux_logging_monitoring_python.txt |
Q:
Surprising output of Python program
I am just started learning Python am getting bit confused after seeing the output of following program:
#!/usr/bin/python
# Function definition is here
def changeme( mylist ):
"This changes a passed list into this function"
mylist = [1,2,3,4]; # This would assig new refe... | Surprising output of Python program | I am just started learning Python am getting bit confused after seeing the output of following program:
#!/usr/bin/python
# Function definition is here
def changeme( mylist ):
"This changes a passed list into this function"
mylist = [1,2,3,4]; # This would assig new reference in mylist
print "Values inside ... | [
"Works for me, with proper indentation:\ndef changeme(mylist):\n mylist.append([1, 2, 3, 4])\n print \"Values inside the function: \", mylist\n\nmylist = [10, 20, 30]\nchangeme(mylist)\nprint \"Values outside the function: \", mylist\n\nOutput:\nValues inside the function: [10, 20, 30, [1, 2, 3, 4]]\nValues ... | [
4,
3,
1
] | [] | [] | [
"python"
] | stackoverflow_0006184257_python.txt |
Q:
Can I reliably unimport a Python module if I import it in a namespace?
Basically, I have a long running process where I would like to be able to unimport modules and recover memory via the gc. I've read about deleting modules How do I unload (reload) a Python module? and it seems like there are still dangling refe... | Can I reliably unimport a Python module if I import it in a namespace? | Basically, I have a long running process where I would like to be able to unimport modules and recover memory via the gc. I've read about deleting modules How do I unload (reload) a Python module? and it seems like there are still dangling references that block gc.
However, what if I import and use the module only insi... | [
"If what you really want is to avoid memory leaks, Your best bet is probably to arrange for importing the module once, in the normal way, with sys.modules in it's usual state. No matter how many times the module is later imported, it will not take any more memory, since the import machinery will just keep returnin... | [
3,
3
] | [] | [] | [
"python"
] | stackoverflow_0006182071_python.txt |
Q:
Database Based Job scheduler
I need a job scheduler (a library) that queries a db every 5 minutes and, based on time, triggers events which have expired and rerun on failure.
It should be in Python or PHP.
I researched and came up with Advanced Python Scheduler but it is not appropriate because it only schedules t... | Database Based Job scheduler | I need a job scheduler (a library) that queries a db every 5 minutes and, based on time, triggers events which have expired and rerun on failure.
It should be in Python or PHP.
I researched and came up with Advanced Python Scheduler but it is not appropriate because it only schedules the jobs in its job store. Instead,... | [
"Here's a possible solution\n- a script, either in php or python performing your database tasks\n- a scheduler : Cron for linux, or the windows task scheduler ; where you set the frequency of your jobs.\nI'm using this solution for multiple projects.\nVery easy to set up.\n",
"Celery runs best using RabbitMQ, but... | [
1,
0
] | [] | [] | [
"database",
"php",
"python"
] | stackoverflow_0006184491_database_php_python.txt |
Q:
How do I get the ORIGINAL command line in Python? with spaces, tabs, etc
Possible Duplicate:
Full command line as it was typed
sys.argv is already a parsed array, losing double quotes, double spaces and maybe even tab characters (it all depends on the OS/shell, of course).
How can I access the original string be... | How do I get the ORIGINAL command line in Python? with spaces, tabs, etc |
Possible Duplicate:
Full command line as it was typed
sys.argv is already a parsed array, losing double quotes, double spaces and maybe even tab characters (it all depends on the OS/shell, of course).
How can I access the original string before parsing?
| [
"Shortly, you don't.\nLong: on Unix command line is parsed by the calling program and by the time python starts you already have the command line parsed.\nPS. On Windows it is possible, but I suppose you are looking for a general response.\n"
] | [
4
] | [
"You can't do that explicitly because, this is how a shell passes the arguments to a program.\n",
"The sys.argv is all Python got. The shell processed the filename generation (globs), parameter (variable) expansion, quotes, and word splitting before passing the arguments to the Python process (in Unix; in Windows... | [
-1,
-1
] | [
"command_line",
"python"
] | stackoverflow_0006184925_command_line_python.txt |
Q:
derstroy an instance via "del module_x"
I created my own module "MyServer" which have the function ".connect()".
When I have connected to my server
import MyServer
con = MyServer.connect(...)
and I delete my module ("del MyServer") I expect that "con" is also immediately deleted/destroyed.
But it doesn't work. Ma... | derstroy an instance via "del module_x" | I created my own module "MyServer" which have the function ".connect()".
When I have connected to my server
import MyServer
con = MyServer.connect(...)
and I delete my module ("del MyServer") I expect that "con" is also immediately deleted/destroyed.
But it doesn't work. Maybe the reason for that is the garbage collec... | [
"I assume that you're trying to ensure that the connection to the server is closed? This is not the right way to do that. There are several options:\n\nWrite a MyServer.disconnect_all() method and use that:\ntry: \n con = MyServer.connect()\nfinally:\n MyServer.disconnect_all()\n\nWrite a con.close() method ... | [
2,
0
] | [] | [] | [
"garbage",
"module",
"python"
] | stackoverflow_0006185290_garbage_module_python.txt |
Q:
Python xml parsing problem
could you please explain me the error below, and give me a workaround?
Thanks in advance!
Python 2.4.3 (#1, Apr 14 2011, 20:41:59)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from xml.sax import make_parser
... | Python xml parsing problem | could you please explain me the error below, and give me a workaround?
Thanks in advance!
Python 2.4.3 (#1, Apr 14 2011, 20:41:59)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from xml.sax import make_parser
>>> p = make_parser()
Traceback ... | [
"Problem seems to be with your python version and python library.\nHave a look here\n"
] | [
0
] | [] | [] | [
"parsing",
"python",
"sax",
"xml"
] | stackoverflow_0006185479_parsing_python_sax_xml.txt |
Q:
In a Python program, why can't I cat a file right after writing it?
I tried to cat a file, using Popen(), right after creating and writing to it. It doesn't work. Print p gives two empty tuples ('',''). Why ? I've used rename to ensure an atomic write, as discussed here.
#!/usr/bin/env python
import sys,os,subproc... | In a Python program, why can't I cat a file right after writing it? | I tried to cat a file, using Popen(), right after creating and writing to it. It doesn't work. Print p gives two empty tuples ('',''). Why ? I've used rename to ensure an atomic write, as discussed here.
#!/usr/bin/env python
import sys,os,subprocess
def run(cmd):
try:
p = subprocess.Popen(cmd, stdout=subp... | [
"You did not call close. Use fd.close() (you forgot the parentheses there to make it an actual function call). This could have been prevented by using the with-statement:\nwith open(\"__q\", \"w\") as fd:\n fd.write(t)\n# will automatically be closed here\n\n"
] | [
11
] | [] | [] | [
"python"
] | stackoverflow_0006186304_python.txt |
Q:
3D plotting in Python
What are my options for 3D plotting in Python?
It also must be redistributable.
A:
I assume you're asking for reccomendations, rather than just what modules are available...
Personally, I mostly use Mayavi/Mlab/TVTK. It's essentially a higher level interface to VTK. It's available unde... | 3D plotting in Python | What are my options for 3D plotting in Python?
It also must be redistributable.
| [
"I assume you're asking for reccomendations, rather than just what modules are available... \nPersonally, I mostly use Mayavi/Mlab/TVTK. It's essentially a higher level interface to VTK. It's available under a BSD-style license (If I recall correctly...), so it should be freely re-distributable. If you're visual... | [
6,
3
] | [] | [] | [
"3d",
"plot",
"python"
] | stackoverflow_0003809224_3d_plot_python.txt |
Q:
How to display interactive SVG in a window on Linux?
I really like SVG, it's very nice to draw with it. So far i've made static images using Inkscape. I'd like to make them interactive though.
I did some trials, following tutorials like this one. But i can see a SVG and interact with it in my web browser only. I'd... | How to display interactive SVG in a window on Linux? | I really like SVG, it's very nice to draw with it. So far i've made static images using Inkscape. I'd like to make them interactive though.
I did some trials, following tutorials like this one. But i can see a SVG and interact with it in my web browser only. I'd like to make such things in a window on the desktop.
Ther... | [
"The problem is that the effects require javascript and cascading style-sheets, which basically means complete web rendering engine. So the easiest way is to use one, either webkit or gecko (webkit has probably better support for SVG these days, plus I can't find package of gecko right now).\n"
] | [
2
] | [] | [] | [
"cairo",
"linux",
"opengl",
"python",
"svg"
] | stackoverflow_0006186335_cairo_linux_opengl_python_svg.txt |
Q:
No of Days between two dates in python 2.4
This will work in python 2.6
from datetime import datetime
print (datetime.strptime('2008-12-31', "%Y-%m-%d")- datetime.strptime('2007-04-30',"%Y-%m-%d")).days
But in 2.4 shows following error
AttributeError: type object 'datetime.datetime' has no attribute 'strptime'
... | No of Days between two dates in python 2.4 | This will work in python 2.6
from datetime import datetime
print (datetime.strptime('2008-12-31', "%Y-%m-%d")- datetime.strptime('2007-04-30',"%Y-%m-%d")).days
But in 2.4 shows following error
AttributeError: type object 'datetime.datetime' has no attribute 'strptime'
Thank you for all your Support.
from datetime im... | [
"In Python 2.4 strptime is located in time module:\nfrom time import strptime\n\nSee http://docs.python.org/release/2.4/lib/module-time.html\n"
] | [
7
] | [] | [] | [
"python",
"strptime"
] | stackoverflow_0006186918_python_strptime.txt |
Q:
To log error lines while inserting data into the postgres table from a text file using python
I am new to python and postgres.
I have a code which reads from a csv file and inserts the data into a table.
The code only works when there are error free lines in the file.
But if there are any errors in some of the lin... | To log error lines while inserting data into the postgres table from a text file using python | I am new to python and postgres.
I have a code which reads from a csv file and inserts the data into a table.
The code only works when there are error free lines in the file.
But if there are any errors in some of the lines I want python to ignore those lines and insert the rest of the lines into the table. The lines w... | [
"if you detect errors with an exception raised, try this : \nfor row in reader:\n try:\n statement = \"INSERT INTO abc(col1,col2,col3) VALUES ('%s', '%s','%s')\" % (tuple(row))\n cur.execute(statement)\n except:\n #do the stuff in case of error\n\n"
] | [
0
] | [] | [] | [
"python"
] | stackoverflow_0006186093_python.txt |
Q:
Inheritance in python and constructor calls
The output is:
Class A
Class B
printout
Given code:
class A(object):
def __init__(self):
print "Class A"
def printout(self):
print "printout"
class B(A):
def __init__(self):
print "Class B"
def main():
myA = A()
myB = B()
... | Inheritance in python and constructor calls | The output is:
Class A
Class B
printout
Given code:
class A(object):
def __init__(self):
print "Class A"
def printout(self):
print "printout"
class B(A):
def __init__(self):
print "Class B"
def main():
myA = A()
myB = B()
myB.printout()
if __name__ == '__main__':
... | [
"It's because you did not call the superclass's __init__.\nclass B(A):\n def __init__(self):\n A.__init__(self)\n# ^^^^^^^^^^^^^^^^ this have to be explicitly added\n print \"Class B\"\n\nIn Python 3.x you could use super().__init__() instead of A.__init__(self), but you're still explicitly i... | [
4,
4,
1
] | [] | [] | [
"python"
] | stackoverflow_0006187042_python.txt |
Q:
PyQt: best way to do the trick "start at boot" for my program in Windows
I'm using PyQt to develop an application that in Windows, if set in preferences, should be able to start at boot.
I'm releasing this software with PyInstaller as a single executable file; i don't have a proper "installer".
Which is the best w... | PyQt: best way to do the trick "start at boot" for my program in Windows | I'm using PyQt to develop an application that in Windows, if set in preferences, should be able to start at boot.
I'm releasing this software with PyInstaller as a single executable file; i don't have a proper "installer".
Which is the best way to achieve this? ( = starting at boot)
A possible solution is to add a link... | [
"try this code (it works for me with py2exe):\nimport sys\nfrom PyQt4.QtCore import QSettings\nfrom PyQt4.QtGui import (QApplication, QWidget, QCheckBox, QPushButton,\n QVBoxLayout)\n\nRUN_PATH = \"HKEY_CURRENT_USER\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run\"\n\nclass Main... | [
8,
4
] | [] | [] | [
"pyinstaller",
"pyqt",
"python",
"startup",
"windows"
] | stackoverflow_0006186091_pyinstaller_pyqt_python_startup_windows.txt |
Q:
Is there a way to change the current PyGTK theme on Windows?
I've written a Python app that uses PyGTK. It runs fine on Linux and looks great. It also runs fine on Windows, but it looks absolutely awful. The default GTK theme looks absolutely nothing like the native Windows GUI elements.
Is there anything I can do... | Is there a way to change the current PyGTK theme on Windows? | I've written a Python app that uses PyGTK. It runs fine on Linux and looks great. It also runs fine on Windows, but it looks absolutely awful. The default GTK theme looks absolutely nothing like the native Windows GUI elements.
Is there anything I can do to make my Python app look a little better? Perhaps some function... | [
"I believe you're looking for the rc_parse function, which will let you load a gtkrc file with a theme. Also, see http://faq.pygtk.org/index.py?file=faq21.012.htp&req=show, which shows how to change the GTK theme on windows. Now the problem becomes finding a GTK theme that fits your needs. Some googling turns up ht... | [
2,
1,
1,
1
] | [] | [] | [
"pygtk",
"python",
"themes"
] | stackoverflow_0005768265_pygtk_python_themes.txt |
Q:
How do i split a very long string into a list of shorter strings in python
In my current django project I have a model that stores very long strings (can be 5000-10000 or even more characters per DB entry) and then i need to split them when a user is calling the record (it really need to be in one record in the DB... | How do i split a very long string into a list of shorter strings in python | In my current django project I have a model that stores very long strings (can be 5000-10000 or even more characters per DB entry) and then i need to split them when a user is calling the record (it really need to be in one record in the DB). What i need is it to return a list (queryset? depends if in the "SQL" part or... | [
">>> s = \"This is a very long string with many many many many and many more sentences and there is not one character that i can use to split by, just by number of words\"\n>>> l = s.split()\n>>> n = 5\n>>> [' '.join(l[x:x+n]) for x in xrange(0, len(l), n)]\n['This is a very long',\n 'string with many many many',\n... | [
8,
1
] | [] | [] | [
"django",
"django_queryset",
"python",
"python_2.6"
] | stackoverflow_0006186746_django_django_queryset_python_python_2.6.txt |
Q:
How do you get the name of a calling module as a string using inspect in Python (I keep getting a module object)
I'm trying to get the name of a calling module by using inspect. When I return what should be the module string, I get this:
<module 'mymod.wrapper' from '/usr/local/lib/python2
I've looked at the docs... | How do you get the name of a calling module as a string using inspect in Python (I keep getting a module object) | I'm trying to get the name of a calling module by using inspect. When I return what should be the module string, I get this:
<module 'mymod.wrapper' from '/usr/local/lib/python2
I've looked at the docs and couldn't see anything about what the reason for this may be (I'm tired, so I may have missed it).
Here is the cla... | [
"inspect.getmodule() returns the module object itself, not its name.\nTry replacing\nstr(inspect.getmodule(frm[0]))\n\nwith\ninspect.getmodule(frm[0]).__name__\n\nAlso, bear in mind that inspect.getmodule() can return None.\n",
"You can use the __name__ attribute:\n>>> import xml\n>>> xml.__name__\n'xml'\n>>> m =... | [
4,
1
] | [] | [] | [
"inspect",
"module",
"python"
] | stackoverflow_0006187355_inspect_module_python.txt |
Q:
python save url list in txt file
Hello I am trying to make a python function to save a list of URLs in .txt file
Example: visit http://forum.domain.com/ and save all viewtopic.php?t= word URL in .txt file
http://forum.domain.com/viewtopic.php?t=1333
http://forum.domain.com/viewtopic.php?t=2333
I use this function... | python save url list in txt file | Hello I am trying to make a python function to save a list of URLs in .txt file
Example: visit http://forum.domain.com/ and save all viewtopic.php?t= word URL in .txt file
http://forum.domain.com/viewtopic.php?t=1333
http://forum.domain.com/viewtopic.php?t=2333
I use this function but not save
I am very new in python ... | [
"This is far from trivial and can have quite a few corner cases (I suppose the page you're referring to is a web page)\nTo give you a few pointers, you need to:\n\ndownload the web page : you're already doing it (in data)\nextract the URLs : this is hard, most probably, you'll want to usae an html parser, extract <... | [
4
] | [] | [] | [
"python"
] | stackoverflow_0006187412_python.txt |
Q:
Brightening or darkening images in PIL without built in functions
I'm using PIL for a uni project and we have one task where we have to darken or brighten an image without using any of PIL's functions to do so. The function takes the original filename, the action ('lighten' or 'darken') and the extent (in percent ... | Brightening or darkening images in PIL without built in functions | I'm using PIL for a uni project and we have one task where we have to darken or brighten an image without using any of PIL's functions to do so. The function takes the original filename, the action ('lighten' or 'darken') and the extent (in percent - an int between 0 and 100). Here's what I've come up with so far:
from... | [
"It's an issue of integer division in the (extent/100) expression. To rectify this, you can:\nuse a floating point literal\nextent/100.0\n\nHandy if a term is a literal.\nconvert either the numerator or the denominator into float\nfloat(extent)/a_hundred\n\nIf no term is a literal.\nmake sure that / is floating-poi... | [
2
] | [] | [] | [
"python",
"python_imaging_library"
] | stackoverflow_0006161219_python_python_imaging_library.txt |
Q:
pydev - can someone please explain these errors
I am developing using PyDev in Eclipse. I have put in some comments in my code. I get wavy red lines underneath certain words. The program runs fine and there are no warnings mentioned. So what is the meaning of these wavy lines.
e.g.
#!/usr/bin/python - I get the l... | pydev - can someone please explain these errors | I am developing using PyDev in Eclipse. I have put in some comments in my code. I get wavy red lines underneath certain words. The program runs fine and there are no warnings mentioned. So what is the meaning of these wavy lines.
e.g.
#!/usr/bin/python - I get the line under usr and python
# generated by accessing re... | [
"Neil speaks the truth, except for telling you to turn it off -- spell check in comments is quite helpful -- those who come after will thank you for ensuring they can read your comments without trying to decode random spelling errors.\nThe lines are simply pointing out words your IDE thinks are spelled wrong. I don... | [
3,
0
] | [] | [] | [
"pydev",
"python"
] | stackoverflow_0006187874_pydev_python.txt |
Q:
MySQL bulk update statement in Python
I wonder how I can do a bulk update using MySQL and Python. My requirement is like
for x in range(0,100):
NNN = some calculation
ABC = some calculation
query = update XXX set value = NNN, name = ABC where id = x
con.execute(query)
The problem here is it is executing 100 DB q... | MySQL bulk update statement in Python | I wonder how I can do a bulk update using MySQL and Python. My requirement is like
for x in range(0,100):
NNN = some calculation
ABC = some calculation
query = update XXX set value = NNN, name = ABC where id = x
con.execute(query)
The problem here is it is executing 100 DB queries and makes the update process slow. I... | [
"According to the MySQL update manual, you can do \nUPDATE tableX SET NNN = calculation, \n ABC = (SELECT whatever FROM whatevertable WHERE condition) \n WHERE x >=0 AND x <=100\n\n",
"I agree we can do the calculation on the query. But it is not flexible for change and maintenance. Going for a MYSQL Stored Pro... | [
0,
0
] | [] | [] | [
"bulkinsert",
"mysql",
"python"
] | stackoverflow_0006183232_bulkinsert_mysql_python.txt |
Q:
Http header User-Agent
I am trying to get list of browsers from the User-Agent strings in HTTP header. In many of the strings, the browser info is the second entry in the string, like the following:
(compatible;.MSIE.8.0;.Windows.NT.5.1;.Trident/4.0)
But in some of the strings, there is either no browser info, or... | Http header User-Agent | I am trying to get list of browsers from the User-Agent strings in HTTP header. In many of the strings, the browser info is the second entry in the string, like the following:
(compatible;.MSIE.8.0;.Windows.NT.5.1;.Trident/4.0)
But in some of the strings, there is either no browser info, or the info comes as the 3rd e... | [
"I wrote a User Agent analyzer in PHP some time back, so it might be a bit off date, but hope it helps. I extracted the browser info, operating system and language, but I will only include the browser info here.\nAll major browser names are included in the UA string, but Mozilla is in almoust every one, for Firefox... | [
3
] | [] | [] | [
"python"
] | stackoverflow_0006187834_python.txt |
Q:
pydev - call a function with only self as argument
I am new to PyDev, written scripts using mainly notepad++ and jedit where I never had these issues.
In a module, I have defined a function - get_user_inputs(self). I used the argument self as PyDev would not let me define the function othewise (and apparently it i... | pydev - call a function with only self as argument | I am new to PyDev, written scripts using mainly notepad++ and jedit where I never had these issues.
In a module, I have defined a function - get_user_inputs(self). I used the argument self as PyDev would not let me define the function othewise (and apparently it is the right thing to do).
Now my question is how do I ca... | [
"The argument self is only necessary for class methods. It doesn't make sense for normal functions.\nThat means you either omitted a vital information in your question or there is a bug in PyDev.\n"
] | [
1
] | [] | [] | [
"pydev",
"python"
] | stackoverflow_0006188464_pydev_python.txt |
Q:
Homework - Printing lines of a file between two line numbers
Using Python, how do I print the lines of a text file, given a starting and ending line number?
I have come up with a function, but this doesn't work.
def printPart(src, des, varFile):
returnLines = ""
for curLine in range(src, des):
retu... | Homework - Printing lines of a file between two line numbers | Using Python, how do I print the lines of a text file, given a starting and ending line number?
I have come up with a function, but this doesn't work.
def printPart(src, des, varFile):
returnLines = ""
for curLine in range(src, des):
returnLines += linecache.getline(varFile, curLine)
return returnLi... | [
"Since file objects are iterable in Python, you can apply all the functions from itertools to them. Have a look at itertools.islice(). (Since this is homework, I'll leave the details to you.)\n",
"I would start with the first line in the file, using readline() reading each line counting count += 1. once count g... | [
6,
1
] | [] | [] | [
"file",
"line",
"python"
] | stackoverflow_0006188465_file_line_python.txt |
Q:
Python raw_input in Google App Engine shell
I have a Python program that is run on the command line. It uses raw_input() to read a string from the user's keyboard. I'd like to make the program available on Google App Engine and want to use the App Engine Shell since it has a command prompt.
However, the shell see... | Python raw_input in Google App Engine shell | I have a Python program that is run on the command line. It uses raw_input() to read a string from the user's keyboard. I'd like to make the program available on Google App Engine and want to use the App Engine Shell since it has a command prompt.
However, the shell seems to provide a "fake" prompt, and when I use raw... | [
"The Python source for that application is available on Google Code for you to study, or reuse. raw_input() has probably been disabled for security reasons and always returns EOF.\nThis shell uses an AJAX interface and is simply grabbing the code from the input area and parsing it. See shell.js in the repository:\n... | [
2,
1,
0
] | [] | [] | [
"console_application",
"google_app_engine",
"python"
] | stackoverflow_0006168931_console_application_google_app_engine_python.txt |
Q:
How to use a Python stream object?
I have a function that takes an opened file object file and writes data to it like so:
def Write(self, file):
file.write("Data")
Now I would like to test that function and I thought it would be neat to do that with some kind of stream that is not writing data to a file. I co... | How to use a Python stream object? | I have a function that takes an opened file object file and writes data to it like so:
def Write(self, file):
file.write("Data")
Now I would like to test that function and I thought it would be neat to do that with some kind of stream that is not writing data to a file. I could not find a Python2.7 class that does... | [
"As the documentation of io states:\n\nSince this module has been designed primarily for Python 3.x, you have to be aware that all uses of “bytes” in this document refer to the str type (of which bytes is an alias), and all uses of “text” refer to the unicode type. Furthermore, those two types are not interchangeab... | [
1
] | [] | [] | [
"io",
"python",
"python_2.7",
"stream"
] | stackoverflow_0006189167_io_python_python_2.7_stream.txt |
Q:
How to retrieve a polymorphic model from a single table in django - or how to implement polymorphic behaviour in django
Can I read polymorphic models from a single database table, with their behaviour depending on a (boolean) field of the model?
In one of my models the behaviour is slightly different if the insta... | How to retrieve a polymorphic model from a single table in django - or how to implement polymorphic behaviour in django | Can I read polymorphic models from a single database table, with their behaviour depending on a (boolean) field of the model?
In one of my models the behaviour is slightly different if the instance is 'forward' vs. 'backward' or 'left' vs. 'right'. That leads to a lot of if-clauses and code duplication. So I want to h... | [
"Proxy models:\nclass Foo(models.Model):\n # all model attributes here\n\nclass ForwardFooManager(models.Manager):\n def get_query_set(self, *args, **kwargs):\n qs = super(ForwardFooManager, self).get_query_set(*args, **kwargs)\n return qs.filter(forward=True)\n\nclass ForwardFoo(Foo):\n clas... | [
1
] | [] | [] | [
"django",
"dry",
"python"
] | stackoverflow_0006189029_django_dry_python.txt |
Q:
urllib.py doesn't work with https?
In my python app I try to open a https url, but I get:
File "C:\Python26\lib\urllib.py", line 215, in open_unknown
raise IOError, ('url error', 'unknown url type', type)
IOError: [Errno url error] unknown url type: 'https'
my code:
import urllib
def generate_embedded_doc(do... | urllib.py doesn't work with https? | In my python app I try to open a https url, but I get:
File "C:\Python26\lib\urllib.py", line 215, in open_unknown
raise IOError, ('url error', 'unknown url type', type)
IOError: [Errno url error] unknown url type: 'https'
my code:
import urllib
def generate_embedded_doc(doc_id):
url = "https://docs.google.co... | [
"To have SSL support you need to compile Python with OpenSSL. \nFor example under ubuntu lucid you must install the module libcurl4-openssl-dev then re-build Python.\n",
"urllib and Python 2.6 have SSL support and your code example works fine for me. Probably your Python is built without SSL support? Try to reins... | [
6,
3,
1
] | [] | [] | [
"google_app_engine",
"python",
"url",
"urllib"
] | stackoverflow_0003747037_google_app_engine_python_url_urllib.txt |
Q:
Parallel computing with Python
here is the code of my python script:
import time
for j in range(1,150,1):
for i in range(1,5,1):
x = j + i
print(x)
time.sleep(180)
This script is started out of my Finite Element programm which can be manipulated by python. If i sta... | Parallel computing with Python | here is the code of my python script:
import time
for j in range(1,150,1):
for i in range(1,5,1):
x = j + i
print(x)
time.sleep(180)
This script is started out of my Finite Element programm which can be manipulated by python. If i start this script it starts to run, but... | [
"Do you intend to do something like this:\n#! /usr/bin/env python\n\nimport threading\nimport time\n\nclass Worker (threading.Thread):\n def run (self):\n for j in range(1,150,1):\n for i in range(1,5,1):\n x = j + i\n print \"Worker says: %d\" % x\n tim... | [
2
] | [] | [] | [
"parallel_processing",
"python"
] | stackoverflow_0006190220_parallel_processing_python.txt |
Q:
python problem with MPI (mpi4py), client can not connect
The error I'm getting is:
Traceback (most recent call last):
File "client2.py", line 14, in
port = MPI.Lookup_name(service, info)
File "Comm.pyx", line 1676, in mpi4py.MPI.Lookup_name (src/mpi4py.MPI.c:64562)
mpi4py.MPI.Exception: MPI_ERR_NAME: inva... | python problem with MPI (mpi4py), client can not connect | The error I'm getting is:
Traceback (most recent call last):
File "client2.py", line 14, in
port = MPI.Lookup_name(service, info)
File "Comm.pyx", line 1676, in mpi4py.MPI.Lookup_name (src/mpi4py.MPI.c:64562)
mpi4py.MPI.Exception: MPI_ERR_NAME: invalid name argument
I am trying implement client/server model us... | [
"You want the server to spawn the clients so that they can communicate. Also, your Send/Recv/Bcasts should be send/recv/bcast ; mpi4py supports both Send and send, Recv and recv, etc, but the upper case versions take \"regular\" C/C++/Fortran arguments, and the lowercase ones are more pythonic.\nSo the following ... | [
2,
1
] | [] | [] | [
"client_server",
"mpi",
"network_programming",
"parallel_processing",
"python"
] | stackoverflow_0006178637_client_server_mpi_network_programming_parallel_processing_python.txt |
Q:
Path-independant management of shared C libs inside a Python package
Say I have a package called Foo organized this way:
Foo\
__init__.py
foo.py
bar.py
lib\
libwhatever.so
My module foo.py uses python ctypes to wrap the C-methods contained in my libwhatever.lib, which involves checking the... | Path-independant management of shared C libs inside a Python package | Say I have a package called Foo organized this way:
Foo\
__init__.py
foo.py
bar.py
lib\
libwhatever.so
My module foo.py uses python ctypes to wrap the C-methods contained in my libwhatever.lib, which involves checking the lib is where it should be. 2 questions:
1) How to check in my package tha... | [
"Assuming you're on Linux, I think you'll have to either add that .so file to your library search path, or add the module directory to your path. Have a look at ldconfig. man ldconfig. Once you do either of those, you could use ctypes.util.find_library(). Otherwise you would have to have the full path to the .so f... | [
1
] | [] | [] | [
"ctypes",
"package",
"python"
] | stackoverflow_0006189498_ctypes_package_python.txt |
Q:
How to sort the output of this django template code in alphabetical order?
I have the following code in a django template:
{% for object in object_list %}
{% with game=object.game %}
<a href="{% url game_view game.id game.title|slugify %}" class="img_link alphabeticList">{{game.title}}</a>
{% endwith %}
{% endfo... | How to sort the output of this django template code in alphabetical order? | I have the following code in a django template:
{% for object in object_list %}
{% with game=object.game %}
<a href="{% url game_view game.id game.title|slugify %}" class="img_link alphabeticList">{{game.title}}</a>
{% endwith %}
{% endfor %}
It outputs all the games in the present category, for example:
Armor Dude
... | [
"I hate throwing so much logic into the template. Typically I'd either have the list grouped in the view or have a custom tag to handle the processing for me. I really have no clue if something like this would work, but perhaps some combination of slicing, dicsorting, and regrouping can get you what you need?\nIf n... | [
2
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006190506_django_python.txt |
Q:
how to write python array (data = []) to excel?
I am writing a python program to process .hdf files, I would like to output this data to an excel spreadsheet. I put the data into an array as shown below:
Code:
data = []
for rec in hdfFile[:]:
data.append(rec)
from here I have created a 2D array with 9 colu... | how to write python array (data = []) to excel? | I am writing a python program to process .hdf files, I would like to output this data to an excel spreadsheet. I put the data into an array as shown below:
Code:
data = []
for rec in hdfFile[:]:
data.append(rec)
from here I have created a 2D array with 9 columns and 171 rows.
I am looking for a way to iterate t... | [
"Just like @senderle said, use csv.writer\na = [[1,2,3],[4,5,6],[7,8,9]]\nar = array(a)\n\nimport csv\n\nfl = open('filename.csv', 'w')\n\nwriter = csv.writer(fl)\nwriter.writerow(['label1', 'label2', 'label3']) #if needed\nfor values in ar:\n writer.writerow(values)\n\nfl.close() \n\n",
"A great file type ... | [
6,
4,
2
] | [] | [] | [
"arrays",
"excel_2007",
"python",
"python_2.7",
"xlwt"
] | stackoverflow_0006190612_arrays_excel_2007_python_python_2.7_xlwt.txt |
Q:
Python Dictionary with List as Keys and Tuple as Values
I have a list that I want to use as the keys to a dictionary and a list of tuples with the values. Consider the following:
d = {}
l = ['a', 'b', 'c', 'd', 'e']
t = [(1, 2, 3, 4), (7, 8, 9, 10), (4, 5, 6, 7), (9, 6, 3, 8), (7, 4, 1, 2)]
for i in range(len(l))... | Python Dictionary with List as Keys and Tuple as Values | I have a list that I want to use as the keys to a dictionary and a list of tuples with the values. Consider the following:
d = {}
l = ['a', 'b', 'c', 'd', 'e']
t = [(1, 2, 3, 4), (7, 8, 9, 10), (4, 5, 6, 7), (9, 6, 3, 8), (7, 4, 1, 2)]
for i in range(len(l)):
d[l[i]] = t[i]
The list will consistently be 5 values ... | [
"I did no timings, but probably\nd = dict(zip(l, t))\n\nwill be quite good. For only 5 key-value pairs, I don't think izip() will provide any advantage over zip(). The fact that each tuple has a lot of items does not matter for this operation, since the tuple objects are not copied at any point, neither with your... | [
17,
9
] | [] | [] | [
"dictionary",
"list",
"python",
"tuples"
] | stackoverflow_0006190868_dictionary_list_python_tuples.txt |
Q:
How to initialize classes (not instances) in Python?
I want to merge constraints from the current and inherited classes only once a class is loaded (not per object!).
class Domain(Validatable):
constraints = {...}
To do this I defined a method _initialize_class_not_instance that should be called once for ea... | How to initialize classes (not instances) in Python? | I want to merge constraints from the current and inherited classes only once a class is loaded (not per object!).
class Domain(Validatable):
constraints = {...}
To do this I defined a method _initialize_class_not_instance that should be called once for each class:
class Validatable:
@classmethod
def _in... | [
"Use a metaclass.\nclass MetaClass(type):\n def __init__(cls, name, bases, d):\n type.__init__(cls, name, bases, d)\n cls.foo = 42\n\nclass MyClass(object):\n __metaclass__ = MetaClass\n\nprint MyClass.foo\n\n",
"I ended up with a class decorator and without inheritance. This decorator merges the constrai... | [
17,
2
] | [] | [] | [
"class_method",
"inheritance",
"oop",
"python"
] | stackoverflow_0006183704_class_method_inheritance_oop_python.txt |
Q:
What is the best way to handle connections (e.g. to mysql server using MySQLdb) in python, needed by multiple nested functions?
When accessing a MySQL database on low level using python, I use the MySQLdb module.
I create a connection instance, then a cursor instance then I pass it to every function, that needs th... | What is the best way to handle connections (e.g. to mysql server using MySQLdb) in python, needed by multiple nested functions? | When accessing a MySQL database on low level using python, I use the MySQLdb module.
I create a connection instance, then a cursor instance then I pass it to every function, that needs the cursor.
Sometimes I have many nested function calls, all desiring the mysql_cursor. Would it hurt to initialise the connection as g... | [
"I think that database cursors are scarce resources, so passing them around can limit your scalability and cause management issues (e.g. which method is responsible for closing the connection)?\nI'd recommend pooling connections and keeping them open for the shortest time possible. Check out the connection, perfor... | [
1
] | [] | [] | [
"connection",
"global_variables",
"python"
] | stackoverflow_0006190982_connection_global_variables_python.txt |
Q:
Python Win32, how to save an XLS as a CSV?
I'm loading up a .xlsx with win32com and would like to save the results as a csv when I'm done.
myworkbook.SaveAs('results.csv')
gives me an xlsx file with a csv extension. How do I save as an actual CSV?
A:
I think that if you add the type after the filename, it shoul... | Python Win32, how to save an XLS as a CSV? | I'm loading up a .xlsx with win32com and would like to save the results as a csv when I'm done.
myworkbook.SaveAs('results.csv')
gives me an xlsx file with a csv extension. How do I save as an actual CSV?
| [
"I think that if you add the type after the filename, it should work. (Can't test right now.)\nI think the type for CSV (DOS) is 24.\nmyworkbook.SaveAs('results.csv', 24)\n\n",
"Here are the docs for saveAs:\nhttp://msdn.microsoft.com/en-us/library/bb214129.aspx\nfrom win32com.client import constants as c\nmyWork... | [
4,
3,
3,
1
] | [] | [] | [
"csv",
"excel",
"python",
"win32com"
] | stackoverflow_0006190897_csv_excel_python_win32com.txt |
Q:
python connecting to Oracle using pyodbc sometimes kills python interpreter
Periodically when using pyodbc to create a connection to an oracle database, it kills the interpreter.
import pyodbc
connectString = 'Driver={Microdsoft ODBC for Oracle};Server=<host>:<port>/<db>.<host>;uid=<username>;pwd=<password>'
cnxn ... | python connecting to Oracle using pyodbc sometimes kills python interpreter | Periodically when using pyodbc to create a connection to an oracle database, it kills the interpreter.
import pyodbc
connectString = 'Driver={Microdsoft ODBC for Oracle};Server=<host>:<port>/<db>.<host>;uid=<username>;pwd=<password>'
cnxn = pyodbc.connect(connectString)
Say 1/5 of the time this will just drop me from ... | [
"We could not discover what was exactly causing this problem. Research leads us to think that there may be a problem with Python 2.7.1, PyODBC, and Win 2003 server. \nTo fix this problem we created a jar file that executed the permission check and then had the python script call that file and return the result\n"... | [
1
] | [] | [] | [
"oracle",
"pyodbc",
"python"
] | stackoverflow_0005744977_oracle_pyodbc_python.txt |
Q:
some Numpy functions return ndarray instead of my subclass
I am subclassing Numpy's ndarray class, adding some meta-data and additional methods. I'm trying to follow the instructions in this article and that one. However, some Numpy (or Scipy) functions return the base class "ndarray" instead of my custom subclas... | some Numpy functions return ndarray instead of my subclass | I am subclassing Numpy's ndarray class, adding some meta-data and additional methods. I'm trying to follow the instructions in this article and that one. However, some Numpy (or Scipy) functions return the base class "ndarray" instead of my custom subclass. Other Numpy functions DO return my subclass, and I don't know... | [
"I am not sure about fft, but np.log10 is a ufunc. The following page explains how the output type of a ufunc is determined: http://docs.scipy.org/doc/numpy/reference/ufuncs.html#output-type-determination\nIt wouldn't surprise me if fft always returned an ndarray though (I haven't looked at the source code, but the... | [
1
] | [] | [] | [
"numpy",
"python",
"subclass"
] | stackoverflow_0006190859_numpy_python_subclass.txt |
Q:
Trouble setting up psycopg2 (PostGreSQL/python database)
Hey, I'm pretty new to linux (using Ubuntu 11.04) so bear with me here.
I downloaded psycopg2 2.4.1 from http://linux.softpedia.com/get/Database/Database-APIs/psycopg-6404.shtml
Then I try running...
python setup.py install
..While in the directory but th... | Trouble setting up psycopg2 (PostGreSQL/python database) | Hey, I'm pretty new to linux (using Ubuntu 11.04) so bear with me here.
I downloaded psycopg2 2.4.1 from http://linux.softpedia.com/get/Database/Database-APIs/psycopg-6404.shtml
Then I try running...
python setup.py install
..While in the directory but then it tells me..
Error: pg_config executable not found.
Please... | [
"You probably don't have it installed. I did this:\nme@mine:~ $ pg_config\nThe program 'pg_config' is currently not installed. You can install it by typing:\nsudo apt-get install libpq-dev\nme@mine:~ $ sudo apt-get install libpq-dev\n\nSeemed to work.\nIs there a reason you aren't installing psychopg via apt-get t... | [
2,
2
] | [] | [] | [
"database",
"postgresql",
"psycopg2",
"python",
"ubuntu"
] | stackoverflow_0006179772_database_postgresql_psycopg2_python_ubuntu.txt |
Q:
Line smoothing with Numpy/SciPy
I have a line which should be smoothened by scipy.interpolate.splrep and scipy.interpolate.splev.
line = ((x1, y1), (x2, y2), ... (xn, yn))
tck = interpolate.splrep(x, y)
I need to find more values for my x-coordinate which should be arranged evenly.
newx = numpy.XXX(x)
newy = inte... | Line smoothing with Numpy/SciPy | I have a line which should be smoothened by scipy.interpolate.splrep and scipy.interpolate.splev.
line = ((x1, y1), (x2, y2), ... (xn, yn))
tck = interpolate.splrep(x, y)
I need to find more values for my x-coordinate which should be arranged evenly.
newx = numpy.XXX(x)
newy = interpolate.splev(newx, tck)
e.g. (1, 2,... | [
"You could do something like this:\nimport scipy.interpolate as interp\nz = arange(0,4)\nx = np.array([1,2,4,3])\nf = interp.interp1d(z, x)\nnewx = f(np.linspace(z[0],z[-1],7))\n\nwhich should give you\nIn [40]: print z\n[0 1 2 3]\n\nIn [41]: print x\n[1 2 4 3]\n\nIn [42]: print newx\n[ 1. 1.5 2. 3. 4. 3.5... | [
3
] | [] | [] | [
"numpy",
"python",
"scipy"
] | stackoverflow_0006191627_numpy_python_scipy.txt |
Q:
Make Spinctrl selected when activated in WxPython
I have 4 spinctrls in my app. When I click on them, I want all their
content to be selected instantly. And another thing is, I need to make
them tab traversal. Can you help me with some sort of code to do this
task?
Thanks in advance.
A:
You need to catch EVT... | Make Spinctrl selected when activated in WxPython | I have 4 spinctrls in my app. When I click on them, I want all their
content to be selected instantly. And another thing is, I need to make
them tab traversal. Can you help me with some sort of code to do this
task?
Thanks in advance.
| [
"You need to catch EVT_SPIN or EVT_SPINCTRL and in your handler, you can select all the values by calling each of the control's GetValue method. In the wxPython demo, it seems to support tab traversal. I'm not sure what's going on with yours. Did you try the FloatSpin widget as an alternative?\n"
] | [
2
] | [] | [] | [
"python",
"wxpython"
] | stackoverflow_0006189047_python_wxpython.txt |
Q:
wxpython - Pubsub across files
I am creating a GUI and I am using the MVC pattern for creating it. As doing so, I am using pubsub to manage the events between the backend and the front end.
How can I make pubsub go across files?
My files are behind the link right here. (They are rather long files, my post would be... | wxpython - Pubsub across files | I am creating a GUI and I am using the MVC pattern for creating it. As doing so, I am using pubsub to manage the events between the backend and the front end.
How can I make pubsub go across files?
My files are behind the link right here. (They are rather long files, my post would be huge otherwise.)
For instance:
On ... | [
"This is weird. I use the pubsub that is included in wxPython itself and have never had that issue, but I do it slightly differently: http://www.blog.pythonlibrary.org/2010/06/27/wxpython-and-pubsub-a-simple-tutorial/\nHopefully that will help you out. If not, you can try posting to the official wxPython mailing li... | [
0
] | [] | [] | [
"python",
"wxpython"
] | stackoverflow_0006183383_python_wxpython.txt |
Q:
References in Python
I have a multicasting network that needs to continuously send data to all other users. This data will be changing constantly so I do not want the programmer to have to deal with the sending of packets to users. Because of this, I am trying to find out how I can make a reference to any object o... | References in Python | I have a multicasting network that needs to continuously send data to all other users. This data will be changing constantly so I do not want the programmer to have to deal with the sending of packets to users. Because of this, I am trying to find out how I can make a reference to any object or variable in Python (I am... | [
"In python everything is a reference, but strings are not mutable. So test is holding a reference to \"test\". If you assign \"this should change\" to test you just change it to another reference. But your clients still have the reference to \"test\". Or shorter: It does not work that way in python! ;-)\nA solution... | [
5,
4
] | [] | [] | [
"pointers",
"python",
"reference"
] | stackoverflow_0006191966_pointers_python_reference.txt |
Q:
Notification as a cron job
I coded a python application which was running OK as a cron job. Later I added some libraries (e.g. pynotify and other *) because I wanted to be notified with the message describing what is happening, but it seems that cron can't run such an application.
Do you know some alternative how ... | Notification as a cron job | I coded a python application which was running OK as a cron job. Later I added some libraries (e.g. pynotify and other *) because I wanted to be notified with the message describing what is happening, but it seems that cron can't run such an application.
Do you know some alternative how to run this application every fi... | [
"If your python script runs fine by itself and only fails in cron, then most likely the paths to the libraries are not set in cron. Here's an example from one of my cronjobs where I add the path to cron before executing the file\n00 12 * * * LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib && export LD_LIBRARY_PATH ... | [
1,
1,
0,
0
] | [] | [] | [
"cron",
"python"
] | stackoverflow_0006191624_cron_python.txt |
Q:
Excel comparing two csv files and showing the difference
I'm looking to compare two big sets of csv files and/or a csv file and a .txt file. I "think" the .txt file may need to be converted to a csv file just for simplicity sake but that may or may not be needed. I either want to use excel, c++, or python. I need ... | Excel comparing two csv files and showing the difference | I'm looking to compare two big sets of csv files and/or a csv file and a .txt file. I "think" the .txt file may need to be converted to a csv file just for simplicity sake but that may or may not be needed. I either want to use excel, c++, or python. I need to compare one "accepted" value list to a list that is measure... | [
"You can use ADO (ODBC/JET/OLEDB Text Driver) to treat 'decent' .txt/.csv/.tab/.flr files as tables in a SQL Database from every COM-enabled language. Then the comparisons could be done using the power of SQL (DISTINCT, GROUP, (LEFT) JOINS, ...).\nAdded with regard to your comment:\nIt's your problem and I don't wa... | [
2,
1
] | [] | [] | [
"c++",
"compare",
"excel",
"python"
] | stackoverflow_0006191708_c++_compare_excel_python.txt |
Q:
Python: Is passing a function more information a bad thing?
I have two or more threads(created by subclassing threading.Thread) running in parallel and they often communicate with each other. They communicate by calling each others methods. As I have been doing it, I have each thread pass itself as an argument, so... | Python: Is passing a function more information a bad thing? | I have two or more threads(created by subclassing threading.Thread) running in parallel and they often communicate with each other. They communicate by calling each others methods. As I have been doing it, I have each thread pass itself as an argument, so that all of that classes attributes are available right away.
T... | [
"It's not less efficient, but it can increase coupling -- that is, it might lead you to make your function more dependent on the details of the overall structure. This makes code more brittle -- you might have to make more changes throughout the code to account for a change in the structure.\n",
"Python passes r... | [
6,
1
] | [] | [] | [
"multithreading",
"python"
] | stackoverflow_0006191651_multithreading_python.txt |
Q:
Need help with KeyError when building epydoc files for project
I have a pylons project with an extensive set of functional tests that I want my manual QA's to be able to read from time to time, so I'm using epydoc to build out the html pydocs on the functional test modules.
It seems to be working fine. It generat... | Need help with KeyError when building epydoc files for project | I have a pylons project with an extensive set of functional tests that I want my manual QA's to be able to read from time to time, so I'm using epydoc to build out the html pydocs on the functional test modules.
It seems to be working fine. It generates the docs, and I can navigate through them without any apparent pr... | [
"What I ended up doing, finally, was just including --parse-only on the epydoc command, to force it not to import anything (thus working around the problem of unlocatable imports, but not really answering why it was happening at all). Not a perfect solution, but it satisfied the requirements...\n"
] | [
0
] | [] | [] | [
"epydoc",
"pylons",
"python"
] | stackoverflow_0004055388_epydoc_pylons_python.txt |
Q:
What is the closest thing to Apache Hadoop in other languages?
Specifically any Open Source implementations at any degree of usefulness in the following languages:
1) C++
2) Python
3) Ruby
4) C#
A:
The german wikipedia has some software examples for each language. I'm translating:
Apache Hadoop MapReduce (nativ... | What is the closest thing to Apache Hadoop in other languages? | Specifically any Open Source implementations at any degree of usefulness in the following languages:
1) C++
2) Python
3) Ruby
4) C#
| [
"The german wikipedia has some software examples for each language. I'm translating:\n\nApache Hadoop MapReduce (natively Java, pipes to C++, Python, etc.)\ndisco Open Source Project (Python and Erlang) by Nokia Research Center\nGreenplum MapReduce by Greenplum (not sure, seems to be C++ though, but with a SQL laye... | [
5,
2
] | [] | [] | [
"c++",
"distributed_computing",
"hadoop",
"mapreduce",
"python"
] | stackoverflow_0006084954_c++_distributed_computing_hadoop_mapreduce_python.txt |
Q:
What's the advantage or benefit of Slug field in Django?
What's the benefit of the slug field? Does it make the url more searching engine friendly? If it does, how? Isn't a meaningful title of the page searching engine friendly enough?
A:
The slug provides a human-friendly url fragment for the page. This is ofte... | What's the advantage or benefit of Slug field in Django? | What's the benefit of the slug field? Does it make the url more searching engine friendly? If it does, how? Isn't a meaningful title of the page searching engine friendly enough?
| [
"The slug provides a human-friendly url fragment for the page. This is often useful when people are deciding whether or not to click a link. There's one in the url of this page, for example:\nhttp://stackoverflow.com/questions/6192655/whats-the-advantage-or-benefit-of-slug-field-in-django\nYou can actually get to t... | [
8
] | [] | [] | [
"django",
"python",
"slug"
] | stackoverflow_0006192655_django_python_slug.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.