Here is a twofold question, with a theoretical part, and a practical one:
When subclassing dict:
class ImageDB(dict):
def __init__(self, directory):
dict.__init__(self) # Necessary??
...
should dict.__init__(self) be called, just as a "safety" measure (e.g., in case there are some non-trivial implementation deta...
Hi I'm planning on building a site with social networking features. Which Python framework do you think is more appropriate or you would suggest over the other, CherryPy or Pylons?
...
var1 = 'abc'
var2 = 'xyz'
print('literal' + var1 + var2) # literalabcxyz
print('literal', var1, var2) # literal abc xyz
... except for automatic spaces with ',' whats the difference between the two? Which to use normally, also which is the fastest?
Thanks
...
I could not understand the ipython library. This url provide the common feature but I could not core-relate it. http://ipython.scipy.org/doc/rel-0.9.1/html/interactive/tutorial.html
How to I use IPython to improve my day to day python application experience?
...
I have created a margin in a gtk.TextView widget. Now I want to make sure that the default event handler for mouse click, which is moving the text cursor to the clicked position, works only when clicked to the right of the margin.
Is this possible?
...
InstaMapper is a GPS tracking service that updates the device's position more frequently when the device is being tracked live on the InstaMapper webpage. I'd like to have this happen all the time so I thought I'd write a python script to login to my account and access the page periodically.
import urllib2, urllib, cookielib
cj = cook...
I am trying to emboss an image using PIL.
PIL provides a basic way to emboss an image ( using ImageFilter.EMBOSS).
In image editing packages like GIMP, you can vary parameters like Azimuth, depth and elevation in this embossed image.
Does anyone know how to do this with PIL? At the very least I want to adjust the "depth" of the em...
When load matrices from mat file in python using scipy.io, it makes dictionary where key is name of matrix,and value is 2D array of that matrix.
How can i access elements in this array?
...
If you were looking to hire a web developer who would primarily be working with TurboGears/Python - what sort of questions should you ask them?
...
Hello, I like to organize a lot of information from literature reviews in "tables" (information not unlike product comparisons, but for scientific research), but often the information I enter can contain lines or paragraphs of text and becomes unwieldy in a spreadsheet. I've heard SQL relational tables are often used for this purpose; fo...
I have a process that builds a list from a database table and runs real time. Every now and then new data gets added to the database table. Querying data from the table every now and then is cumbersome, and time consuming, and this need to be as real time as possible.What is the right way to approach the problem?
The process is as follo...
Has anyone done a Python CLI to edit Firefox bookmarks ?
My worldview is that of Unix file trees; I want
find /re/ in given or all fields in given or all subtrees
cd
ls with context
mv this ../there/
Whether it uses bookamrks.html or places.sqlite is secondary -- whatever's easier.
Clarification added: I'd be happy to quit Firefox, e...
I decided, that I learn a bit of Python. The first introduction says that it uses indentation to group statements. While the best habit is clearly to use just one of these what happens if I interchange them? How many spaces will be considered equal to one tab? Or will it fail to work at all if tabs and spaces are mixed?
...
I am trying to use the invoke method of a ttk.Button, as shown at TkDocs (look at "The Command Callback"), but I keep getting this error:
AttributeError: 'NoneType' object has no attribute 'invoke'
So, I tried this in the Interactive Shell:
ActivePython 3.1.1.2 (ActiveState Software Inc.) based on
Python 3.1.1 (r311:74480,...
I'm creating a Trivia app, and need some help designing my model relationships. This question may get fairly complicated, but I'll try to be concise.
Trivia questions will all be part of a particular category. Categories may be a category within another category. If a trivia question is created/removed, I need to make sure that I als...
I need to sort a list of tuples by first item in descending order, and then by second item in ascending order.
To do this, I have implemented the following function, but I think it could be faster.
>>> compare = lambda a, b: -cmp(b[1], a[1]) if b[0] == a[0] else cmp(b[0], a[0])
>>> sorted([(0, 2), (0, 1), (1, 0), (1, 2)], cmp=compare)
...
Currently I have a website on the Google App Engine written in Google's webapp framework. What I want to know is what are the benefits of converting my app to run with django? And what are the downsides? Also how did you guys code your GAE apps? Did you use webapp or django? Or did you go an entirely different route and use the Java api?...
All diff tools I've found are just comparing line by line instead of char by char. Is there any library that gives details on single line strings? Maybe also a percentage difference, though I guess there are separate functions for that?
...
I have a simple python application where my directory structure is as follows:
project/
main.py
config.py
plugins/
plugin1
plugin2
...
Config.py only loads configuration files, it does not contain any configuration info in itself.
I now want to distribute this program, and I thought I'd use setuptools to do it. The file users ar...
Today I've switched to GNOME (from XFCE) and found some of the cool stuff missing and I would like to (try to) do them on my own. I tried to find information on how to develop Gnome applets (items you place within the panel) and most likely in Python, but it's not a hard limitation.
I found the article 'Gnome applets with Python', but i...