How can I pass a functions name to a function and then call it?
Is it possible to do this without using getattribute?
How can I pass a class name to a function and then instantiate the class?
I know I just could pass the instance of the class directly to the function but it is important that the class gets instantiated after calling the...
hi there,
please, help me with designing MVC-pattern with PyQt.
i want to split all program at 3 parts:
1. some class that is abstracted from all Qt classes(model)
2. some class that provides data from model to qt-app(controller)
3. Qt-app itself with defined method SignalsToSlots that connect signals with controller.
is it optimally a...
I would like to be able to run a nose test script which accepts command line arguments. For example, something along the lines:
test.py
import nose, sys
def test():
# do something with the command line arguments
print sys.argv
if __name__ == '__main__':
nose.runmodule()
However, whenever I run this with a command line a...
Hi,
I am able to properly pass a string variable to the gqlquery through parameter substitution, here's the code i've tried to use;
user_name = self.request.get('username') #retrieved from UI
p = models.UserDetails.all().filter('user_name = ', user_name).fetch(1)
I don't get any results and the query fails silently. But when I hard c...
Hello, I'm looking for a tool to record scripts for web application testing in python, similar to ruby watirrecorder. The latter is basically a tool that generates the script for watir (web application testing in ruby) which uses IE to test web applications.
...
Writing a python program, and I came up with this error while using the urllib.urlopen function.
Traceback (most recent call last):
File "ChurchScraper.py", line 58, in <module>
html = GetAllChurchPages()
File "ChurchScraper.py", line 48, in GetAllChurchPages
CPs = CPs + urllib.urlopen(url)
TypeError: cannot concatenate 'str' and 'insta...
Hello, I'm using win32com.client to control an IE instance in Python. How can I click a link on a certain page (e.g. using navigate to link href isn't acceptable since it won't trigger referer sending)? Here is the base:
import random
import time
from win32com.client import Dispatch
ie = Dispatch("InternetExplorer.Application")
ie.visi...
I'm using this recipe: http://code.activestate.com/recipes/278731/ on an Ubuntu server.
I make a daemon instance like this:
class MyDaemon(Daemon):
def run(self):
while True:
try:
do_my_data_processing()
except MySQLdb.OperationalError:
# Sleep an extra 30 second...
File-like objects are objects in Python that behave like a real file, e.g. have a read() and a write method(), but have a different implementation. It is and realization of the Duck Typing concept.
It is considered good practice to allow a file-like object everywhere where a file is expected so that e.g. a StringIO or a Socket object ca...
I am using the Boto library to talk to AWS. I want to disable logging. (Or redirect to /dev/null or other file). I cant find an obvious way to do this. I tried this, but that doesn't seem to help.
import boto
boto.set_file_logger('boto', 'logs/boto.log')
This says it is possible, http://developer.amazonwebservices.com/connect/thread.j...
I just tried to run BeautifulSoup (3.1.0.1) with Jython (2.5.1) and I was amazed to see how much slower it was than CPython. Parsing a page (http://www.fixprotocol.org/specifications/fields/5000-5999) with CPython took just under a second (0.844 second to be exact). With Jython it took 564 seconds - almost 700 times as much.
Can anyone ...
I like to check if there is any result for my datastore query in the Google App Engine Datastore. This is my query:
users = User.all()
users.filter("hash =", current_user_hash)
What is the fastest and most elegant way to check if my query returns any result?
PS: I know a way to do so, but I'm very unsure if it is very efficient...
...
Hi, I regularly make figures (the exploratory data analysis type) in R. I also program in Python and was wondering if there are features or concepts in matplotlib that would be worth learning. For instance, I am quite happy with R - but its image() function will produce large files with pixelated output, whereas Matlab's equivalent figur...
I want to create a simple infographic in python. Matplotlib seems to have a lot of features but nothing that covers off my simple heatmap grid example.
The infographic is a simple 5 x 5 grid with numbers inside ranging from 0 to 1. The grid squares would then be coloured in 0=white 1=blue 0.5 being a pale blue.
Matplotlib could probabl...
I'm just confused about why my code would not work, here's the question and the code I have so far (the test run says my answer is wrong).
Given the dictionary d, find the largest key in the dictionary and associate the corresponding value with the variable val_of_max. For example, given the dictionary {5:3, 4:1, 12:2}, 2 would be asso...
I am writing a module that amongst other things allows bitwise read access to files. The files can potentially be large (hundreds of GB) so I wrote a simple class that lets me treat the file like a string and hides all the seeking and reading.
At the time I wrote my wrapper class I didn't know about the mmap module. On reading the docum...
Hello!
How to create datetime object representing the very last moment of the current month ?
...
Possible Duplicate:
do-while loop in python?
Is there a
do until x:
...
in Python, or a nice way to implement such a looping construct?
...
Hi,
I am trying to record the success or failure of a number of copy commands, into a log file. I'm using shutil.copy() - e.g.
`str_list.append(getbitmapsfrom)
game.bigbitmap = "i doubt this is there.bmp"
str_list.append(game.bigbitmap)
source = '\\'.join(str_list)
shutil.copy (source, newbi...
Hi All,
I'm currently using the toprettyxml() function of the xml.dom module in a python script and I have some troubles with the newlines.
If don't use the newl parameter or if I use toprettyxml(newl='\n') actually it displays several new lines instead of only one.
For instance
f = open(filename, 'w')
f.write(dom1.toprettyxml(encodi...