python

python readline license horror. How to really be free ?

I love the GPL as much as the next guy, but it should help to share code, not prevent to do it. I am currently in a situation where I have to provide a python free from GNU readline, which is GPL, otherwise it would turn all my python GPL, something I don't want (I'm going BSD here). I tried to look around for both mac and linux. On mac...

what functional tools remain in Python 3k?

I have have read several entries regarding dropping several functional functions from future python, including map and reduce. What is the official policy regarding functional extensions? is lambda function going to stay? ...

Python OLE2 date format conversion

Hello all, I have created a python script which pulls data out of OLE streams in Word documents, but am having trouble converting the OLE2-formatted timestamp to something more human-readable :( The timestamp which is pulled out is 12760233021 but I cannot for the life of me convert this to a date like 12 Mar 2007 or similar. Any help...

What are these errors and how do I handle them?

I am using this simple code for l in bios: OpenThisLink = url + l response = urllib2.urlopen(OpenThisLink) to open about 200 urls and search them with regex (and BeautifulSoup), but after a dozen or so I get these errors and IDLE quits. What do they mean? How can I handle them? Thank you. Traceback (most recent call last): ...

Format Python List to SQL script ?

I have a list need to be format it to SQL scripte list = [['11', ' 0', " 'MMB'", " '2 MB INTERNATIONAL'", ' NULL', ' NULL', ' 0\n'], ['12', ' 0', " '3D STRUCTURES'", " '3D STRUCTURES'", ' NULL', ' NULL', ' 0\n'], ['13', ' 0', " '2 STRUCTURES'", " '2D STRUCTURES'", ' NULL', ' NULL', ' 0\n'], To sql script like this: I...

SQLAlchemy not returning selected data

I'm using SQLAlchemy as the ORM within an application i've been building for some time. So far, it's been quite a painless ORM to implement and use, however, a recent feature I'm working on requires a persistent & distributed queue (list & worker) style implementation, which I've built in MySQL and Python. It's all worked quite well un...

Django-Use of unicode

Why is a unicode function is required in models.py? i.e, def __unicode__(self) return sumid; ...

python logging in django

Hi, I am using the basic python logger in django and it seems to be workng well. I have the logging setup in my setting.py as; logging.baseConfig(level = logging.NOTSET, format='a format', datemt=' a datefmt', filename='path to log', filemod...

Python unicode: how to test against unicode string

I have a script like this: #!/Python26/ # -*- coding: utf-8 -*- import sys import xlrd import xlwt argset = set(sys.argv[1:]) #----------- import ---------------- wb = xlrd.open_workbook("excelfile.xls") #----------- script ---------------- #Get the first sheet either by name sh = wb.sheet_by_name(u'Data') hlo = [] for i in range(...

python 2.3 regex problem

how do i set the regular expressions flags like multiline and ignorecase in python 2.3? in python 2.6 its like this re.findall(pattern,string, re.multiline | re.ignorecase) but this doesn't seem to wok for python 2.3, any ideas? pointers appreciated edit: sorry, it was python 2.3 not 2.4 ...

setuptools test hides import errors. How to have better info ?

In python setuptools, python setup.py test runs the testsuite. However if I have an import error in my testsuite, the only error message I obtain is an AttributeError complaining that my test class is missing. Is there a way to obtain a more detailed error message, so I can fix the testsuite ? I will explain myself better with the follo...

cat filename.* > Datei

I'm looking to translate the unix-command $ cat filename.* > Datei into a Python program. Can somebody help ? ...

Creating new list with values from two prior lists.

Given the lists list1 and list2 that are of the same length, create a new list consisting of the last element of list1 followed by the last element of list2 , followed by the second to last element of list1 , followed by the second to last element of list2 , and so on (in other words the new list should consist of alternating eleme...

Python subprocess

hey, I try to call a process via python with severals arguments. executing the *.bat itself works fine for me but transfering it into python makes me scream. Here the bat file: "C:\Program Files\bin\cspybat" "C:\Program Files\bin\armproc.dll" "C:\Program Files\bin\armjlink.dll" "C:\Documents and Settings\USER\Desktop\CAL\testing\Verific...

Close and open a new browser in Selenium

Hey guys, I'm writting a script which needs the browser that selinium is operating to close and re-open, without loosing his cookies. any idea of how to go about it? Basically it's a check to see that if the user opens and closes his browser, his cookies stay intact. ...

Image comparison algorithm

I'm trying to compare images to each other to find out whether they are different. First I tried to make a Pearson correleation of the RGB values, which works also quite good unless the pictures are a litte bit shifted. So if a have a 100% identical images but one is a little bit moved, I get a bad correlation value. Any suggestions for...

Introduction to Python

Possible Duplicate: Python tutorial for total beginners? Hi I am new in the forum and would like to have advices concerning books to learn Python. Thanks in advance. Mamane ...

Sharing utilities modules across python projects.

Hi, What would be the best directory structure strategy to share a utilities module across my python projects? As the common modules would be updated with new functions I would not want to put them in the python install directory. project1/ project2/ sharedUtils/ From project1 I can not use "import ..\sharedUtils", is there any other...

Are there functions in Python?

Or is everything a method? Since everything is an object, a def whatever: is just a method of that file.py, right? ...

Cannot make cProfile work in IPython

I'm missing something very basic. class C: def __init__(self): self.N = 100 pass def f(self, param): print 'C.f -- param' for k in xrange(param): for i in xrange(self.N): for j in xrange(self.N): a = float(i)/(1+float(j)) + float(i/self.N) ** float...