How do I translate something like this into SQLAlchemy?
select x - y as difference...
I know how to do:
x.label('foo')
...but I'm not sure where to put the ".label()" method call below:
select ([table.c.x - table.c.y], ...
...
How do I translate something like this into SQLAlchemy?
SELECT (a * b) - (x + y) / z AS result
FROM table
ORDER BY result
...
I've got several function where I need to do a one-to-many join, using count(), group_by, and order_by. I'm using the sqlalchemy.select function to produce a query that will return me a set of id's, which I then iterate over to do an ORM select on the individual records. What I'm wondering is if there is a way to do what I need using t...
Hi,
I've been programming for many years, and recently started learning Python. The following code works as expected in both python 2.5 and 3.0 (on OS X if that matters):
a, b, c = (1, 2, 3)
print(a, b, c)
def test():
print(a)
print(b)
print(c) # (A)
#c+=1 # (B)
test()
However, when I uncomment line (B), I ...
I've had some experience with Pygame, but there seems to be a lot of buzz around Pyglet these days.
How do these two libraries compare? What would be the advantage of using one over the other, both in features and ease of use?
Finally, would you say that one is more Pythonic than the other?
...
I'm trying to write my first little plugin for Trac and am kind of lost as to what the API exactly is. For example, exactly which fields are offered for "ticket" objects, among many other things.
Does anyone know of a good place to look for Trac API documentation? Can't find anything on the web site but maybe I'm just looking wrong...
...
Has anyone tried the NetBeans 6.5 Python IDE?
What are your opinions? Is it better/worse than PyDev? Do you like it? How does it integrate with source control tools (especially Mercurial)?
...
I'm using Python 2.5. The DLL I imported is created using the CLR.
The DLL function is returning a string. I'm trying to apply "partition" attribute to it. I'm not able to do it. Even the partition is not working.
I think "all strings returned from CLR are returned as Unicode". Help me please. It's very urgent.
Thank you Jetxee for your...
I have a function that expects real numbers (either integers or floats) as its input, and I'm trying to validate this input before doing mathematical operations on it.
My first instinct is to cast inputs as floats from within a try-except block.
try:
myinput = float(input)
except:
raise ValueError("input is not a well-formed numb...
I want to override access to one variable in a class, but return all others normally. How do I accomplish this with __getattribute__?
I tried the following (which should also illustrate what I'm trying to do) but I get a recursion error:
class D(object):
def __init__(self):
self.test=20
self.test2=21
def __geta...
I've heard from reliable sources that Python is a great language that every programmer can learn, but I've heard so much good about it that I'm clearly not getting the whole picture. I'm considering spending more time to learn it, and I've heard more than I need about its virtues (to the point where I've started recommending it having ne...
It seems to be ignored inside a list, for example:
for x in range(5):
list += [x, 1
,2,3,
4,5]
...
What is the difference between abstract class and interface in Python?
...
I'm aware that Python 3 fixes a lot of UTF issues, I am not however able to use Python 3, I am using 2.5.1
I'm trying to regex a document but the document has UTF hyphens in it – rather than -. Python can't match these and if I put them in the regex it throws a wobbly.
How can I force Python to use a UTF string or in some way match a c...
I'm looking for a python project to use as example to learning python.
The project should have these features:
is almost fully unit tested
use consistently the code convention recommended by PEP 8
it's elements are almost fully documented
Extra point features are:
building, assembling, and release automation
EDIT:
The Question...
I am using xmlrpclib.ServerProxy to make RPC calls to a remote server. If there is not a network connection to the server it takes the default 10 seconds to return a socket.gaierror to my program.
This is annoying when doing development without a network connection, or if the remote server is down. Is there a way to update the timeout ...
How would I only allow users authenticated via Python code to access certain files on the server?
For instance, say I have /static/book.txt which I want to protect. When a user accesses /some/path/that/validates/him, a Python script deems him worthy of accessing /static/book.txt and redirects him to that path.
How would I stop users wh...
I have a large set of data (a data cube of 250,000 X 1,000 doubles, about a 4 gig file) and I want to manipulate it using a previous set of OOP classes I have written in Python. Currently the data set is already so large that to read into my machine memory I have to at least split it in half so computing overhead is a concern. My OOP c...
How do i connect to a MySQL database using a python program.
...
Is there a way to find the application name of the current active window at a given time on Mac OS X using Python?
...