python

python regex to get all text until a (, and get text inside brackets

I need help with 2 regex. get all text until a open bracket. e.g. this is so cool (234) => 'this is so cool' get the text inside the brackets, so the # '234' ...

Python requires a GIL. But Jython & IronPython don't. Why?

Why is it that you can run Jython and IronPython without the need for a GIL but Python (CPython) requires a GIL? ...

Determining running programs in Python

How would I use Python to determine what programs are currently running. I am on Windows. ...

Select columns of data from .txt to .csv

hi there! I am quite new to python (well more like I've only been using it for the past week). My task seems fairly simple, yet I am struggling. I have several large text files each with many columns of data in them from different regions. I would like to take the data from one text file and extract only the columns of data that I ne...

Pylons formencode - How do I POST an array of data?

I have a form that is similar to the following: Enter Name: Enter Age: [add more] That add more field copies the Name and Age inputs and can be clicked as many times as the user wants. Potentially, they could end up submitting 50 sets of Name and Age data. How can I handle this received data when it's posted to my Pylons application?...

Pythonic way to convert a list of integers into a string of comma-separated ranges

I have a list of integers which I need to parse into a string of ranges. For example: [0, 1, 2, 3] -> "0-3" [0, 1, 2, 4, 8] -> "0-2,4,8" And so on. I'm still learning more pythonic ways of handling lists, and this one is a bit difficult for me. My latest thought was to create a list of lists which keeps track of paired numbers: ...

An optional dict in the structure with MongoKit

I've got MongoKit structure like this: structure = { ... 'plugin': { 'id': unicode, 'title': unicode, 'description': unicode, ... } However, not all documents will have the plugin key. If they do, I'd like it to be validated against the structure. required_fields does not include plugin. (plugin isn't a required k...

Can I use SWF file to import in Python web application

Hey all i develop one project on python and upload on google app can i use swf file to import in python web application??? if u have any link or idea give me some suggestions please. ...

getting a list of files in a custom directory using glob()

Hi, Im trying to write a program that renames files when a use input their own custom file directory. I'm at a very early part of it. And this is my first time using the OS and glob commands. My code is below. However when I tried running that, the result was an empty list. I tried typing a file root directory into the glob command direc...

Porting Python code to run on iphone

Hi! Does anyone have any experience in porting Python code to either C++ or Objective-C? If so, can you give me some advice on docs or tutorials which my help me? The Python code I'm hoping to port is mostly non-gui and involves a lot of string manipulation, regex, and extensions of container datastructures. Speed is less important. Bas...

XML-RPC Python, Server Contact Client

Hi - I am trying to create a client-server application with XML-RPC in Python, in Ubuntu Linux. It is straightforward to have the client side request a particular service from the server side. What I am trying to do is have the client send a file to the server. The server will then process the file; this process may take a few hours. W...

Howto import a function with python

I'm developing a Python application for the GAE. The application consists of a bunch of classes and functions which are at the moment all in the same file main.py. The application is running without problems. Now, I want to refactor the application and outsource all the classes. Every class should be in her own file. The files shall ...

Automatic creation date for django model form objects?

What's the best way to set a creation date for an object automatically, and also a field that will record when the object was last updated? In my model I have: created_at = models.DateTimeField(False, True, editable=False) updated_at = models.DateTimeField(True, True, editable=False) and in my view: if request.method == 'POST': ...

How to organize Eclipse - Workspace VS Programming languages

I use Eclipse for programming in PHP (PDT), Python and sometimes Android. Each of this programming languages requires to run many things after Eclipse start. Of course I do not use all of them at one moment, I have different workspace for each of those. Is there any way, or recommendation, how to make Eclipse to run only neccessary tool...

sort date objects in Python

I start out with date strings: from operator import itemgetter import datetime as DT # unsorted dates raw = (map(int, "2010-08-01".split("-")), map(int, "2010-03-25".split("-")), map(int, "2010-07-01".split("-"))) transactions = [] for year, month, day in raw: new = (DT.date(year, month, day), "Some data here") t...

Most memory-efficient way of holding base64 data in Python?

Suppose you have a MD5 hash encoded in base64. Then each character needs only 6 bits to store each character in the resultant 22-byte string (excluding the ending '=='). Thus, each base64 md5 hash can shrink down to 6*22 = 132 bits, which requires 25% less memory space compared to the original 8*22=176 bits string. Is there any Python...

How to develop an Avahi client/server

I am trying to develop a client/server solution using python, the server must broadcast the service availability using Avahi. I am using the following code to publish the service: import avahi import dbus __all__ = ["ZeroconfService"] class ZeroconfService: """A simple class to publish a network service with zeroconf using ava...

Which graphics library?

Can someone reccommend to me a graphics library that meets the following needs: Can be used with either C# or Python The basic functionality that I need is to be able to draw lines and polylines, and to be able to fill in geometric 2d shapes with any colour. Something easy to use that doesnt require hours of reading documentation to un...

python package for distributed auction simulation

Hi, Does anyone know of a package that allows for a distributed agent-based double auction simulation? I've looked at SimPy, but that's a discrete-event simulator and difficult to get working in a distributed fashion. regs, Vivek ...

Group together arbitrary date objects that are within a time range of each other

I want to split the calendar into two-week intervals starting at 2008-May-5, or any arbitrary starting point. So I start with several date objects: import datetime as DT raw = ("2010-08-01", "2010-06-25", "2010-07-01", "2010-07-08") transactions = [(DT.datetime.strptime(datestring, "%Y-%m-%d").date(), ...