python

Web application architecture, and application servers?

Hi, I'm building a web application, and I need to use an architecture that allows me to run it on two servers. The application scrapes information from other sites periodically, and on input from the end user. To do this I'm using Php+curl to scrape the information, Php or python to parse it and store the results in a MySQLDB. Then...

Windows can't find the file on subprocess.call()

I am getting the following error: WindowsError: [Error 2] The system cannot find the file specified My code is: subprocess.call(["<<executable file found in PATH>>"]) Windows 7, 64 bit. Python 3.x latest, stable. Any ideas? Thanks, ...

MySQL Module for Python

What is a good, and easy to install MySQL module for Python? Especially for Mac OS X (in terms of installation)? ...

What's a better choice for SQL-backed number crunching - Ruby 1.9, Python 2, Python 3, or PHP 5.3?

Criteria for 'better': fast in math and simple (few fields, many records) db transactions, convenient to develop/read/extend, flexible, connectible. The task is to use a common web development scripting language to process and calculate long time series and multidimensional surfaces (mostly selecting/inserting sets of floats and doing m...

how to store password on gae when someone register.

ex: username:zjm1126 password:11 i stored the password to the datastore on gae, when i see the data view at /_ah/admin, i can see the password all people's password who register, i think it is not safe , yes ? is password stroed like this ? how to stored password, thanks and the check_password method is : user=MyUser.get_by...

How to process user supplied formulas?

Hi, I have a dictionary containing a set of key values available through a web application: I want to process user supplied formulas like: ((value1+value3)/value4)*100 What would be the easiest way to get the formula calculated matching values with ones from the dictionary? Consider this example: #!/usr/bin/python values={'value1':10...

Python equivalent of C++ getline()

In C++ we can enter multiple lines by giving our own choice of delimiting character in the getline() function.. however I am not able to do the same in Python!! it has only raw_input() and sys.stdin.readline() methods that read till I press enter. Is there any way to customize this so that I can specify my own delimiter? ...

Python Application in right click menu of OS X

Hi All, I know that there is the PyObjC bridge is OSX and what I want to do is to put a python application/script in the rightclick context menu of OS X. there is the OnMyCommand plugin but I dont think that supports python. I've had a look at how to do it in Carbon/ Objective-C and i'll admit it im a wuss and am just not smart enough y...

Passing around an ElementTree

Hello. In my program, I need to make use of an ElementTree object in various functions in my program. More specifically, I am doing this: tree = etree.parse('somefile.xml') I am passing this tree around in my program. I was wondering whether this is a good approach, or can I do this: Create a global tree (I come from a C++ backg...

Python win32com - Automating Word - How to replace text in a text box?

I'm trying to automate word to replace text in a word document using Python. (I'm on word 2003 if that matters and Python 2.4) The first part of my replace method below works on everything except text in text boxes. The text just doesn't get selected. I notice when I go into Word manually and hit ctrl-A all of the text gets selected ...

Test assertions for tuples with floats

I have a function that returns a tuple that, among others, contains a float value. Usually I use assertAlmostEquals to compare those, but this does not work with tuples. Also, the tuple contains other data-types as well. Currently I am asserting every element of the tuple individually, but that gets too much for a list of such tuples. Is...

How to extract a windows cabinet file in python

Is it somehow possible to extract .cab files in python? ...

How to create temporary files in memory visible for other process, using python

Hello! I'm trying to write simple batch file generator in python. Batch file consist of about 30-50 lines of text and is passed to other applications. During the execution of script there a lot of calls to external applications. I want to create file in memory (like named pipes in win32). Is there any platform-independent way? UPD: Tha...

How to define multi-argument decorators within a class in 2.6

Generally don't do OO-programming in Python. This project requires it and am running into a bit of trouble. Here's my scratch code for attempting to figure out where it went wrong: class trial(object): def output( func, x ): def ya( self, y ): return func( self, x ) + y return ya def f1( func ): ...

How can I check if an object is an iterator in Python?

I can try if it has a next() method or something like that. Is there a standard way? ...

How to list all the objects with a specific date no matter the time in a DateTime Field

I Have a model like this foo=models.char bar=models.dateime In wich several foos arrives in one day in different time. I need to list all the foos in a specific date, no matter the time they arrive. I can't change the model, so splitting the bar in two fields(one for date and one for time) is out of reach right now :( ...

Printing Unicode in eclipse Pydev console and in Idle

My configuration: Win7 + Python 2.6 + eclipse + PyDev How do I enable Unicode print statements in: PyDev console in eclipse Idle Python GUI Example print statement: print(u"שלום עולם") This comes out as: ùìåí òåìí ...

How to expire session due to inactivity in Django?

Our Django application has the following session management requirements. Sessions expire when the user closes the browser. Sessions expire after a period of inactivity. Detect when a session expires due to inactivity and display appropriate message to the user. Warn users of a impending session expiry a few minutes before the end of t...

How to merge or copy anonymous session data into user data when user logs in?

This is a general question, or perhaps a request for pointers to other open source projects to look at: I'm wondering how people merge an anonymous user's session data into the authenticated user data when a user logs in. For example, someone is browsing around your websites saving various items as favourites. He's not logged in, so the...

Search for a String and replace it with a variable

Hello, I am trying to use regular expression to search a document fo a UUID number and replace the end of it with a new number. The code I have so far is: read_file = open('test.txt', 'r+') write_file = open('test.txt', 'w') r = re.compile(r'(self.uid\s*=\s*5EFF837F-EFC2-4c32-A3D4\s*)(\S+)') for l in read_file: m1 = r.match(l) ...