python

Which language is easiest and fastest to work with XML content?

We have developers with knowledge of these languages - Ruby , Python, .Net or Java. We are developing an application which will mainly handle XML documents. Most of the work is to convert predefined XML files into database tables, providing mapping between XML documents through database, creating reports from database etc. Which language...

How to convert a date in python?

I've got this: post["date"] = "2007-07-18 10:03:19" And from post["date"], I'd like to extract just "2007-07-18". I've seen some reference to strptime without being sure how to use it I'm not really familiar with python, just 1-2 scripts a year, so the solution might be obvious for a lot of you :) ...

How to update turbogears application production database.

Hi, I am having a postgres production database in production (which contains a lot of Data). now I need to modify the model of the tg-app to add couple of new tables to the database. How do i do this? I am using sqlAlchemy. ...

Python: urllib/urllib2/httplib confusion

I'm trying to test the functionality of a web app by scripting a login sequence in Python, but I'm having some troubles. Here's what I need to do: Do a POST with a few parameters and headers. Follow a redirect Retrieve the HTML body. Now, I'm relatively new to python, but the two things I've tested so far haven't worked. First I use...

Global hotkey for Python application in Gnome

I would like to assign a global hotkey to my Python application, running in Gnome. How do I do that? All I can find are two year old posts saying, well, pretty much nothing :-) ...

Setting up paths: .pth or sys.path

Hello, I have a verification project of which Python is only a part. The project's structure is: root/ vhdl/ synthesis/ tb/ some_tb1/ svn_code/ vhdl/ python_lib/ generic_svn is a Subversion 'externals' directory holding common code. I have several scripts in tb/some_tb1 that want to use modules from svn_code/pyt...

What is the best book for learning about Algorithms?

I know what algorithms are, but I have never consciously used or created one for any of the programming that I have done. So I'd like to get a book about the subject - I'd prefer if it was in python but that's not a strict requirement. What book about algorithms helped you most to understand, use, and create algorithms? One book per a...

Calculate exact result of complex throw of two D30

Okay, this bugged me for several years, now. If you sucked in statistics and higher math at school, turn away, now. Too late. Okay. Take a deep breath. Here are the rules. Take two thirty sided dice (yes, they do exist) and roll them simultaneously. Add the two numbers If both dice show <= 5 or >= 26, throw again and add the result to...

Embedded Web Server in Python ?

Can you recommend a minimalistic python webserver that I can embedded in my Desktop Application. ...

Use only some parts of Django?

I like Django, but for a particular application I would like to use only parts of it, but I'm not familiar enough with how Django works on the inside, so maybe someone can point me into the right direction as to what I have to check out. Specifically, I want to use: The models and database abstraction The caching API, although I want ...

Running a Django site under mod_wsgi

I am trying to run my Django sites with mod_wsgi instead of mod_python (RHEL 5). I tried this with all my sites, but get the same problem. I configured it the standard way everyone recommends, but requests to the site simply time out. Apache conf: <VirtualHost 74.54.144.34> DocumentRoot /wwwclients/thymeandagain ServerName thym...

How does Python handle classes being in separate files or are they all supposed to be in one file

I'm working on framework for testing some command line utilities. I want to create some classes to hold the different types of information more easily. Python is fairly new to me so I'm not sure how you would handle this. Do you keep all your classes in one file with your main script or can you separate them into their own files and ...

scons : src and include dirs

can someone give a scons config file which allows the following structure toplevel/ /src - .cc files /include .h files at top level I want the o and final exe. ...

How do I install a Python extension module using distutils?

I'm working on a Python package named "lehmer" that includes a bunch of extension modules written in C. Currently, I have a single extension module, "rng". I am using Python's Distutils to build and install the module. I can compile and install the module, but when I try to import the module using import lehmer.rng or from lehmer import ...

Best Django 'CMS' component for integration into existing site.

So I have a relatively large (enough code that it would be easier to write this CMS component from scratch than to rewrite the app to fit into a CMS) webapp that I want to add basic Page/Menu/Media management too, I've seen several Django pluggables addressing this issue, but many seem targeted as full CMS platforms. Does anyone know o...

How do I remove/delete a folder that is not empty with Python?

I am getting an 'access is denied' error when I attempt to delete a folder that is not empty. I used the following command in my attempt: os.remove("/folder_name"). What is the most effective way of removing/deleting a folder/directory that is not empty? Thanks in advance. ...

Is there a better StringCollection editor for use in PropertyGrids?

I'm making heavy use of PropertySheets in my application framework's configuration editor. I like them a lot because it's pretty easy to work with them (once you learn how) and make the editing bulletproof. One of the things that I'm storing in my configuration are Python scripts. It's possible to edit a Python script in a StringColle...

Newbie Python Question about tuples

I am new to Python, and I'm working on writing some database code using the cx_Oracle module. In the cx_Oracle documentation they have a code example like this: import sys import cx_Oracle connection = cx_Oracle.Connection("user/pw@tns") cursor = connection.cursor() try: cursor.execute("select 1 / 0 from dual") except cx_Oracle.D...

(Python) socket.gaierror on every addres...except http://www.reddit.com?

I'm just playing around and I'm trying to grab information from websites. Unfortunately, with the following code: import sys import socket import re from urlparse import urlsplit url = urlsplit(sys.argv[1]) sock = socket.socket() sock.connect((url[0] + '://' + url[1],80)) path = url[2] if not path: path = '/' print path sock.sen...

emacs 23 and iPython

Is there anyone out there using iPython with emacs 23? The documents on the emacs wiki are a bit of a muddle and I would be interested in hearing from anyone using emacs for Python development. Do you use the download python-mode and ipython.el? What do you recommend? ...