python

String search in mysqltable using python

Hi, I want to search the matching strings from a mysql table. The search string is not a correct sentence, its only a part of the sentence.Any one can help me.? Thanks in advance... Nimmy ...

Python: Locate 3 adjacent list items and determine list index of first of them

I need to process weather station data which is in a format like this (SYNOP), where each line represents one measurement and I have thousands of measurements: line = 'AAXX 01004 60265 32970 03404 10048 20010 38997 48605 51014=' Starting with the 6th block, the blocks are numbered (1xxxx 2xxxx 3xxxx etc, sometimes only 5 blocks but so...

How to insert a SVG file in a PDF document?

I'm trying use tool from http://jan.kollhof.net/projects/svg/svgpdf/ but acrobat reader don't show svg content in pdf. ...

twisted web getPage, 2 clients in 2 classes, manage events between the two

Hi All, i'm trying to create a bridge program in twisted.web that receives data from a web server and sends it to another server, thus i'm using 2 getPage applications that i have wrapped in a class for convenience, the class contains all the callbacks and the client "routine".. 1)auth 2)receive data 3)send data, all this is done in a c...

Project euler problem in python (problem 53)

So I'm learning python so I'm going through some project euler problems. And I'm not sure if this is a python problem I'm having, or just me being retarded, but I seem to be getting the wrong answer for problem 53. Here's a link to the problem http://projecteuler.net/index.php?section=problems&id=53 and this is my code: from math...

how to export images from an openstreetmap server??

Good morning everyone, i'll try to explain the whole situation here: I have a website (django-python) that shows a map using Openlayers. The map has two layers: a background that shows the city names and streets and for that i use openstreetmaps; the second layer contains some greographic information , for that i use MapServer (more spec...

Sql Alchemy connecion time Out

I am using sqlalchemy with Mysql, and executing query with sql expression . when executing a number of query then it time out. I found an answer but it is not clear to me -- Answer link . plz any one can help me? TimeoutError: QueuePool limit of size 5 overflow 10 reached, connection timed out, timeout 30 ...

Python how to search and correct html tags and attributes?

I have to fix all the closing tags of the <img> tag as shown in the text below. Instead of closing the <img> with a >, it should close with />. Is there any easy way to search for all the <img> in this text and fix the > ? (If it is closed with a /> already then there is no action required). Other question, if there is no "width" or "...

easy_install extra build arguments

I'm trying to install ReportLab, but I have no C compiler available to compile the rl_accel library. Using setup.py, I would add an extra argument like so: python setup.py --rl_accel=no install Is it possible to add extra arguments to easy_install so that I can reproduce the same effect? easy_install reportlab [something here?] ...

Eclipse and PyDev

I want to start using Eclipse with the PyDev plugin, as recommended by this poster. The PyDev download page says I need Eclipse (3.2 to 3.5) and that I can use the Platform Runtime Binary. Can I also use Eclipse 3.5.2 (or maybe even 3.6) instead of 3.5? Where can I find the Platform Runtime Binary? I'm a little bit lost in the Eclips...

How do I get the stack trace from an Exception Object in Python?

How can I get the full stack trace from the Exception object itself? Consider the following code as reduced example of the problem: last_exception = None try: raise Exception('foo failed') except Exception as e: last_exception = e # this happens somewhere else, decoupled from the original raise print_exception_stack_trace(last_...

What libraries for modeling complex questionaire in Python?

For a medical website I'm trying to model a questionnaire that should result in a range of possible diagnoses. The questionnaire is fairly complex with a lot of conditionals. I made a flowchart/decision tree to reflect this questionnaire. I'm using Django to make the website. Currently I'm thinking of using Python Graph to turn the flow...

How to parse RSS link (get ulr to RSS) from the page in Python framework Scrapy?

Hello. I want to parse Google search and get links to RSS from each item from the search results. I use Scrapy. I tried this construction, ... def parse_second(self, response): hxs = HtmlXPathSelector(response) qqq = hxs.select('/html/head/link[@type=application/rss+xml]/@href').extract() print qqq item = response.req...

How to install pangocairo with python bindings on 32bit OSX 10.6

I'm having difficulties building the pangocairo bindings on my OSX 10.6 machine and would like to know how to proceed. To sketch the background, I'm writing a wxwindows application in Python with wxpython that draws on a cairo canvas. I have been able to compile all dependencies for this with the extra difficulty that I need 32bit (inst...

mplot3d in wxPython frame

I'm writing an application in wxPython. The button "Plot" shows the wxFrame with 3D surface but I can't rotate the surface. Is it possible to rotate a 3D plot placed in a wxFrame? How can I do? Example: import matplotlib matplotlib.use('WXAgg') from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas from matplot...

"post" method to communicate directly with a server

Just started with python not long ago, and I'm learning to use "post" method to communicate directly with a server. A fun script I'm working on right now is to post comments on wordpress. The script does post comments on my local site, but I don't know why it raises HTTP Error 404 which means page not found. Here's my code, please help m...

Would it be very unpythonic to use this setitem function to overcome the list comprehension limitation?

>>> a=range(5) >>> [a[i] for i in range(0,len(a),2)] ## list comprehension for side effects [0, 2, 4] >>> a [0, 1, 2, 3, 4] >>> [a[i]=3 for i in range(0,len(a),2)] ## try to do assignment SyntaxError: invalid syntax >>> def setitem(listtochange,n,value): ## function to overcome limitation listtochange[n]=value return value >>> ...

How to send Email Attachments with python

I am having problems understanding how to email an attachment using python. I have successfully emailed simple messages with the smtplib. Could someone please explain how to send an attachment in an email. I know there are other posts online but as a python beginner I find them hard to understand. ...

pyAA with py2exe

Hi, Is anyone able to get pyAA working with py2exe? pyAA can be downloaded here. I have trying to do this for the last 2 days and I am unable to reach a solution till now. The example files are like given below: hello.py import pyAA print "Hello, World" setup.py from distutils.core import setup import py2exe setup(console=['hell...

Scraping websites with Javascript enabled?

I'm trying to scrape and submit information to websites that heavily rely on Javascript to do most of its actions. The website won't even work when i disable Javascript in my browser. I've searched for some solutions on Google and SO and there was someone who suggested i should reverse engineer the Javascript, but i have no idea how to ...