I've got a C++ windows app that is trying to load a PyQt4 object, similar to the way PyQt4 does it for providing python widgets in the QtDesigner. The app loads other Python modules just fine, but fails to load PyQt4.QtGui. Also, with straight Python, I can load PyQt4.QtGui just fine. The debug output when it attempts that is:
'devenv.e...
In our Pylons based web-app, we're creating a class that essentially provides some logging functionality. We need a new instance of this class for each http request that comes in, but only one per request.
What is the proper way to go about this? Should we just create the object in middleware and store in in request.environ? Is there a ...
Hello I have test's using unittest. I have a test suite and I am trying to pass variables through into each of the tests. The below code shows the test suite used.
class suite():
def suite(self): #Function stores all the modules to be tested
modules_to_test = ('testmodule1', 'testmodule2')
alltests = unittest.TestS...
Hello,
I have a script that does various things and access paramenters using sys.argv but when the script gets to the unittest part of the code it says there is no module for this. The script that I have is:
class MyScript():
def __init__(self):
self.value = sys.argv[1]
def hello(self):
print self.value
...
Q: Do we have anything functionally equivalent in Python to the Ruby version manager 'rvm'?
(RVM lets you easily switch completely between different versions of the ruby interpreter and different sets of gems (modules). Everything concerning download-build-install-switch of interpreter(-s) and gems gets taken care of by invoking rvm...
Is there any way to make pip play well with multiple versions of Python? For example, I want to use pip to explicitly install things to either my site 2.5 installation or my site 2.6 installation.
For example, with easy_install, I use easy_install-2.{5,6}.
And, yes — I know about virtualenv, and no — it's not a solution to this particu...
Hey,
My current project requires extensive use of bit fields. I found a simple, functional recipe for bit a field class but it was lacking a few features I needed, so I decided to extend it. I've just got to implementing __str__ and __repr__ and I want to make sure I'm following convention.
__str__ is supposed to be informal and conci...
Why can Lisp with all its dynamic features be statically compiled but Python cannot (without losing all its dynamic features)?
...
Hi!
I try to upload file, how can i check if file is upload
when i send empty input witch file upload i get
AttributeError: 'unicode' object has no attribute 'filename'
How can i check added file?
...
I find myself adding debugging "print" statements quite often -- stuff like this:
print("a_variable_name: %s" % a_variable_name)
How do you all do that? Am I being neurotic in trying to find a way to optimize this? I may be working on a function and put in a half-dozen or so of those lines, figure out why it's not working, and then cu...
I've got a piece of software which consists of several python sources and a couple of c++ libraries. I'd like to pack them in a executable single file, just like java does with .jar files. Is there a way to do that?
...
Is there a way to sign values with a PEM formatted private key in Google App Engine (Python)?
For example in PHP it could be achieved like this:
$key = openssl_pkey_get_private($privateKey);
openssl_sign($strToBeSigned, $signature, $key);
echo "signature: ".base64_encode($signature);
Is there a way to do the same thing with Python in...
Hi everyone. I will try my best to explain my problem and my line of thought on how I think I can solve it.
I use this code
for root, dirs, files in os.walk(downloaddir):
for infile in files:
f = open(os.path.join(root,infile),'rb')
filehash = hashlib.md5()
while True:
data = f.read(10240)
if len(data) =...
Just wondering...
I find using escape characters too distracting. I'd rather do something like this:
>>> print ^'Let's begin and end with sets of unlikely 2 chars and bingo!'^
Let's begin and end with sets of unlikely 2 chars and bingo!
Note the ' inside the string, and how this syntax would have no issue with it, or whatever else i...
I recently upgraded my Google App Engine launcher on my Mac, running OSX 10.5.8, and afterwards my projects that work with images stopped working locally.
It seems to be the same problem that I had when first using GAE locally to work with images, before I installed PIL. Here is the error I get:
SystemError: Parent module 'PIL' not lo...
i have users from all timezones, and i want to send out alerts at around 8AM in each users respective timezone.
i need a python script that runs every hour [in a cron job] and i need to find out at which timezone it is 8AM right now, and i can use that info to select the users that have to receive the alerts.
how do i go about doing t...
I have the following dictionary:
sites = {
'stackoverflow': 1,
'superuser': 2,
'meta': 3,
'serverfault': 4,
'mathoverflow': 5
}
To check if there are more than one key available in the above dictionary, I will do something like:
'stackoverflow' in sites and 'serverfault' in sites
The above is maintainable with o...
Suppose I have this:
My---sun--is------very-big---.
I want to replace all multiple hyphens with just one hyphen.
...
I run this code:
from sys import argv
script, user_name =argv
prompt = '>'
print "Hi %s, I'm the %s script." % (user_name, script)
And I get the following error:
Traceback (most recent call last):
script, user_name =argv
ValueError: need more than 1 value to unpack
...
Has anyone made Django work with myconnpy?
I've checked out http://github.com/rtyler/connector-django-mysql but
the author said it's very outdated and not supported.
If you've managed to make Django work with myconnpy, please share your
experience.
Thanks.
...