I have a nested dict like this
d={ time1 : column1 : {data1,data2,data3}
column2 : {data1,data2,data3}
column3 : {data1,data2,data3} #So on.
time2 : {column1: } #Same as Above
}
data1,data2,data3 represent the type of data and not the data itself
I need to put this dict into a file like ...
I am trying to pass the 'day' from the while loop into a sql statement that then gets passed into a MySQL command line to be executed with -e
I can not use the DB module or other python libraries to access MySQL, it needs to be done via command line. It also looks like I might need to convert the day to a string before concatenating to...
Is there a better way to do this in python, or rather: Is this a good way to do it?
x = ('a', 'b', 'c')
y = ('d', 'e', 'f')
z = ('g', 'e', 'i')
l = [x, y, z]
s = set([e for (_, e, _) in l])
I looks somewhat ugly but does what i need without writing a complex "get_unique_elements_from_tuple_list" function... ;)
edit: expected value ...
Im trying to connect a "Information" object to many "Customers" (see code below)
When one Information object is updated, I want to send email to each Customer that is connected to the Information.
However, when I log the sold_to field that the signal recieves I always get what the data is like BEFORE the save.
I'm guessing this is bec...
Hi!
I will have to implement a convolution of two functions in Python, but SciPy/Numpy appear to have functions only for the convolution of two arrays.
Before I try to implement this by using the the regular integration expression of convolution, I would like to ask if someone knows of an already available module that performs these op...
Hi, does SQLAlchemy have something similar to Django's signal concept? Basically, I'd like to trigger a few functions when I pre-save or post-save some entity objects. Thanks.
Edit: I JUST want equivalent of django-signals in SQLAlchemy.
...
I'm looking for a good html parser like HtmlAgilityPack (open-source .NET project: http://www.codeplex.com/htmlagilitypack), but for using with Python.
Anyone knows?
...
I wanted to do something like setattr to a class in class method in Python, but the class doesn't exist so I basically get:
NameError: global name 'ClassName' is not defined
Is there a way for a class method to modify the class? Something like this but that actually works:
class ClassName(object):
def HocusPocus(name):
se...
I was recently requested by a client to build a website for their insurance business. As part of this, they want to do some screen scraping of the quote site for one of their providers. They asked if their was an API to do this, and were told there wasn't one, but that if they could get the data from their engine they could use it as t...
I have a python list which holds a few email ids accepted as unicode strings:
[u'[email protected]',u'[email protected]',u'[email protected]']
This is assigned to values['Emails'] and values is passed to render as html.
The Html renders as this:
Emails: [u'[email protected]',u'[email protected]',u'[email protected]']
I would like it to ...
Hi
Let's suppose that I have a list of elements, and I want to select only some of them, according to a certain function (for example a distance to an other element).
I want to have as a result a list of tuple, with the distance and the element. So, I wrote the following code
result = [ ( myFunction(C), C) for C in originalList if myF...
Recently I decided to expand my programming horizons and learn the python programming language. While I have used python a little bit for classes in college and for a project or two at work I am by no means an expert. My question is as follows: should I bother with the 2.x releases or should I jump straight to 3.0? I am leaning towards 3...
Does anybody knows fate of Global Interpreter Lock in Python 3.1 against C++ multithreading integration
...
I'm working on a statistical project that involves iterating over every possible way to partition a collection of strings and running a simple calculation on each. Specifically, each possible substring has a probability associated with it, and I'm trying to get the sum across all partitions of the product of the substring probability in ...
The os.write function can be used to writes bytes into a file descriptor (not file object). If I execute os.write(fd, '\n'), only the LF character will be written into the file, even on Windows. I would like to have CRLF in the file on Windows and only LF in Linux. What is the best way to achieve this?
I'm using Python 2.6, but I'm also...
Upon trying to start a Pinax app, I receive the following error:
Error: No module named notification
Below are the steps I took
svn co http://svn.pinaxproject.com/pinax/trunk/ pinax
cd pinax/pinax/projects/basic_project
./manage.py syncdb
Any suggestions?
...
I'm working on a django field validation and I can't figure out why I'm getting a type error for this section:
def clean_tid(self):
data = self.cleaned_data['tid']
stdout_handel = os.popen("/var/www/nsmweb/jre1.6.0_14/bin/java -jar /var/www/nsmweb/sla.jar -t %s grep -v DAN") % data
result = stdout_handel.read()
Do I have ...
Programming a Python web application, I want to create a text area where the users can enter text in a lightweight markup language. The text will be imported to a html template and viewed on the page. Today I use this command to create the textarea, which allows users to enter any (html) text:
my_text = cgidata.getvalue('my_text', 'defa...
In Django, how do I associate a Form with a Model so that data entered into the form are inserted into the database table associated with the Model? How do I save that user input to that database table?
For example:
class PhoneNumber(models.Model):
FirstName = models.CharField(max_length=30)
LastName = models.CharField(max_len...
I have django running through WSGI like this :
<VirtualHost *:80>
WSGIScriptAlias / /home/ptarjan/django/django.wsgi
WSGIDaemonProcess ptarjan processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup ptarjan
Alias /media /home/ptarjan/django/mysite/media/
</VirtualHost>
But if in python I do :
def handler(request...