I have a MacBook Pro with Snow Leopard, and the Python 2.6 distribution that comes standard. Numpy does not work properly on it. Loadtxt gives errors of the filename being too long, and getfromtxt does not work at all (no object in module error). So then I tried downloading the py26-numpy port on MacPorts. Of course when I use python...
I built a wiki using Google App engine and the Data APIs. The wiki pages are stored as Google Base 'Reference Articles.' I want users to be able to view, edit, and delete the items, so when a request is made to the server, client login uses my username and password, and retrieves or edits the data on the user's behalf. The login code:...
I've been playing mostly with PHP and Python.
I've been reading about Interfaces in OO programming and can't see an advantage in using it.
Multiple objects can implement the same interface, but multiple inheritance doesn't provide this as well?
Why do I need to create an Interface "with no implementation" - mainly a "contract" - if I ...
Hello,
I am relatively new to Python having used C# for many years and I'm hoping someone can help me with this question. I have a module called actuators.py that contains a number of classes for defining properties and methods for the servos I use in a robot project. In another module called robot.py, I instantiate my actuators like ...
I'm having a hard time getting some sql in python to correctly go through MySQLdb. It's pythons string formatting that is killing me.
My sql statement is using the LIKE keyword with wildcards. I've tried a number of different things in Python. The problem is once I get one of them working, there's a line of code in MySQLdb that burps on...
With PostgreSQL, one of my tables has an 'interval' column, values of which I would like to extract as something I can manipulate (datetime.timedelta?); however I am using PyGreSQL which seems to be returning intervals as strings, which is less than helpful.
Where should I be looking to either parse the interval or make PyGreSQL return ...
So I'm making a Pascal's triangle and I can't figure out why this code isn't working. It prints out something like this
[]
[1]
[1, 2]
[1, 3, 3]
[1, 4, 6, 4]
[1, 5, 10, 10, 5]
[1, 6, 15, 20, 15, 6]
[1, 7, 21, 35, 35, 21, 7]
[1, 8, 28, 56, 70, 56, 28, 8]
[1, 9, 36, 84, 126, 126, 84, 36, 9]
Which is almost correct, however it seems that ...
Hi,
I'm porting some geolocation java code from http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates#Java (shown below) to python. It can be initialized using two functions (fromDegrees or fromRadians). I thought I could do something like
class geoLocation:
_radLat = 0
_radLong = 0
_degLat = 0
_degLong = 0
...
Hi expert Pythonists out there, I am starting to use cProfile so as to have a more detailed timing information on my program. However, it's quite disturbing to me that there's a significant overhead. Any idea why cProfile reported 7 seconds while time module only reported 2 seconds in the code below?
# a simple function
def f(a, b):
c...
I want to be able to use wildcards in my django queries used for searching. However as the documentation says:
Entry.objects.filter(headline__contains='%')
Will result in SQL that looks something like this:
SELECT ... WHERE headline LIKE '%\%%';
How do I tell django to not escape % and _ in a query. Or is there another way to...
I am using pythons built-in sqlite3 module to access a database. My query executes a join between a table of 150000 entries and a table of 40000 entries, the result contains about 150000 entries again. If I execute the query in the SQLite Manager it takes a few seconds, but if I execute the same query from python, it has not finished aft...
I'm processing 100k domain names into a CSV based on results taken from Siteadvisor using urllib (not the best method, I know). However, my current script creates too many threads and Python runs into errors. Is there a way I can "chunk" this script to do X number of domains at a time (say, 10-20) to prevent these errors? Thanks in advan...
This is the type of dropdown window I would like. It has columns, with different types of data in each. I tried just using tab delimiting, but it made it look sloppy. How could I get a dropdown / combobox element like this using PyQt4? (Ignore the black box, I just wanted to hide my system files).
...
I'm trying to take an image file, do some stuff to it and save the changes back to the original file. The problem I'm having is in overwriting the original image; there doesn't seem to be a reliable way to release the handle on filename.
I need this content to be saved back to the same file because external processes depend on that fil...
I have a similar question to this one: It's very easy in py-amqp/flopsy to say "I'm going to wait forever, and I want this callback to be called whenever a message comes in," but I can't find any way of saying "OK, I got the message I want now stop waiting." (Maybe a GOTO? Just kidding...) Is there an elegant way of doing this?
...
I'm trying to add a feature in python that copies the entire contents of two text widgets. How would one go about that?
Pseudo Code:
text1.SelectAll()
C1 = text1.get(Copy)
text2.SelectAll()
C2 = text2.get(Copy)
Paste('Widget 1:\n\n' + C1 + 'Widget 2:\n\n' + C2 )
...
I need to make both a Control-Z and Shift-Control-Z function in Python. Anyone have any Idea?
Also I need to select the contents of an entire text widget, anyone know how to go about that?
...
Imagine this:
def method(self, alpha, beta, gamma, delta, epsilon, zeta, eta, theta, iota, kappa):
pass
The line overpass the 79 characters, so, what's the pythonic way to multiline it?
...
Is there a way to get one value from a tuple in python using expressions?
def Tup():
return (3,"hello")
i = 5 + Tup(); ## I want to add just the three
I know I can do this:
(j,_) = Tup()
i = 5 + j
But that would add a few dozen lines to my function, doubling its length.
...
Started my first Python pet project using PyGTK. Though it is a really powerful GUI toolkit and looks excellent, I have some pet peeves. So I thought about transitioning to something else, as it's not yet too extensive. Had a look around on SO and python documentation, but didn't get a good overview.
What's nice about PyGTK:
Glade fil...