Nose Tests - File Uploads
Hi Stackoverflow, How would one go about testing a Pylons controller (using Nose Tests) that takes a file upload as a POST parameter? ...
Hi Stackoverflow, How would one go about testing a Pylons controller (using Nose Tests) that takes a file upload as a POST parameter? ...
I've tried the sound module in Pygame, and I haven't been satisfied with the results. I need to play music and sounds in my game. What can I use that works with OSX, Linux and Windows, and plays sound well? Unfortunately, pyMedia doesn't compile on OSX. ...
The title isn't very clear but I'll try to explain. Having this class: class Wrapped(object): def method_a(self): # do some operations return n def method_b(self): # also do some operations return n I wan't to have a class that performs the same way as this one: class Wrapper(object): def ...
Here's my code: sentenceToTranslate = raw_input("Please write in the sentence you want to translate: ") words = sentenceToTranslate.split(" ") for word in words: if isVowel(word[0]): print "TEST" def isVowel(letter): if letter.lower() == "a" or letter.lower() == "e" or letter.lower() == "i" or letter.lower() == "o" or...
I have been learning a bit of Python 2 and Python 3 and it seems like Python 2 is over all better than Python 3. So that's where my question comes in. Are there any good reasons to actually switch over to python 3? ...
What if there is nothing that matches the get? Then it returns in an error. How do I say: get if there is, otherwise, return nothing. ...
I am running the following test script to try to read packets from a sample .pcap file I have downloaded. It won't seem to run. I have all of the modules, but no examples seem to be running. import socket import dpkt import sys pcapReader = dpkt.pcap.Reader(file("test1.pcap", "rb")) for ts, data in pcapReader: ether = dpkt.etherne...
I'm pretty stumped with this one guys. I'm trying to toy with Python (as you can see with my previous questions) so I'd really love some help here. :P Speeds is of no concern for now, just working. Thanks! Edit: I ended up doing it this way: def isSquare(number): temp = math.sqrt(int(number)) if "." in str(abs(int(temp))...
Hello Assume I have these datatime variables: start_time, end_time, current_time I would like to know how much time left as percentage by checking current_time and the time delta between start_time and the end_time IE: Assume the interval is a 24 hours betwen start_time and end_time yet between current_time and end_time, there are 6...
So after a few hours, I discovered the cause of a bug in my application. My app's source is structured like: main/ __init__.py folderA/ __init__.py fileA.py fileB.py Really, there are about 50 more files. But that's not the point. In main/__init__.py, I have this code: from folderA.fileA import * in f...
Hi folks, I think this is a bit tricky, at least for me. :) So I have 4 models Person, Singer, Bassist and Ninja. Singer, Bassist and Ninja inherit from Person. The problem is that each Person can be any of its subclasses. e.g. A person can be a Singer and a Ninja. Another Person can be a Bassist and a Ninja. Another one can be a...
I'm new to Python and am starting to teach myself GUI programming (hopefully) using PyQT4.7 and Python 2.6 I just downloaded the whole PyQT/QT4 package (including QTDesigner) from the PyQT website, however it seems QTDesigner, which looks amazing to use as a newbie (since you can see all the attributes/properties/defaults etc) of each w...
Unless I'm mistaken, creating a function in Python works like this def my_func(param1, param2): # stuff However, you don't actually give the types of those parameters. Also, if I remember, python is a strongly typed language, as such, it sesms like Python shouldn't let you pass in a parameter of a different type then the function ...
there is an interesting page http://scotdoyle.com/python-epoll-howto.html about how to do asnchronous / non-blocking / AIO http serving in python 3. there is the tornado web server which does include a non-blocking http client. i have managed to port parts of the server to python 3.1, but the implementation of the client requires pyCur...
Just wondering whats the best way to test Python CGI while developing a site? (I'm used to PHP for web dev so bear with me :P) ...
BaseHTTPHandler from the BaseHTTPServer module doesn't seem to provide any convenient way to access http request parameters. What is the best way to parse the GET parameters from the path, and the POST parameters from the request body? Right now, I'm using this for GET: def do_GET(self): parsed_path = urlparse.urlparse(self.path) ...
OK this is presumably a hard one, I've got an pyGTK application that has random crashes due to X Window errors that I can't catch/control. So I created a wrapper that restarts the app as soon as it detects a crash, now comes the problem, when the user logs out or shuts down the system, the app exits with status 1. But on some X errors i...
Hi all, I need to create daemon that will monitor certain directory and will process every file that's written to that particular path. My choice is either java or python. Did you guys have any experience using both technology? what is the best one? EDIT 1: files that will be processed is simple text file (one line with tab separated ...
Does Python have a built-in, simple way of encoding/decoding strings using a password? Something like this: >>> encode('John Doe', password = 'mypass') 'sjkl28cn2sx0' >>> decode('sjkl28cn2sx0', password = 'mypass') 'John Doe' So the string "John Doe" gets encrypted as 'sjkl28cn2sx0'. To get the original string, I would "unlock" that ...
We are planning a web application to build on Google's App Engine platform. Is it good to use the Django 1.1 framework to develop Google App Engine applications? If not, could you please suggest me the best option available, which has good tutorials and learning resource? ...