python

Python: How to do break up array processing (using multiple queued functions) in timed chunks (600ms)

Hi, I was wondering what would be the best approach to split up array processing using multiple queued functions into small time chunks? So say I have an multi dimensional array, and I want to run a function(s) over it, but only in small timed chunks, say 500ms each time I trigger the processing to occur. What would be the best approa...

How to uninstall Python 2.7 on a Mac OS X 10.6.4?

I want to completely remove Python 2.7 from my Mac OS X 10.6.4. I managed to remove the entry from the PATH variable by reverting my .bash_profile. But I also want to remove all directories, files, symlinks, and entries that got installed by the Python 2.7 install package. I've got the install package from http://www.python.org/. What di...

Code to solve determinant using Python without using scipy.linalg.det

Description(this is a hwk question): I am not sure where to start here. I plan to use Laplace's Expansion but I am not sure how to implement it for nxn matrices. Any help would be appreciated. Note: I already have a function to generate random matrices for a nxn matrix. Also the timing the calculation isn't a problem. The only thing I...

List of combinations

I have a list with length N and each element of this list are 0 or 1. I need to get all possible combinations of this list. Here is my code: def some(lst): result = [] for element in lst: c1 = copy.copy(element) c2 = copy.copy(element) c1.append(0) c2.append(1) result.append(c1) ...

Distinct in many-to-many relation

class Order(models.Model): ... class OrderItem(models.Model) order = models.ForeignKey(Order) product = models.ForeignKey(Product) quantity = models.PositiveIntegerField() What I need to do is to get the Order(s) which has only one order item. How can I write it using the QuerySet objects (without writing SQL)? ...

Error in django unittest while loading a fixture

Hello all, I am making unittests for a django app. I need some data in the database for my tests so I am using a json fixture. I have two fixtures: for users and it works ok. for some webpages The fixture 2 cause the following error: Problem installing fixture 'C:\Users\luc\Dev\Hg\mnl-adminpub\website\fixtures\website-unittest.js...

single py file for convert rst to html

I write blog by using rst, and I manually convert it into html, and post it. For now, I want to create a simple blog system by using GAE, I know docutils can convert rst to html, but docutils is big, is there a single py file for convert rst to html? anyone notice GAE? ...

How to perform this sql in django model?

SELECT *, SUM( cardtype.price - cardtype.cost ) AS profit FROM user LEFT OUTER JOIN card ON ( user.id = card.buyer_id ) LEFT OUTER JOIN cardtype ON ( card.cardtype_id = cardtype.id ) GROUP BY user.id ORDER BY profit DESC I tried this: User.objects.extra(select=dict(profit='SUM(cardtype.price-cardtype.cost)')).annotat...

Python: Write a list of tuples to a file

Hi everyone. How can I write the following list: [(8, 'rfa'), (8, 'acc-raid'), (7, 'rapidbase'), (7, 'rcts'), (7, 'tve-announce'), (5, 'mysql-im'), (5, 'telnetcpcd'), (5, 'etftp'), (5, 'http-alt')] to a text file with two columns (8 rfa) and many rows, so that I have something like this: 8 rfa 8 acc-raid 7 rapidbase 7 rcts 7 tve-an...

Why must I use Qt Designer 2.7 with Python 2.7 ?

Why can't I use other Qt series with different Python releases? ...

python and Os moduels !

hello every body i wana do that os.system('crontab -e;1') then write (python WOW.py) then close !! so how to write ! ...

linux "more" like code in python for very big tuple/file/db records/numpy.darray?

Dear All, I am in looking for a buffer code for process huge records in tuple / csv file / sqlite db records / numpy.darray, the buffer may just like linux command "more". The request came from processing huge data records(100000000 rows maybe), the records may look like this: 0.12313 0.231312 0.23123 0.152432 0.22569 0.311312 0.54549...

Location of python string class in the source code

I'm looking into overloading the '+' operator for a certain string so I was thinking of subclassing the string class then adding the code in the new class. However I wanted to take a look at the standard string class first but I can't seem to find it... stupid eh? Can anyone point the way? Even online documentation of the source cod...

why the behaviour of the shell prompt changes after terminating the subprocess

hi, all, I have a python test script to test and launch several subprocesses and after some interval of time, terminate these subprocesses. e.g. [username@machine workdir]python call_test.py and inside one test case of this call_test.py, it is bit like this. def test_launch_kill(self): p1 = subprocess.Popen("./exec1") thread...

Running cx_Oracle under jython on tomcat

Hi I'm trying to load cx_Oracle using tomcat. Loading from python works fine, but for jython I'm getting "module not found". My system.path includes site-packages that contains cx_Oracle.so. I'm new to jython and I've not had time to familiarize myself with all the variables but I believe I have all the necessary environment variables...

How to get server reply after sending a mail using smtplib SMTP.sendmail

Hi, I have a program to send mail using python smtplib. I have the mail sending part working fine, but I also need to capture the server return message after a mail has been sent. For example postfix returns the following message after a mail has been queueed: reply: '250 2.0.0 Ok: queued as EB83821273B\r\n' reply: retcode (250); Msg: ...

Using Python vs PHP for Web Development - When and Where

First of all, please don't make a comment that is based on your opinion or preferences or some magic hatred for PHP. I work at a web development company and I'm going to write a new CMS soon. I'm currently using WordPress, but I have lots of experience with Python/Django. My question to this great community is what are the practical be...

Django ManyToMany relationship with abstract base - not possible, but is there a better way?

Given the following models: class BaseMachine(models.Model) fqdn = models.CharField(max_length=150) cpus = models.IntegerField() memory = models.IntegerField() class Meta: abstract = True class PhysicalMachine(BaseMachine) location = models.CharField(max_length=150) class VirtualMachine(BaseMachine) h...

does python gives interactivity as javascript?

I want to add interactivity like clicks, hover, onpage load() to a webpage, if i use python for generating xhtml, will python give essential flavors like javascript?? I'm bit confused and starter in python for web development, so is there need to include old javascript into python or the python only can handle interactivity, events as j...

GAE webapp application internationalization with Babel

How would you go about internationalizing a Google App Engine webapp application using BABEL? I am looking here for all the stages: Marking the strings to be translated. Extracting them. Traslating Configuring your app to load the right language requested by the browser ...