python

pyExcelerator or xlrd - How to FIND/SEARCH a row for the given few column data?

Python communicating with EXCEL... i need to find a way so that I can find/search a row for given column datas. Now, i m scanning entire rows one by one... It would be useful, If there is some functions like FIND/SEARCH/REPLACE .... I dont see these features in pyExcelerator or xlrd modules.. I dont want to use win32com modules! it makes...

problem opening a text document - unicode error

hello, i have probably rather simple question. however, i am just starting to use python and it just drives me crazy. i am following the instructions of a book and would like to open a simple text file. the code i am using: import sys try: d = open("p0901aus.txt" , "W") except: print("Unsucessfull") sys.exit(0) i am either getting...

smtplib and gmail - python script problems

Here's my script: #!/usr/bin/python import smtplib msg = 'Hello world.' server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587 server.ehlo() server.starttls() server.ehlo() server.login('[email protected]','mypass') server.sendmail('[email protected]','[email protected]',msg) server.close() I'm just trying to send an email ...

Accepting email address as username in Django

Is there a good way to do this in django without rolling my own authentication system? I want the username to be the user's email address instead of them creating a username. Please advise, thank you. ...

Identifying the types of all variables in a C project

I am trying to write a program to check that some C source code conforms to a variable naming convention. In order to do this, I need to analyse the source code and identify the type of all the local and global variables. The end result will almost certainly be a python program, but the tool to analyse the code could either be a python...

How to center a GNOME pop-up notification?

To display a GNOME pop-up notification at (200,400) on the screen (using Python): import pynotify n = pynotify.Notification("This is my title", "This is my description") n.set_hint('x', 200) n.set_hint('y', 400) n.show() I'm a gtk noob. How can I make this Notification show up centered on the screen, or at the bottom-center of the s...

Generating unique and opaque user IDs in Google App Engine

I'm working on an application that lets registered users create or upload content, and allows anonymous users to view that content and browse registered users' pages to find that content - this is very similar to how a site like Flickr, for example, allows people to browse its users' pages. To do this, I need a way to identify the user ...

regex for parsing SQL statements

I've got an IronPython script that executes a bunch of SQL statements against a SQL Server database. the statements are large strings that actually contain multiple statements, separated by the "GO" keyword. That works when they're run from sql management studio and some other tools, but not in ADO. So I split up the strings using the...

How to upload a pristine Python package to PyPI?

What's the magic "python setup.py some_incantation_here" command to upload a package to PyPI, in a form that can be downloaded to get the original package in its original form? I have a package with some source and a few image files (as package_data). If I do "setup.py sdist register upload", the .tar.gz has the image files excluded. ...

Python Multiprocessing: Sending data to a process

I have subclassed Process like so: class EdgeRenderer(Process): def __init__(self,starter,*args,**kwargs): Process.__init__(self,*args,**kwargs) self.starter=starter Then I define a run method which uses self.starter. That starter object is of a class State that I define. Is it okay that I do this? What happens t...

Python Access Data in Package Subdirectory

I am writing a python package with modules that need to open data files in a ./data/ subdirectory. Write now I have the paths to the files hardcoded into my classes and functions. I would like to write more robust code that can access the subdirectory regardless of where it is installed on the user's system. I've tried a variety of met...

Using Gecko/Firefox or Webkit got HTML parsing in python

I am using BeautifulSoup and urllib2 for downloading HTML pages and parsing them. Problem is with mis formed HTML pages. Though BeautifulSoup is good at handling mis formed HTML still its not as good as Firefox. Considering that Firefox or Webkit are more updated and resilient at handling HTML I think its ideal to use them to construct ...

Stop python from closing on error

In python when running scripts is there a way to stop the console window from closing after spitting out the traceback? ...

What to write into log file?

My question is simple: what to write into a log. Are there any conventions? What do I have to put in? Since my app has to be released, I'd like to have friendly logs, which could be read by most people without asking what it is. I already have some ideas, like a timestamp, a unique identifier for each function/method, etc.. I'd like to...

how get last number in range in python

there is a way to get the last number in range i need to get the last number in fibonacci sequence for first 20 terms or can to do with a list instead range? ...

Installing bitarray in Python 2.6 on Windows

I would like to install bitarray in Windows running python 2.6. I have mingw32 installed, and I have C:\Python26\Lib\distutils\distutils.cfg set to: [build] compiler = mingw32 If I type, in a cmd.exe window: C:\Documents and Settings\john\My Documents\bitarray-0.3.5>python setup.py install I get: [normal python messages skipped] ...

How do I create collision detections for my bouncing balls?

I have coded an animation (in python) for three beach balls to bounce around a screen. I now wish to have them all collide and be able to bounce off each other. I would really appreciate any help that can be offered. import pygame import random import sys class Ball: def __init__(self,X,Y): self.velocity = [1,1] s...

Unescape Python Strings From HTTP

I've got a string from an HTTP header, but it's been escaped.. what function can I use to unescape it? myemail%40gmail.com -> [email protected] Would urllib.unquote() be the way to go? ...

Convert a number to a list of integers

How do I write the magic function below? >>> num = 123 >>> lst = magic(num) >>> >>> print lst, type(lst) [1, 2, 3], <type 'list'> ...

How to automatically reload a python file when it is changed

Hi guys, If I make some changes to one of the files belonging to a running app, is there a way to tell the python runtime to automatically reload the module/file? Cheers Naren ...