python

Bind arbitrary Python objects to CherryPy sessions

I'm using CherryPy to make a web-based frontend for SymPy that uses an asynchronous process library on the server side to allow for processing multiple requests at once without waiting for each one to complete. So as to allow for the frontend to function as expected, I am using one process for the entirety of each session. The client-s...

Uses of Jython while programming

I recently started learning Python and came accross the term Jython. From the Google search results, I thereby concluded that it is indeed a very important term. What is the experience programming/coding using Jython? ...

Changing the words keeping its meaning intact...

Hi We have a requirement in which we need to change change the words or phrases in the sentence while keeping its meaning intact. This application is going to provide suggestions to users who are involved in copy-writing. I don't know where should I start... we have not yet finalized the technology but would like to do it in a Python o...

How can I organise program, which should have non-blocking connection on Python?

My question is next: I want to write a program which should connect to the same program on the other machine, and both this program should exchange some information. I can't set up non-blocking connection. How can it be? ...

Problem using f2py

I have some routines written in fortran that I'd like to use in my python code. A quick websearch informed me about f2py, and I gave it a try. Using f2py -c numericalMethods.f -m numericalMethods it seems to work for a while until a lot of errors are spawn during the conversion. Any idea of why the following bit of code fails to work...

Transforming early modern English into 20th century spelling using the NLTK

I have a list of strings that are all early modern English words ending with 'th.' These include hath, appointeth, demandeth, etc. -- they are all conjugated for the third person singular. As part of a much larger project (using my computer to convert the Gutenberg etext of Gargantua and Pantagruel into something more like 20th century ...

Why are sets bigger than lists in python?

Why is the size of sets in Python noticeably larger than that of lists with same elements? a = set(range(10000)) b = list(range(10000)) print('set size = ', a.__sizeof__()) print('list size = ', b.__sizeof__()) output: set size = 524488 list size = 90088 ...

How can I stop Python.exe from closing immediatly after i get an output?

Hello. Im brand new with python and im just trying some basic programming. I was wondering if there was any way i could stop python.exe from closing immediatly after it completes. It closes faster than I can read the output. Is there any way to stop that? Here is the program. Width = float(input("Enter the width: ")) Height = float(input...

Python import X or from X import Y? (performance)

I'm just wondering - if there is a library from which I'm going to use at least 2 methods, is there any difference in performance or ram usage between: from X import method1, method2 and this import X I know about namespaces and stuff, but I'm just wondering if python is smart enough to know that I'll use only 2 methods. ...

Export mail from Gmail

At one point it was possible to use scripts like libgmail and gmail.py (can't post more than one hyperlink) to export mail from Gmail accounts. Both of those seem to not work anymore — I can't even log in with them. I assume it's because there's been some changes in Gmail. Is there still any way to do this? ...

how to change mac address by use python with windows xp environment

Hi All. i want to create python script which can change mac address in windows environment. i can found bunch of some info about linux environment but i couldn't found on windows environment. if anyone help me much appreciate! thanks in advance ...

Why does printer changes resolution? User, background, what?

Hi, I am runing a .bat file from a php using exec on a Windwos php server, where php is run using fast-cgi (and nginx). The command line to run this script is pclose(popen("start / ". $cmd, "r")); Where $cmd is somethign like "mybatfile.bat 45 1" When I run the batch file manually it runs a python program to read a database, ...

How to make integration test for DB at google App. engine?

Hi overflowed. I'am wondering, how to write integration tests, that involves DB interaction, for Google app engine? It's seems - no problem to run this test at Google, on "live" db, using GAEUnit SO Thread But, this seems bad practice to me, because it's live environment. Google has provided examples of such tests, for java, but not fo...

How to filter a numpy.ndarray by date?

I have a 2d numpy.array, where the first column contains datetime.datetime objects, and the second column integers: A = array([[2002-03-14 19:57:38, 197], [2002-03-17 16:31:33, 237], [2002-03-17 16:47:18, 238], [2002-03-17 18:29:31, 239], [2002-03-17 20:10:11, 240], [2002-03-18 16:18:08, 252], [...

Change console font in Windows

Is there a way to change the console font in Windows in python 2.6? I'm on Windows 7. ie: import os os.console.font = 'Lucida Console' *EDIT (posted this an answer by accident) Some more information and questions: I looked into the windows API: http://msdn.microsoft.com/en-us/library/ms682073%28v=VS.85%29.aspx It look like it ha...

Python invalid syntax

lastPosition = GPS.getActualPosition() I m trying to compile a code which is about sending sms through telit module. above statement is giving an error. I couldn't understand, GPS library is in the place where it's supposed to be and I imported it. import SER import MOD import MDM import GPS syntaxError: invalid syntax http://foru...

Output of proc.communicate() does not format newlines in django python

I have a subprocess using communicate to get the output ans saving it to my database: p = Popen([str(pre_sync), '-avu', str(src), str(dest)], stdout=PIPE) syncoutput = p.communicate() check.log = syncoutput It all works fine, but the output from communicate looks like this: ('sending incremental file list\n\nsent 89 bytes rece...

Reading input from remote control device on macs

How could I read input from a remote control device on a mac (iMac, Mac Mini, etc.) and handle actions based on differently pressed buttons in python? I would like to map the button-press events to my custom app instead of "Front Row". What actions should I take to do that and what python libraries to use to handle the events? ...

Parsing HTML easily like PyQuery in Python 2.5

I am writing an app for GAE (Python 2.5) and I was wondering if there is any library like PyQuery (which runs on Python 2.6+). All I have to do is to load an HTML file and get the content of a especific tag through its ID. In PyQuery, or even Python2.6's libraries like lxml, it is very easy, but I don't know how to do that with Python 2...

Porting a threaded C program to Python

As an exercise, I would like to port some of the functionality of a threaded C program (using pthreads) to Python. The C program spawns a thread to (almost) constantly iterate through certain directories, filling a data structure with their contents; these directories change crazy frequently (it's a mail queue). The main body of the ...