Re: [Tutor] PDF and Python

2004-12-09 Thread Alan Gauld
> Hey there. Does anyone know of a way to output PDFs with python? I have some > data that I have processed from a series of textfiles that I would like to > provide PDF format reports for.. I can't recall what its called but a couple of years ago I found a module on the Parnassus site for proces

Re: [Tutor] Capturing Logfile data in Windows

2004-12-09 Thread Guillermo Fernandez Castellanos
Hi, If you want an easy way of iterating over stdin, you may be interested in using this module: http://www.python.org/dev/doc/devel/lib/module-fileinput.html I've used it with some of my scripts to do something similar. It will not work for a growing file though... Otherwise, you can always tr

Re: [Tutor] PDF and Python

2004-12-09 Thread Kent Johnson
The reportlab toolkit is frequently recommended, though I haven't tried it myself. http://www.reportlab.org/ Kent Jason Child wrote: Hey there. Does anyone know of a way to output PDFs with python? I have some data that I have processed from a series of textfiles that I would like to provide PDF f

Re: [Tutor] Problem with python2.4.

2004-12-09 Thread Jeff Shannon
Orri Ganel wrote: On Thu, 9 Dec 2004 19:31:22 -0500, Jacob S. <[EMAIL PROTECTED]> wrote: [...] It appears as though pythonw.exe is not working properly in the python 2.4 distribution. I had a similar problem with some of the early versions of 2.4 (beta, release candidate), and it seems to me, lo

Re: [Tutor] Problem with python2.4.

2004-12-09 Thread Danny Yoo
On Thu, 9 Dec 2004, Jacob S. wrote: > Nothing I can do can fix my problem. It appears as though > pythonw.exe is not working properly in the python 2.4 distribution. [some text cut] > The symptoms: I click on edit with > idle--which runs the command "C:\python24\pythonw.exe" > "C:\python

[Tutor] test

2004-12-09 Thread Jason Child
test Jason Christopher Child Computer Network Services Professionals Tech Support 505-986-1669 1-877-321-9165 [EMAIL PROTECTED] VOZ Online VOIP Install Tech 505-428-7500 1-877-428-7550 ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/m

Re: [Tutor] MemoryError

2004-12-09 Thread Kent Johnson
Liam, Here's a nifty re trick for you. The sub() method can take a function as the replacement parameter. Instead of replacing with a fixed string, the function is called with the match object. Whatever string the function returns, is substituted for the match. So you can simplify your code a bit

[Tutor] PDF and Python

2004-12-09 Thread Jason Child
Hey there. Does anyone know of a way to output PDFs with python? I have some data that I have processed from a series of textfiles that I would like to provide PDF format reports for.. Jason Christopher Child Computer Network Services Professionals Tech Support 505-986-1669 1-877-321-9165 [EMAIL

Re: [Tutor] Problem with python2.4.

2004-12-09 Thread Orri Ganel
On Thu, 9 Dec 2004 19:31:22 -0500, Jacob S. <[EMAIL PROTECTED]> wrote: > Hi all. > > Nothing I can do can fix my problem. It appears as though pythonw.exe is > not working properly in the python 2.4 distribution. I have tried numerous > things to try and fix it. The only way I can run Tk scrip

[Tutor] Problem with python2.4.

2004-12-09 Thread Jacob S.
Hi all. Nothing I can do can fix my problem. It appears as though pythonw.exe is not working properly in the python 2.4 distribution. I have tried numerous things to try and fix it. The only way I can run Tk scripts and the like is to use the pythonw.exe from the 2.3 distribution. This include

Re: [Tutor] Capturing Logfile data in Windows

2004-12-09 Thread Alan Gauld
> I have a closed-source application which creates log files. I'd like to > capture this logfile data as it is crated, and do clever things with it! > > Is this possible? I guess it must be, because there are "tail" type > utilities for Windows... Depends on whether the output goes to stdout or st

Re: [Tutor] Difference between for i in range(len(object)) andfor i in object

2004-12-09 Thread Alan Gauld
> Personally I am getting weary of a lot of requests that to me seem to come > from a lack of understanding of Python.. To be fair that is what the tutor list is for - learning Python. > Would you be willing to take a good tutorial so you understand > basic Python concepts and apply them to your

Re: [Tutor] Difference between for i in range(len(object)) and for i inobject

2004-12-09 Thread Alan Gauld
> Here is my code: > >>> spot_cor=[] > >>> for m in cor: > ... cols = split(cor,'\t') You are splitting the list not the item cols = split(m, '\t') Better to use a meaningful name too: for line in cor: would probably have made the mistake more obvious. > However, when I trie

Re: [Tutor] Lock down windows with python+usb

2004-12-09 Thread Chad Crabtree
Asif Iqbal wrote: >Hi All > >Has anyone done any script like this? Use a python script for Windows XP >that will continuosly check if my USB is plugged in. So if I unplug my >USB flashdrive it will fork a screensaver with password lock. > >Thanks for any idea/suggestion > > > You could make scre

Re: [Tutor] Capturing Logfile data in Windows

2004-12-09 Thread Liam Clarke
You could have something along the lines of - import os.path import time curTime = os.path.getmtime('log.txt') #Or whatever it's called. while 1: #or some other loop time.sleep(10) #Check logfile every ten seconds. if os.path.getmtime('log.txt') != curTime: curTime = os.path.get

Re: [Tutor] MemoryError

2004-12-09 Thread Liam Clarke
Hi all, Yeah, I should've written this in functions from the get go, but I thought it would be a simple script. :/ I'll come back to that script when I've had some sleep, my son was recently born and it's amazing how dramatically lack of sleep affects my acuity. But, I want to figure out what's

Re: [Tutor] sorting a list of dictionaries

2004-12-09 Thread Larry Holish
On Thu, Dec 09, 2004 at 03:22:29PM -0500, Kent Johnson wrote: > Using sort() with a user compare function is not recommended when you > care about performance. The problem is that the sort function has to > call back into Python code for every compare, of which there are many. > The decorate - sort

Re: [Tutor] Removing/Handing large blocks of text

2004-12-09 Thread Jesse Noller
On Wed, 8 Dec 2004 15:11:55 +, Max Noel <[EMAIL PROTECTED]> wrote: > > > > On Dec 8, 2004, at 14:42, Jesse Noller wrote: > > > Hello, > > > > I'm trying to do some text processing with python on a farily large > > text file (actually, XML, but I am handling it as plaintext as all I > > need

Re: [Tutor] sorting a list of dictionaries

2004-12-09 Thread Kent Johnson
Using sort() with a user compare function is not recommended when you care about performance. The problem is that the sort function has to call back into Python code for every compare, of which there are many. The decorate - sort - undecorate idiom is the preferred way to do this in Python < 2.4

Re: [Tutor] Difference between for i in range(len(object)) and for i in object

2004-12-09 Thread Jeff Shannon
kumar s wrote: > Here is my code: spot_cor=[] Create an empty list... for m in cor: Now, for each element in some other list from somewhere else, ... cols = split(cor,'\t') Ignore the element we've just isolated and try to split the entire list on '\t' ... Traceback (most recent call last):

Re: [Tutor] MemoryError

2004-12-09 Thread Jeff Shannon
Liam Clarke wrote: So, I'm going to throw caution to the wind, and try an re approach. It can't be any more unwieldy and ugly than what I've got going at the moment. If you're going to try a new approach, I'd strongly suggest using a proper html/xml parser instead of re's. You'll almost certainly

Re: [Tutor] Please help matching elements from two lists and printing them

2004-12-09 Thread Jeff Shannon
kumar s wrote: On top of this this process is VERY SLOW on high end server too. That's because, for each line in spot_cor, you're examining every item in spot_int, and if there's a match, you examine every element in spot_int again! If I'm remembering my big-O notation correctly, that makes th

Re: [Tutor] sorting a list of dictionaries

2004-12-09 Thread Karl Pflästerer
On 9 Dez 2004, [EMAIL PROTECTED] wrote: > I have a list of dictionaries, each representing info about a file, > something like: > > [{'name':'foo.txt','size':35}, {'name':'bar.txt','size':35}, ...] > > I want to present a sorted list of all the files' data, sorting on the > keys 'name' or 'size'.

Re: [Tutor] sorting a list of dictionaries

2004-12-09 Thread Kent Johnson
If you can use Python 2.4 it is very simple using the new key= parameter to sort and operator.itemgetter: >>> import operator >>> ds = [{'name':'foo.txt','size':35}, {'name':'bar.txt','size':36}] >>> ds.sort(key=operator.itemgetter('name')) >>> ds [{'name': 'bar.txt', 'size': 36}, {'name': 'foo.t

[Tutor] Lock down windows with python+usb

2004-12-09 Thread Asif Iqbal
Hi All Has anyone done any script like this? Use a python script for Windows XP that will continuosly check if my USB is plugged in. So if I unplug my USB flashdrive it will fork a screensaver with password lock. Thanks for any idea/suggestion -- Asif Iqbal PGP Key: 0xE62693C5 KeyServer: pgp.mi

[Tutor] sorting a list of dictionaries

2004-12-09 Thread Larry Holish
Hello, I have a list of dictionaries, each representing info about a file, something like: [{'name':'foo.txt','size':35}, {'name':'bar.txt','size':35}, ...] I want to present a sorted list of all the files' data, sorting on the keys 'name' or 'size'. The file 'name' s should be unique (I'm hopin

[Tutor] Capturing Logfile data in Windows

2004-12-09 Thread Philip Kilner
Hi List, I have a closed-source application which creates log files. I'd like to capture this logfile data as it is crated, and do clever things with it! Is this possible? I guess it must be, because there are "tail" type utilities for Windows... Is it possible in Python? I'd be grateful for an

Re: [Tutor] Difference between for i in range(len(object)) and for i in object

2004-12-09 Thread Bob Gailer
At 09:50 AM 12/9/2004, kumar s wrote: [snip] Personally I am getting weary of a lot of requests that to me seem to come from a lack of understanding of Python.. Would you be willing to take a good tutorial so you understand basic Python concepts and apply them to your code. I also despair that

RE: [Tutor] Difference between for i in range(len(object)) and for i in object

2004-12-09 Thread Robert, Andrew
Good morning Kumar, I believe you need to do something like: # # Read from command line supplied input file # for line in open(sys.argv[1]).xreadlines(): # # Remove \n from end of line # line=line[:-1] # # Break line by tab delimiter

[Tutor] Difference between for i in range(len(object)) and for i in object

2004-12-09 Thread kumar s
Dear group, My Tab delimited text looks like this: HG-U95Av2 32972_at432 117 HG-U95Av2 32972_at499 631 HG-U95Av2 32972_at12 185 HG-U95Av2 32972_at326 83 HG-U95Av2 32972_at62 197 I want to capture: co

Re: [Tutor] CGI Video collection application File I/O troubles

2004-12-09 Thread Alan Gauld
> When I run the script from my bash shell it creates the videodb > database file, but when I run it from the browser it doesn't > create no file whatsoever. This is usually due to wrong file permissions. The script runs under the web server and this usually has restricted access for security rea

Re: [Tutor] CGI Video collection application File I/O troubles

2004-12-09 Thread Patric Michael
<> > Sorry for the delay but I was busy with soemthing else. > The script prints the values of the variables fine in the > browser so there must be a problem with the file writing part. > When I run the script from my bash shell it creates the videodb > database file, but when I run it from the b

Re: [Tutor] Complex roots

2004-12-09 Thread Tim Peters
[Dick Moores] > VERY helpful, Matt. Thanks. > > One question: This seems to not compute accurately at all > when the imaginary part of number=complex() is other than 0. That's just because the math was wrong . Starting with theta = 0.0 *assumed* the imaginary part is 0, although I can't guess wh

[Tutor] Graphics coordinates

2004-12-09 Thread Ron Phillips
I work for a Civil Engineering organization. I need to give our users a means to generate geographic coordinates for our projects and structures.   I plan to do this by making a viewer which will accept a graphic file and two  points (pixels) in that image for which geographic coordinates ar

Re: [Tutor] Complex roots

2004-12-09 Thread Dick Moores
VERY helpful, Matt. Thanks. One question: This seems to not compute accurately at all when the imaginary part of number=complex() is other than 0. For example, number=complex(5,5): With number=complex(5,5) n=float(4) the code produces {0: (1.631, 0.0), 1: (0.0, 1.631), 2: (-1.631, 0.0), 3: (0.0

Re: [Tutor] CGI Video collection application File I/O troubles

2004-12-09 Thread Guybrush Threepwood
Quoting Chad Crabtree <[EMAIL PROTECTED]>: > Olli Rajala wrote: > > > > > > > > >>Ok. I tried running the script on my Apache server on Windows NT > and IT > >>WORKS The script saves the values of videodb keys correctly. > DARN!!! > >>I don't get it. Why does the exact same script work on Win

Re: [Tutor] How to get the 2 complex cube roots of 1?

2004-12-09 Thread Alan Gauld
> My trusty $10 Casio calculator tells me that the 3 cube roots of 1 are: > 1, (-.5 +0.866025403j), and (-.5 -0.866025403j), or thereabouts. Is there > a way to do this in Python? Sorry the power operation in Python will only return 1+0j You need to dig out the math books and write a function to

[Tutor] Complex roots

2004-12-09 Thread Matt Williams
Further to my previous post, please find some code below: Hope this helps, Matt #Complex number Roots #Matt Williams 9.12.04 import math number=complex(0.5,0) n=float(3) size=math.sqrt((number.real**2)+(number.imag**2)) arg=math.radians(360/n) root=1/n modulus=size**root theta=float(0) ro

Re: [Tutor] MemoryError

2004-12-09 Thread Kent Johnson
Liam, I'm sorry to hear you so discouraged. It sourds like your program has gotten too big for you to clearly understand what it is doing. An earlier poster suggested that you break your program up into functions. This is a very good idea, especially if you do it from the start. A very powerful

Re: [Tutor] How to get the 2 complex cube roots of 1?

2004-12-09 Thread Pierre Barbier de Reuille
Do you want : the roots of 1 ? or something more general ? Because the nth-roots of 1 are defined by : r = exp(2*i*pi*k/n) with k = {0,1,...n-1} If it's more complex ... then I don't know :) Pierre Dick Moores a écrit : My trusty $10 Casio calculator tells me that the 3 cube roots of 1 are: 1,

[Tutor] How to find complex roots

2004-12-09 Thread Matt Williams
Dick Mores wrote: My trusty $10 Casio calculator tells me that the 3 cube roots of 1 are: 1, (-.5 +0.866025403j), and (-.5 -0.866025403j), or thereabouts. Is there a way to do this in Python? I think the neatest approach might be to consider that the n-complex roots form at equal angle around

Re: [Tutor] String matching?

2004-12-09 Thread Liam Clarke
Hi Kent, Just wanted to say thanks for the advice on the regular expressions. I've just created a regular expression which finds all 267 applets, my .index iterations were producing some cockeyed results, so I tried re in desperation, and it works, so simply. Looks pretty menacing, but it's good.

Re: [Tutor] Re: Could I have used time or datetime modules here?

2004-12-09 Thread Kent Johnson
Liam Clarke wrote: Hi Brian and Dick, I for one have learnt a lot from this combined poke around the workings of datetime. The datetime.year thing never occurred to me, yet it was so obvious when I saw it being used. I give you, my python alarm clock timing mechanism, final version! http://www.ra

[Tutor] How to get the 2 complex cube roots of 1?

2004-12-09 Thread Dick Moores
My trusty $10 Casio calculator tells me that the 3 cube roots of 1 are: 1, (-.5 +0.866025403j), and (-.5 -0.866025403j), or thereabouts. Is there a way to do this in Python? Checking the Casio results with Python: >>> 1**3 1 >>> (-.5 + .866025403j)**3 (0.796196859+1.1766579932626087e-009j

Re: [Tutor] Please help matching elements from two lists and printingthem

2004-12-09 Thread Alan Gauld
> >>> out = open('sa_int_2.txt','w') > >>> for ele1 in range(len(spot_cor)): > x = spot_cor[ele1] replace this with for x in spot_cor: > for ele2 in range(len(spot_int)): > cols = split(spot_int[ele2],'\t') and this with for item in spot_int: cols = split(item,'\t') > y = (cols[0]+'\t'+col

Re: [Tutor] MemoryError

2004-12-09 Thread Liam Clarke
Well, I figured out the memory error relatively easily once I poked some stuff, I was using codeSt.find instead of codeSt.index, so it was returning no matches as -1, index raises an error for me, and I wasn't catering for that -1. The MemoryError occurred when Python wanted to slice from 160,000 t

Re: [Tutor] Re: Could I have used time or datetime modules here?

2004-12-09 Thread Liam Clarke
Hi Brian and Dick, I for one have learnt a lot from this combined poke around the workings of datetime. The datetime.year thing never occurred to me, yet it was so obvious when I saw it being used. I give you, my python alarm clock timing mechanism, final version! http://www.rafb.net/paste/resu