python

Python: read file line by line into array

How do I read every line of a file in Python and store each line as an element in an array? I want to read the file line by line and each line is appended to the end of the array. I could not find how to do this anywhere and I couldn't find how to create an array of strings in Python. ...

Looking for a good python framework for web apps (w/threading support)

I am looking for a good framework for building web apps in python (could also be python + php). The apps will make http requests (GET/POST) and process data, so I'd like to have threading support to make it faster. I am currently using exec(/path/to/php thread.php ... ); to run "threads" on php. The main app will scrap tons of urls and ...

How deploy Flask application on Webfaction?

Anybody know how to deploy a simple Flask application on Webfaction? I know Webfaction support mod_wsgi and I read the guide on the Flask site but still I can't make my app working. Anybody have a working configuration? UPDATE to answer a comment by Graham Dumpleton. I get a 500 Internal server error. Apache does not show any error in ...

Error using redirect in pylons.

Using Pylons verson 1.0: Working on the FormDemo example from the Pylons book: http://pylonsbook.com/en/1.1/working-with-forms-and-validators.html My controller has the following functions: class FormtestController(BaseController): def form(self): return render('/simpleform.html') def submit(self): # Code to ...

pygame vs. VPython for visualizing PyODE

I made a program similar to the second PyODE tutorial but using VPython instead of pygame and I removed the coord function for changing coordinates. It works but the locating of the spheres and joints isn't correct. I am guessing that it is because I am using the PyODE world coordinates within VPython. Would this in the circumstance I de...

Idle Subprocess connection problem

I'm new to python programming, and want to try to edit scripts in IDLE instead of the OSX command line. However, when I try to start it, it gives me the error "Idle Subprocess didn't make a connection. Either Idle can't start a subprocess or personal firewall software is blocking the connection." I don't have a firewall configured, so wh...

run python file

i dont have any experience in python programming but I get to run python file is there any one to help me pls here is the file content >>>>>>>>>>>>>> #!/usr/local/bin/python """ Based on: http://wxpsvg.googlecode.com/svn/trunk/svg/pathdata.py According to that project, this file is licensed under the LGPL """ try: from pyparsin...

Difference between __getattr__ vs __getattribute__ in Python?

Trying to understand when to use which. The documentation mentions __ getattribute__ applies to new-style classes- What are new-style classes? ...

Using Lambdas to build executable functions from string expressions

I'm using python, and I want a function that takes a string containing a mathematical expression of one variable (x) and returns a function that evaluates that expression using lambdas. Syntax should be such: f = f_of_x("sin(pi*x)/(1+x**2)") print f(0.5) 0.8 syntax should allow ( ) as well as [ ] and use standard operator precedence. ...

[PyGTK] Move cursor upon right click in TextView?

At the moment, when one right clicks in a TextView, a popup menu is brought up, but the cursor doesn't actually change position to where one is right clicking, it just leaves the cursor alone. For me, whom is trying to implement a spell checking menu, this isn't good since I have to click THEN right click in order to get the cursor in th...

In Python - a way to choose which dictionary to iterate over (and manipulate values in)

Here's my problem: Lets say I have two dictionaries, dict_a and dict_b. Each of them have similar keys and values that I can manipulate in the same way, and in fact that's what I'm doing in a large piece of code. Only I don't want to have to write it twice. However, I can't do something like this: if choose_a == 1: for x and y in...

testing urllib2 application, http responses loaded from files

My python application makes many http requests to many urls using urllib2. I would like to build a unit test suite to test my data parsing and error handling code. I have a directory full of test data, with a number of files, each file containing a single http response, with headers and response data. (using curl -i) In some cases, t...

Programming books in ePub format

I purchased an iPad hoping to read books on it that've been aging on my desk for months, but it turned out that there're NO programming books available on iBookstore. Are there any (Python, PHP, jQuery) books available in ePub format? Conversion from pdf to epub is not an option because the formatting is lost in the process. Thanks ...

list of all paths from source to sink in directed acyclic graph

Can anyone point me to some resources on how to do this? I'm using networkx as my python library. Thanks! ...

interesting project that I can implement with fuse-python

Hi, I was thinking of improving my python and just recently read an article about the python-fuse library. I'm always interested about filesystem stuff so I thought this would be a good library to hack on. What I can't come up with is an idea of what I should implement with this. Do you guys have any suggestions or ideas that you can ...

twitter request limit

hi guys , Regarding the twitter API request limit, how does one counts as a request? I'm using python-twitter, so if I have client = twitter.Api(username='acc',password='pw') self.client.GetFriends(result[0]) Does this count as 1 request? Or as many as the number of friends I have? I asked this because I have the following code: ...

comparison between the elements of list with keys of dictionary

I need to check if a particular key is present in some dictionary. I can use has_key ?? Is there any other method to compare the items of the list to the key of dictionary. I have a list like...[(3,4),(4,5)..] I need to check if the (3,4) is there in the dictionary. ...

Doc, rtf and txt reader in python

Like csv.reader() are there any other functions which can read .rtf, .txt, .doc files in Python? ...

Stand-alone fabfile for fabric?

Is it possible to make the fabfile stand-alone? I'm not very fond of running the external tool 'fab'. If I manage to get the fabfile standalone I can run the file from within the (Eclipse / Pydev) IDE, easily debug it, use project configurations and paths etc. Why doesn't this work: from fabric.api import run def host_type(): run('...

Comparing dates in Python

Here's a little snippet that I'm trying execute: >>> from datetime import * >>> item_date = datetime.strptime('7/16/10', "%m/%d/%y") >>> from_date = date.today()-timedelta(days=3) >>> print type(item_date) <type 'datetime.datetime'> >>> print type(from_date) <type 'datetime.date'> >>> if item_date > from_date: ... print 'item is new...