Hi all,
I've got a model that looks like this,
class PL(models.Model):
locid = models.AutoField(primary_key=True)
mentionedby = models.ManyToManyField(PRT)
class PRT(models.Model):
tid = ..
The resulting many to many table in mysql is formed as,
+------------------+------------+------+-----+---------+----------------+
|...
I have a python application that grabs a collection of data and for each piece of data in that collection it performs a task. The task takes some time to complete as there is a delay involved. Because of this delay, I don't want each piece of data to perform the task subsequently, I want them to all happen in parallel. Should I be using ...
I am looking for a good config file library for c that is not xml. Optimally I would really like one that also has python bindings. The best option I have come up with is to use a JSON library in both c and python. What would you recommend, or what method of reading/writing configuration settings do you prefer?
...
I am using Sphinx to document a webservice that will be deployed in different servers. The documentation is full of URL examples for the user to click and they should just work. My problem is that the host, port and deployment root will vary and the documentation will have to be re-generated for every deployment.
I tried defining substi...
What is the best way to compare two instances of some object for equality in Python? I'd like to be able to do something like
Example:
doc1 = ErrorDocument(path='/folder',title='Page')
doc2 = ErrorDocument(path='/folder',title='Page')
if doc1 == doc2: # this should be True
#do something
EDIT:
To further clarify the question. I'...
I'm trying to understand basic threading in python, I'm having trouble understanding how pooling works with the queue module. Heres the example server used in the howto I'm reading from: http://www.devshed.com/c/a/Python/Basic-Threading-in-Python/2/. Basically what I don't understand is how the variable pickledList ends up available to t...
I have to write soaplib method, that has many arguments. The idea is that the user should able able to choose, which arguments he wants to provide. Is that even possible?
I know it is possible in python generally, but there is an error, when i try to set it up like normal python method with default arguments.
...
I've developped a DLL for a driver in C. I wrote a test program in C++ and the DLL works fine.
Now I'd like to interract with this DLL using Python. I've successfully hidden most of the user defined C structures but there is one point where I have to use C structures. I'm rather new to python so I may get things wrong.
My approach is t...
What is the easiest way in python to replace a character in a string like:
text = "abcdefg";
text[1] = "Z";
^
...
Using matplotlib/pylab....
How do I plot 5 heatmaps as subplots which have the same number of columns but different row counts? In other words, I need each subplot's height to be scaled differently.
Perhaps an image better illustrates the problem...
I need the data points to all be square, AND the columns to be lined up, so the heig...
I have an instance of dict with ints, floats, strings as keys, but the problem is when there are a as int and b as float, and float(a) == b, then their hash values are the same, and thats what I do NOT want to get because I need unique hash vales for this cases in order to get corresponding values.
Example:
d = {1:'1', 1.0:'1.0', '1':1...
hello
I have an external C# program which executes a python script using the Process Class.
my script returns a numerical code and I want to view that number with my C# program.
the problem is, I'm getting the return code of python.exe, instead of my script return number - in that case, "return 3"
any suggestions ? thanks
...
okay, I'm learning how to pool threads in python. I'm relatively new to threading in general and I have a question. In the following code, you see that the pickledList variable thats being used by the thread is set in the global scope. This is an example from a howto on a website. My question is: what if the variable that the thread was ...
What I'm trying to do is fairly simple: send a file from client to server. First, the client sends information about the file - the size of it that is. Then it sends the actual file.
This is what I've done so far:
Server.py
from twisted.internet import reactor, protocol
from twisted.protocols.basic import LineReceiver
import pickle
i...
In Python, is there a way to call a function after an object is finalized?
I thought the callback in a weakref would do it, but it appears a weakref's callback is called once the object is garbage collected, but before the objects __del__ method is called. This seems contrary to the notes on weakrefs and garbace collection in the Pytho...
So, I want to store a dictionary in a persistent file. Is there a way to use regular dictionary methods to add, print, or delete entries from the dictionary in that file?
It seems that I would be able to use cPickle to store the dictionary and load it, but I'm not sure where to take it from there.
...
I have an application that allows you to send event data to a custom script. You simply lay out the command line arguments and assign what event data goes with what argument. The problem is that there is no real flexibility here. Every option you map out is going to be used, but not every option will necessarily have data. So when the ap...
I am playing around with PortAudio and Python.
data = getData()
stream.write( data )
I want my stream to play sound data, that is represented in Float32 values. Therefore I use the following function:
def getData():
data = []
for i in range( 0, 1024 ):
data.append( 0.25 * math.sin( math.radians( i ) ) )
return dat...
This is a kind of follow-up from my last question if this can help you.
I'm defining a few ctype structures
class EthercatDatagram(Structure):
_fields_ = [("header", EthercatDatagramHeader),
("packet_data_length", c_int),
("packet_data", POINTER(c_ubyte)),
("work_count", c_ushort)]
class EthercatPacket(Structu...
In python:
u'\u3053\n'
Is it utf-16?
I'm not really aware of all the unicode/encoding stuff, but this type of thing is coming up in my dataset,
like if I have a=u'\u3053\n'.
print gives an exception and
decoding gives an exception.
a.encode("utf-16") > '\xff\xfeS0\n\x00'
a.encode("utf-8") > '\xe3\x81\x93\n'
print a.encode("utf-8...