python

Role of C,C++,python,perl in Web development

Please bear with me experts i'm a newbie in web dev. With html,css can take care of webpages.. javascript,ajax for some dynamic content.. php for server side scripting,accessing databases,sending emails,doing all other stuf... What role do these programming languages play? Can they do any other important task which cannot be done by PH...

A Python script I've written for correcting table names of the SQL dumps from Windows. Any comments?

Hi, as a newbie in Python I've thought about writing a quick and dirty script for correcting the table anme caps of a MySQL dump file (by phpMyAdmin). The idea is since the correct capitalization of the table names are in the comments, I'm going to use it. e.g.: -- -------------------------------------------------------- -- -- Table ...

Accessing samba shares with gio in python

I am trying to make a simple commandline client for accessing shares via the python bindings of gio (yes, the main requirement is to use gio). I can see that comparing with it's predecessor genome-vfs, it provides some means to do authentication stuff (subclassing MountOperation), and even some methods which are quite specific to samba ...

Reading from an SSL Socket in Twisted

I'm trying to implement an SSL client in Twisted that simply must connect to a socket and read binary data (specifically, tuples of data). I've gotten the code to a point where it seems to connect and disconnect successfully but no data is ever read from the socket. class FeedbackHandler(LineReceiver): MAX_LENGTH = 1024*1024 def c...

Execute Scripts online

I'm searching for a website where I can test python scripts within a simple form (so I don't need to install python on my local machine). I know there is a site that can do it (also other script languages like javascript, php are supported...) but I forget the name. Anyone can help me? Thanks! ...

Current Subversion revision command

Is there a Subversion command to show the current revision number? After svn checkout I want to start a Python script and need the revision number in a variable. It would be great if there is a command like svn info get_revision_number. ...

python appengine form-posted utf8 file issue

hi, i am trying to form-post a sql file that consists on many INSERTS, eg. INSERT INTO `TABLE` VALUES ('abcdé', 2759); then i use re.search to parse it and extract the fields to put into my own datastore. The problem is that, although the file contains accented characters (see the e is a é), once uploaded it loses it and either error...

How does Django + mod_wsgi affect the python path?

I have a simple setup with my python libraries in /domains/somedomain.com/libs/ and all my tests run fine. I start WSGI with DJANGO_SETTINGS_MODULE to "somedomain.settings" where somedomain is a package in libs/ Suddenly, when adding pywapi.py into libs/ I can't import it when hitting the site. But, if I add 'import pywapi' to my wsgi s...

python import module to work globally

I've got a problem trying to get python to accept an import 'globally' In a module it needs to import another module depending on another variable but it doesn't seem to import it into all of the module functions if i have it in the start function; for example: def start(): selected = "web" exec("from gui import " + selected + ...

Why file writing does not happen when it is suppose to happen in the program flow?

This is not a new problem for me. From C to PERL to Python on Windows Mobile, Windows XP and other Windows versions this problem persists and f**ks my nerves. Now in my latest script it again happens. To be more concrete: I have coded in Python a trivial script. Now the script writes correctly to the file when run from the debugger, bu...

Parse xml file while a tag is missing

I try to parse an xml file. The text which is in tags is parsed successfully (or it seems so) but I want to output as the text which is not contained in some tags and the following program just ignores it. from xml.etree.ElementTree import XMLTreeBuilder class HtmlLatex: # The target object of the parser out = '...

Recompile Vim for pythoncomplete#Complete on modules *other* than standard library?

I like using pythoncomplete#Complete for Vim omnicompletion, but it doesn't work for Python modules other than the standard library. Is there a way to re-compile Vim so that this will work on non-standard library modules? I have tried pysmell, et. al., but they just don't work as well as pythoncomplete#Complete. This is for a Windows...

Optimize .png images with PIL

All i need is create a .png image with transparent background, draw some text in black on it and save it using img.save('target.png', option='optimize') It looks like to save .png images in 32-bit mode automatically. Can I reduce the color depth while not make the output images looks much worse before saving? Since it contains only blac...

python: Should I use ValueError or create my own subclass to handle invalid strings?

I've looked through python's built in exceptions and the only thing that seems close is ValueError. from python documentation: exception ValueError: Raised when a built-in operation or function receives an argument that has the right type but an inappropriate value, and the situation is not described by a more precise exception su...

how to install mysqlDb for MySQL and Python ON WINDOWS

I AM A NET DEVELOPER TRY TO INSTALL MYSQLDB FOR PYTHON I KEEP HAVING THIS ERROR MESSAGE raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb> I AM FOLLOWING THIS INSTRUCTION FROM THIS SITE <"http://sourceforge.net/project/...

SQL to calculate the Tanimoto Coefficient of several vectors

Hi, I think it's easier to explain my problem with an example. I have one table with ingredients for recipes and I have implemented a function to calculate the Tanimoto coefficient between ingredients. It's fast enough to calculate the coefficient between two ingredients (3 sql queries needed), but it does not scale well. To calculate ...

Python soap using soaplib (server) and suds (client)

This question is related to: http://stackoverflow.com/questions/1751027/python-soap-server-client In the case of soap with python, there are recommendation to use soaplib (http://wiki.github.com/jkp/soaplib) as soap server and suds (https://fedorahosted.org/suds/) as soap client. My target is to create soap services in python that can b...

Simple htaccess rules for clean URLs not showing static media

After looking at 4-5 different ways to get simple clean URLs for static files, we found one that was simple and easy to implement/maintain over multiple folder and files. One problem, it wont load the js/css/images from that folder it is looking at. Here is the rule - it loads the html ok, but not the images, etc which are in the /ima...

How do I open all files of a certain type in Python and process them?

I'm trying to figure out how to make python go through a directory full of csv files, process each of the files and spit out a text file with a trimmed list of values. In this example, I'm iterating through a CSV with lots of different types of columns but all I really want are the first name, last name, and keyword. I have a folder ful...

Python Working with lists based on indexes

I have data in a CSV file. One of the column lists a persons name and all the rows that follow in that column provide some descriptive attributes about that person until the next persons name shows up. I can tell when the row has a name or an attribute by the LTYPE column, N in that column indicates that in that row the NAME value is a...