From what I understand, the parent attribute of a db.Model (typically defined/passed in the constructor call) allows you to define hierarchies in your data models. As a result, this increases the size of the entity group. However, it's not very clear to me why we would want to do that. Is this strictly for ACID compliance? I would like t...
What is the purpose of the colon before a block in Python?
Example:
if n == 0:
print "The end"
...
Hi
I am trying to develop a script to pull some data from a large number of html tables. One problem is that the number of rows that contain the information to create the column headings is indeterminate. I have discovered that the last row of the set of header rows has the attribute border-bottom for each cell with a value. Thus I de...
I still haven't got my head around decorators in Python.
I've already started using a lot of closures to do things like customize functions and classes in my coding.
Eg.
class Node :
def __init__(self,val,children) :
self.val = val
self.children = children
def makeRunner(f) :
def run(node) :
f(node)
...
I had a problem a week or so ago. Since I think the solution was cool I am sharing it here while I am waiting for an answer to the question I posted earlier. I need to know the relative position for the column headings in a table so I know how to match the column heading up with the data in the rows below. I found some of my tables ha...
While working on a C++ project, I was looking for a third party library for something that is not my core business. I found a really good library, doing exactly what's needed, but it is written in Python. I decided to experiment with embedding Python code in C++, using the Boost.Python library.
The C++ code looks something like this:
#...
I've been playing with mod_python in apache2 which seems to work differently than python does in general - there's a bit different syntax and things you need to do. It's not very well documented and after a few days of playing with it, I'm really not seeing the point of mod_python at all, especially when things like php are so well docum...
I am working on a desktop application in PyGTK and seem to be bumping up against some limitations of my file organization. Thus far I've structured my project this way:
application.py - holds the primary application class (most functional routines)
gui.py - holds a loosely coupled GTK gui implementation. Handles signal callbacks, etc...
I want to have a function that will return the reverse of a list that it is given -- using recursion. How can I do that?
...
Hello all,
The point of this question is to create the shortest not abusively slow Sudoku solver. This is defined as: don't recurse when there are spots on the board which can only possibly be one digit.
Here is the shortest I have so far in python:
r=range(81)
s=range(1,10)
def R(A):
bzt={}
for i in r:
if A[i]!=0: con...
Most python frameworks will have a development webserver of some kind that will have a warning that it isn't for use as production servers. How much different do they tend to be from their production equivalents?
I haven't quite decided which framework to go with, much less what production server to use, so it's kinda difficult for me ...
I have a table called logs which has a datetime field.
I want to select the date and count of rows based on a particular date format.
How do I do this using SQLAlchemy?
...
Which types of objects fall into the domain of "subscriptable"?
...
On Mac OS X I can’t enter a pound sterling sign (£) into the Python interactive shell.
* Mac OS X 10.5.5
* Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
* European keyboard (£ is shift-3)
When I type shift-3 in the Python interactive shell, I seem to invoke the previous word function, i.e. the cursor will move to the start of the l...
Currently, Im only proficient in php, and would like to learn something new. The only thing I can think of, is the obvious C# and .NET, and I just wanted to know if there are any alternatives.
Can it be done in Python?
...
I would like to know how long it's been since the user last hit a key or moved the mouse - not just in my application, but on the whole "computer" (i.e. display), in order to guess whether they're still at the computer and able to observe notifications that pop up on the screen.
I'd like to do this purely from (Py)GTK+, but I am amenabl...
I've been a Ruby on Rails developer for a few years now and until Ruby on Rails have never been exposed to the conventions and design patterns that I've now grown to love and appreciate.
I would like to start getting into building desktop applications with Python in a Gnome environment. What would be a beneficial resource to get starte...
I've written a setup.py script for py2exe, generated an executable for my python GUI application and I have a whole bunch of files in the dist directory, including the app, w9xopen.exe and MSVCR71.dll. When I try to run the application, I get an error message that just says "see the logfile for details". The only problem is, the log file...
Hi,
What's the easiest way of me converting the simpler regex format that most users are used to into the correct re python regex string?
As an example, I need to convert this:
string = "*abc+de?"
to this:
string = ".*abc.+de.?"
Of course I could loop through the string and build up another string character by character, but that...
i want to write code for unit test to test my application code. I have different methods and now want to test these methods one by one in python script.
but i do not how to i write. can any one give me example of small code for unit testing in python.
i am thankful
...