python

Is it possible to cut away transparent areas of Gtk-pixbuf ?

Hi, I am currently using rsvg in Python to separate Svggroups. I got it working so that rsvg loads a single group ... alas all the transparent space around that still remains. Is there a gtk functionallity to cut away all this space? Thanks for all the answers! ...

Python 3 with Emacs

Is there anything that should be done to make GNU Emacs 23.2 work well with Python 3? How would an ideal environment for development with Python 3 in Emacs look like? Is there any documentation about using ropemacs with Python 3? Should I add Python 3's site-packages directory to the python path? Will following the instructions here ...

Fibonacci under 4 millions!

Possible Duplicate: Python program to find fibonacci series. More Pythonic way. Hey, i was trying to write a script which sums all the even terms in "Fibonacci Sequence" under 4 millions. Fibonacci1 = 1 Fibonacci2 = 2 a = 2 i = 4 for i in range(1,4000000): Fibonacci1 = Fibonacci1 + Fibonacci2 if Fibonacci1 % 2 == 0: a = a...

How to use python modules that were renamed 3 in a cross compatible way?

There are several modules that were renamed in Python 3 and I'm looking for a solution that will make your code work in both python flavors. In Python 3, __builtin__ was renamed to builtins. Example: import __builtin__ #... __builtin__.something # appearing multiple times ("something" may vary) ...

A href catching

Hello, I'm using BeautifulSoup for parsing some html. Here is the content: <tr> <th>Your provider:</th> <td> <img src="/isp_logos/la-la-la.ico" alt=""/> <a href="/isp/SomeProvider"> Provider name </a> &nbsp; <a href="http://*/isp-comparer/?isp=000000"&gt; </a> </td> </tr> I have to get SomeProvider text from the link . ...

Populating a SQLite3 database from a .txt file with Python

Dear Python Experts, I am trying to setup a website in django which allows the user to send queries to a database containing information about their representatives in the European Parliament. I have the data in a comma seperated .txt file with the following format: Parliament, Name, Country, Party_Group, National_Party, Position ...

python- execution time problem

I'm able to go through the first function....but the second func is not running....getaction def registerInitialState(self, state): """ This is the first time that the agent sees the layout of the game board. Here, we choose a path to the goal. In this phase, the agent should compute the path to the goal and store it i...

How to: python script + imagemagic = windows application ?

Hi guys. I have a small problem. I have a script in python, which uses imagemagic. It works fine on my Mac, or Linux. But I need to give it to the client, and he uses Windows. Actually the question: how can I build applications for it, and on what to do Gui. (Perhaps you know the finished product is open source, who knows how to resize i...

Converting WAV audio files to MP3 on a server automatically once uploaded?

I'm working on a project, using Python/Django running on a Virtual Private Server, which allows me a blank Linux server box that I can pretty much install whatever I need. The project must allow users to upload an uncompressed WAV file for others to download. These will most probably be served up using Amazon S3. I'm not expecting a mass...

How can I accomplish file uploads in twisted.web that don't suck?

I've searched and searched but can't seem to find a way to upload files to my twisted.web application in any reasonable way. Currently, posting file uploads to a resource results in a request.args['file'] variable, that is a list populated with file contents. I can't find a way to get any information about the file: mime type, filename,...

Check list of words in another string

Hello, I can do such thing in python: list = ['one', 'two', 'three'] if 'some word' in list: ... This will check if 'some word' exists in the list. But can I do reverse thing? list = ['one', 'two', 'three'] if list in 'some one long two phrase three': ... I have to check whether some words from array are in the string. I can...

Leave allowed html-tags and remove all others in text using Python

I want to add to my site ability to use some html-tags in text editor. So when user posts some text I need clean up this text - remove html-tags which are not allowed and leave allowed tags. For example, on StackOverflow: http://meta.stackoverflow.com/questions/1777/what-html-tags-are-allowed So I need some parser which has list of al...

Re-factoring To MVC pattern -Doubts on separation of view from controller

At the momement Im trying to refactor my application (with 1000+ lines of GUI code) to an MVC style pattern. The logic code is already seperate from the GUI so that is not a problem. My concern is seperation of the view from the controller. I understand the basic principal of MVC and this tutorial in the wxpython wiki has been very help...

buildout shebang python not using #!/usr/bin/env python but using #!/usr/bin/python2.6

I've a buildout.cfg to manage dependencies and create a bin/script, and then I can do an sdist and include the script in there. The problem I've got is that the script has #!/usr/bin/python2.6 instead of #!/usr/bin/env python. If I use a virtualenv then, it points to the virtualenv python runtime. I would be interested to be #!/usr/bin/e...

Can I install Python windows packages into virtualenvs?

Virtualenv is great: it lets me keep a number of distinct Python installations so that different projects' dependencies aren't all thrown together into a common pile. But if I want to install a package on Windows that's packaged as a .exe installer, how can I direct it to install into the virtualenv? For example, I have pycuda-0.94rc.w...

wxPython: Can a wx.PyControl contain a wx.Sizer?

Can a wx.PyControl contain a wx.Sizer? Note that what I am ultimately trying to do here (spinner with float values) is already answered in another question. I am particularly interested in layouting widgets within a wx.PyControl, a skill which might prove useful if I come across a need to make my own custom widgets. I already read throu...

API of a module in python. In __init__.py?

Hi I have written a python module wich consists of several .py files which contain classes and so on. I want to expose it to client using "Facade" pattern. So I don't want clients learn all internal classes but they only need methods exposed by this API interface. Question is: where do I put this api ? Have I to define a file api.py in...

In python, why is reading from an array slower than reading from list?

Hi, I'm learning python recently, and is doing many practice with the language. One thing I found interesting is that, when I read from an array, it's almost half of the time slower than list. Does somebody know why? here's my code: from timeit import Timer import array t = 10000 l = range(t) a = array.array('i', l) def LIST(): ...

Set products in Python

A product of n copies of a set S is denoted Sn. For example, {0, 1}3 is the set of all 3­-bit sequences: {0,1}3 = {(0,0,0),(0,0,1),(0,1,0),(0,1,1),(1,0,0),(1,0,1),(1,1,0),(1,1,1)} What's the simplest way to replicate this idea in Python? ...

SimpleXmlRpcServer _sock.rcv freezes after thousands of requests

Hi there, I'm serving requests from several XMLRPC clients over WAN. The thing works great for, let's say, a period of one day (sometimes two), then freezes in socket.py: data = self._sock.recv(self._rbufsize) _sock.timeout is -1, _sock.gettimeout is None There is nothing special I do in the main thread (just receiving XMLRPC calls)...