python

geodjango - search by city, state or zip code

How can I use geodjango to search by city and state or zip code in my django application? I am very new to geodjango and just trying to wrap my head around what would be involved in this. Also, does anyone know of an app that already implements this functionality? ...

os.listdir etc fails on shared windows path (Python 2.5)

Hi, I am seeing some weird behavior while parsing shared paths (shared paths on server, e.g. \storage\Builds) I am reading text file which contains directory paths which I want to process further. In order to do so I do as below: def toWin(path): return path.replace("\\", "\\\\") for line in open(fileName): l = toWin(line).st...

architecture of chat website using twisted matrix

I am willing to devlop a anonymus chat website.The website pairs 2 random people who are logged into the website and then allows them to chat to each other.Now if any one of them gets disconnected then the other will get connected to any other person who is single. Now i have some doubts regarding archicture. Each time there is a messa...

Find new messages added to an imap mailbox since I last checked with python libimap2?

I am trying to write a program that monitors an IMAP mailbox and automatically copies every new incoming message into an "Archive" folder. I'm using imaplib2 which implements the IDLE command. Here's my basic program: M = imaplib2.IMAP4("mail.me.com") M.login(username,password) lst = M.list() assert lst[0]=='OK' for mbx in lst[1]: p...

Easy way of getting started programming using python

Background I'm trying to learn to program a little & python seems like a good choice for my purpose. I have no ambition of ever being a serious programmer.I already know bits and pieces of html, css, javascript (mostly how to cut & paste without understanding what I'm doing). The last time I actually "learned programming" was about ten y...

What is/are the Python equivalent(s) to the Java Collections Framework?

The Java Collections Framework is like the C++ Standard Template Library: "a unified architecture for representing and manipulating collections (objects that group multiple elements into a single unit)." http://java.sun.com/docs/books/tutorial/collections/intro/index.html ...

How to use Python to get local admins from a computer on the Network?

Hi, I need to get a list of all people in the company who have local admin rights on their computers. We have a group on each machine called "Administrators." I can get a list of all computers from active directory with: import active_directory for computer in active_directory.search ("objectCategory='Computer'"): print computer.dis...

Unit testing file write in Python

I am writing a wrapper for the ConfigParser in Python to provide an easy interface for storing and retrieving application settings. The wrapper has two methods, read and write, and a set of properties for the different application settings. The write method is just a wrapper for the ConfigParser's write method with the addition of also...

Dithering in text using PIL and truetype fonts

Consider the following code: from PIL import Image, ImageDraw, ImageFont def addText(img, lTxt): FONT_SIZE = 10 INTERLINE_DISTANCE = FONT_SIZE + 1 font = ImageFont.truetype('arial.ttf', FONT_SIZE) lTxtImageHeight = INTERLINE_DISTANCE * len(lTxt) # create text image lTxtImg = Image.new('RGBA', (img.size[1], l...

Is it possible to store Python class objects in SQLite?

I would like to store Python objects into a SQLite database. Is that possible? If so what would be some links / examples for it? ...

How to plot a graph in Python?

I am new to python. I have installed Matplotlib. I have created 2 lists x and y. I want X axis to have values from 0 to 100 in steps of 10 and Y axis to have values from 0 to 1 in steps of 0.1. How do I plot this graph? ...

Sql Alchemy What is wrong?

I got the tutorial http://www.rmunn.com/sqlalchemy-tutorial/tutorial.html When I compile got the error message The debugged program raised the exception unhandled NameError "name 'BoundMetaData' is not defined" I am use the latest sqlAlchemy . How Could I fixed this? After read this I modified to my own for latest version sqlA...

PyQt4 signals and slots

Hello, I am writing my first Python app with PyQt4. I have a MainWindow and a Dialog class, which is a part of MainWindow class: self.loginDialog = LoginDialog(); I use slots and signals. Here's a connection made in MainWindow: QtCore.QObject.connect(self.loginDialog, QtCore.SIGNAL("aa(str)"), self.login) And I try to emit signal ...

if there any better way to read bb function souce code.i was very faint .

in python ,if a.py from b import bb bb() b.py from c import cc def bb(): do someting else cc() c.py from d import dd def cc(): do someting else dd() d.py from e import ee def dd(): do someting else ee() e.py from f import ff def ee(): do someting else ff() to Understood bb function,i must open 5 file,i was very f...

Error when using astWCS trying to create WCS object

I'm running python2.5 and trying to use the astLib library to analyse WCS information in astronomical images. I try and get the object instanciated with the following skeleton code: from astLib import astWCS w = astWCS.WCS('file.fits') # error here where file.fits is a string pointing to a valid fits file. I have tried using the al...

Can I ask for screenshot of some great personalized IDE for python?

How to setup a Linux/Unix machine for python development? Which Linux/Unix version should I use? What IDE should be used? What development plugins should I have? What code style should would be THE BEST? All above, a great development machine for open source (python developers) development? Can i ask for screenshot of some great persona...

Why does this Python code print nothing?

class a(str): def b(self,*x,**y): print str.decode(self,*x,**y) b=a() b.b('utf-8','aaa') # This prints nothing, why? ...

Displaying a cvMatrix containing complex numbers (CV_64FC2)

Hi, I'm new to OpenCV, and I would like to compare the results of a python program with my calculations in OpenCV. My matrix contains complex numbers since its the result of a cvDFT. Python handles complex numbers well and displays it with scientific notation. My C++ program is not effective when trying to use std::cout. I tried to sto...

Search and sort data from several files

Hi, I have a set of 1000 text files with names in_s1.txt, in_s2.txt and so. Each file contains millions of rows and each row has 7 columns like: ccc245 1 4 5 5 3 -12.3 For me the most important is the values from the first and seventh columns; the pairs ccc245 , -12.3 What I need to do is to find between all the in_sXXXX.txt files, ...

Writing copyright information in python code

What is the standard way of writing "copyright information" in python code? Should it be inside docstring or in block comments? Sorry to bother if it is trivial, as I could not find it in PEPs. ...