Hello. I have something like that in my python code
class A:
__mess = "Yeap!"
def doSome(self):
self.FN()
def FN(self):
pass
def myFN(self):
print self.__mess
b = A()
b.FN = myFN
b.doSome()
But this doesn't work. Where am I wrong?
python 2.6.5
upd: I want to redefine method (FN) only for one exemplar (b).
upd2:
i...
I'm trying to adapt some tornado code to work with twisted.
Tornado's IOLoop has a function (add_callback) that will essentially call the function back in the next iteration of the loop. As far as I can tell, twisted doesn't have a direct translation of this. Is there any way to simulate this in twisted?
...
Which is better for creating a settings file for Python programs, the built-in module (ConfigParser) or the independent project (ConfigObj), or using the YAML data serialization format? I have heard that ConfigObj is easier to use than ConfigParser, even though it is not a built-in library. I have also read that PyYAML is easy to use, ...
I'm writing a PyQt (Python bindings for the all-powerful Qt library) application and a small part of my application needs a web browser (hint, OAuth). So I started using QtWebkit, which is fantastic by the way. The only hitch is I would like to allow users behind a proxy to use my application.
I have read about the QNetworkProxy class i...
Hi,
I'm using subprocess.Popen and getting IOErrors when running under mod_wsgi. The following code will work in a python term, or a django runserver, and under mod_python. If you put it under mod_wsgi (v2), it fails: (2, 'No such file or directory') I have tried many variations involving using subprocess.PIPE. I have tried to red...
I want to make a key command so that the program will stop running when the Ctrl key then the 'e' key then the 'x' key then the 'i' and 't' keys are hit. So basically when the program is running if you type Ctrl + exit, the program will stop running. There is no GUI and I don't want to do this via a python interpreter.
The end goal is ...
why would anyone use double underscores
why not just do len([1,2,3])?
my question is specifically What do the underscores mean?
...
Hi,
i have a little problem.
I must parse an xml file.
I use the module "element" : http://code.google.com/p/python-elements/
Sometimes in the XML, an element is orphan but sometimes not :
<product />
....
<product>7</product>
I created a class Products with product as children :
class Products(Elements):
_tag = "products"
_ch...
My company is working on an application that is half Qt/C++ for the editor interface and half Django (via QtWebKit browser control) for the runtime. What we want to do is distribute a minimal python installation with our application.
For instance, our Mac app bundle would ideally be structured something like this:
TheApp.app/
Conte...
Hi all,
I did a search and nothing really seemed to be directly related to this question. Is it possible, using Python, to merge seperate PDF files?
Assuming so, I need to extend this a little further. I am hoping to loop through folders in a directory and repeat this procedure.
And I may be pushing my luck, but is it possible t...
Hello,
I have these classes:
class Channel(rdb.Model):
rdb.metadata(metadata)
rdb.tablename("channels")
id = Column("id", Integer, primary_key=True)
title = Column("title", String(100))
items = relationship("MediaItem", secondary=channel_items, order_by="MediaItem.titleView", backref="channels")
class MediaItem(...
Hi,
I need to build a webservice that is very computationally intensive, and I'm trying to get my bearings on how best to proceed.
I expect users to connect to my service, at which point some computation is done for some amount of time, typically less than 60s. The user knows that they need to wait, so this is not really a problem. My ...
Can I call a test method from within the test class in python? For example:
class Test(unittest.TestCase):
def setUp(self):
#do stuff
def test1(self):
self.test2()
def test2(self):
#do stuff
update: I forgot the other half of my question. Will setup or teardown be called only after the method t...
Hello,
I would like to write a list to a file and read back the contents of the file into a list.
I am able to write the list to the file using simplejson as follows:
f = open("data.txt","w")
l = ["a","b","c"]
simplejson.dump(l,f)
f.close()
Now to read the file back i do
file_contents = simplejson.load(f)
But, i guess file_conten...
Ok I am programing a way to interface with Grooveshark (http://grooveshark.com). Right now I have a class Grooveshark and several methods, one gets a session with the server, another gets a token that is based on the session and another is used to construct api calls to the server (and other methods use that). Right now I use it like so....
I'm trying to setup Pylons (1.0) with Apache mod_wsgi. Everything works fine with mod_wsgi and I can run a simple python wsgi app just fine.
I've got the quickwiki example from the Pylons site working when running it with paster, but obviously I would never deploy in such a manner - so I'm trying to get the Quickwiki example working w...
Hi all,
I am forming a SOAPpy request but I can't figure out how to set the attributes in a tag. Here is my code:
url = wsdlfile = 'https://stats2.overture.com/ExternalSOAP/statsPMCAPI_1_0.wsdl'
n = 'urn:yahoo:overture:stats:3.0'
server = WSDL.Proxy(wsdlfile)
server.soapproxy.config.dumpSOAPOut = 1
server.soapproxy.config.dumpSOAPIn =...
This is a strange request but I'm looking for buggy Python code. I want to learn more about bugs and debuggers and I need some buggy code to work with. Unfortunately, all the code I've written is short and bug-free (so far).
Preferably it's not GUI stuff (b/c I'm just starting to learn it) but anything's good.
Thanks in advance
...
Hi all,
I've been looking for a way to download an image from a URL, preform some image manipulations (resize) actions on it, and then save it to a django ImageField. Using the two great posts (linked below), I have been able to download and save an image to an ImageField. However, I've been having some trouble manipulating the file ...
I'm looking for a good tutorial on Python unit testing in Eclipse, particularly using PyDev.
I am working on a fairly large project using Eclipse. I've built several test suites that are working nicely, but I'm intrigued by the large number of additional unit testing features in PyDev. I've tried to work with them some, but it's gon...