A side effect of this question is that I was lead to this post, which states:
Whenever isinstance is used, control flow forks; one type of object goes down one code path, and other types of object go down the other --- even if they implement the same interface!
and suggests that this is a bad thing.
However, I've used code like th...
When I have a cursor, I know I can safely execute a query as follows:
cur.execute("SELECT * FROM foo WHERE foo.bar = %s", (important_variable,))
Is there any way to just get the string safely without executing the query? For example, if important_variable is a string, like "foo 'bar' \"baz", I'd want the appropriately escaped one:
"S...
Hi there,
I have a c99 function that uses openmp, which works as expected. I also wrote a ptyhon interface using ctypes which causes the problem. Ctypes/python can not find the library for openmp. Here is the error massage:
File "foo.py", line 2, in <module>
foobar=cdll.LoadLibrary("./libfoo.so")
File "/usr/lib/python2.6/ctypes/_...
Hello,
I have a directory with lots of .py files (say test_1.py, test_2.py and so on) Each one of them is written properly to be used with nose. So when I run nosetests script, it finds all the tests in all the .py files and executes them.
I now want to parallelize them so that all the tests in all .py files are treated as being parall...
I have been using django ORM, it's nice and very easy, but this time I'm doing a desktop app and I found SQLAlchemy, but I'm not sure to use it with Elixir. What do you think? is it really useful?
...
Thanks for the help guys!
...
Here are four simple invocations of assert:
>>> assert 1==2
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AssertionError
>>> assert 1==2, "hi"
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AssertionError: hi
>>> assert(1==2)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
Asser...
I'm trying to install Python-Gammu on a mac running Snow Leopard. I successfully configured gammu with cmake and GCC 4, but am getting this error on install. It seems to indicate an improperly configured gcc, but i'm not sure what can be done about this.
Has anyone else run into similar problems with GCC on the mac?
[ 90%] Built targ...
We trying to build application that should use Comet (AJAX Push) to send notifications to individual users. Most notifications will have a fairly low timeout.
As we are running RabbitMQ, it would be easiest to send messages through AMQP. I am wondering what the best way to address individual users is, so that both the Comet server and t...
Whenever looking at API libraries for Python, there seems to be about half of them simply using:
response = urllib2.urlopen('https://www.example.com/api', data)
and about half using:
connection = httplib.HTTPSConnection('www.example.com/api')
# ... rest omitted for simplicity
I tend to think the second version is "cooler" (I'm bias...
I'm looking for a Python plugin that would calculate the realized P&L for a number of stock transactions using the FIFO method.
For example, assume we have the following three MSFT trades :
+75 MSFT 25.10
+50 MSFT 25.12
-100 MSFT 25.22
The sell of 100 shares at 25.22 would fully net against the buy of 75 at 25.10 and partially net ...
I have three pieces of code that i'm working with at the moment:
A closed source application (Main.exe)
A closed source VB COM object implemented as a dll (comobj.dll)
Code that I am developing in Python
comobj.dll hosts a COM object (lets say, 'MainInteract') that I would like to use from Python. I can already use this object perfec...
I'm running a number of python scripts on a linux cluster, and the output from one job is generally the input to another script, potentially run on another node. I find that there is some not insignificant lag before python notices files that have been created on other nodes -- os.path.exists() returns false and open() fails as well. I c...
Hi,
Below is script that I found on forum, and it is almost exactly what I need except I need to read like 30 different url's and print them all together.I have tried few options but script just breaks. How can I merge all 30's urls, parse, and than print them out.
If you can help me I would be very greatful, ty.
import sys
import str...
I've been trying to develop an automated test case solution using Selenium RC and Python and after lengthy testing I've hit a pretty hard block in the road, so to speak.
I have three files: unit.py, case1.py, and case1m.py
unit.py configures instances of case1m.py with a browser and a port, then runs the test by sending the case1m ins...
Hi,
i already have a post which is quite similiar, but i am getting more and more frustrated because it seems nothing is wrong with my network setup. Other software can be seen from the outside (netcat listen servers etc.) but not my scripts.. How can this be??
Note: It works on LAN but not over the internet.
Server:
import socket
ho...
After doing web development (php/js) for the last few years i thought it is about time to also have a look at something different. I thought it may be always good to have look of different areas in programming to understand some different approaches better, so i now want to have look at GUI development.
As programming language i did ch...
I have a django (v1.1.1) on a server running Python 2.4. On my localhost/development computer the site works perfect. When I uploaded the files to the production server, it seemed to work fine, but after a page refresh I am receiving random TemplateDoesNotExist errors.
In the trace report I looked at the TEMPLATE_DIRS variable to make s...
How can I add letter to path?
For example if i have a path like 'c:\example2\media\uploads\test5.txt' (stored in a variable), but I need something like r'c:\example2\media\uploads\test5.txt', how can I add letter `r?
Because the function open() does not want to open the first path. When I try add path to function open() it gives me an ...
I am trying to implement a small, very flexible REST web service. I've done it in the past, but I didn't like the approach and I still don't like. How can one parse the query variables in a more elegant way ? Doing things like:
if query_variable in uri: do_things_based_on_query_variable
look fairly ugly to me, especially when all of th...