Re: [Tutor] re Format a file

2009-02-26 Thread Lie Ryan
On Fri, 27 Feb 2009 09:59:40 +0530, prasad rao wrote: > def myform(s): > import os > so=open(s) > d=os.path.dirname(s)+os.sep+'temp.txt' > de=open(d,'w') > for line in so: > while len(line)>60: > item=line[60:] > try: > a

Re: [Tutor] Extract strings from a text file

2009-02-26 Thread spir
Le Thu, 26 Feb 2009 21:53:43 -0800, Mohamed Hassan s'exprima ainsi: > Hi all, > > I am new to Python and still trying to figure out some things. Here is the > situation: > > There is a text file that looks like this: > > text text text Joseph > text text text text text text text text text text

Re: [Tutor] Class instance understanding = None

2009-02-26 Thread spir
Le Fri, 27 Feb 2009 00:06:59 -0500, David s'exprima ainsi: > Hi Everyone, > I go through the archived [Tutor] mail list to find programs others have > tried to do. I found one that would keep track of a petty cash fund. > please point out my misunderstanding. > Here is what I started with; > >

Re: [Tutor] Class instance understanding = None

2009-02-26 Thread spir
Le Fri, 27 Feb 2009 00:06:59 -0500, David s'exprima ainsi: > Hi Everyone, > I go through the archived [Tutor] mail list to find programs others have > tried to do. I found one that would keep track of a petty cash fund. > please point out my misunderstanding. > Here is what I started with; > [

[Tutor] Extract strings from a text file

2009-02-26 Thread Mohamed Hassan
Hi all, I am new to Python and still trying to figure out some things. Here is the situation: There is a text file that looks like this: text text text Joseph text text text text text text text text text text text text text text text text text text text text text text text text text text text te

Re: [Tutor] setting PYTHONPATH on mac

2009-02-26 Thread Valdemaras Jonikas
>> how does one go about setting a PYTHON path environment variable on >> Mac OS X 10.4? > >i set up my .profile in the Terminal.app (UNIX) with a text file with >the following line: >PATH=$PATH:/Applications/Autodesk/maya8.5/Maya.app/Contents/bin You should do more or less the same -- edit .b

[Tutor] Class instance understanding = None

2009-02-26 Thread David
Hi Everyone, I go through the archived [Tutor] mail list to find programs others have tried to do. I found one that would keep track of a petty cash fund. please point out my misunderstanding. Here is what I started with; #!/usr/bin/python from reportlab.lib.normalDate import ND #import cPick

Re: [Tutor] re Format a file

2009-02-26 Thread John Fouhy
2009/2/27 prasad rao : > Hello > I don't know why, but this I think going into infinite loop. > I cant see anything wrong in it. > Please show me where  the problem is. [...] > while len(line)>60: > tem=line[60:] > try: > ??? a,b=tem.split(' ',1) > ?

[Tutor] re Format a file

2009-02-26 Thread prasad rao
HelloI don't know why, but this I think going into infinite loop. I cant see anything wrong in it. Please show me where the problem is. def myform(s): import os so=open(s) d=os.path.dirname(s)+os.sep+'temp.txt' de=open(d,'w') for line in so: while len(line)>60: ?

[Tutor] setting PYTHONPATH on mac

2009-02-26 Thread bmol...@att.net
how does one go about setting a PYTHON path environment variable on Mac OS X 10.4? i set up my .profile in the Terminal.app (UNIX) with a text file with the following line: PATH=$PATH:/Applications/Autodesk/maya8.5/Maya.app/Contents/bin thanks, -b

Re: [Tutor] re.format a file

2009-02-26 Thread Martin Walsh
A.T.Hofkamp wrote: > prasad rao wrote: >> helloThank you Lie and Kent. >> I forgot about newline character and the fact that string can be sliced. >> Thanks for your timely help >> BTW I have gone through the Python library reference and find no >> examples >> in fileinput module. > > The filein

Re: [Tutor] Tkinter Grid, Listbox expand

2009-02-26 Thread W W
Aha! I found the key - I was missing the weight argument: 1 from Tkinter import * 2 import os, shutil, tkFileDialog, tkMessageBox 3 4 class TkSync: 5 def __init__(self, root): 6 self.sbox = Listbox(root) 7 self.sbox.grid(row=0, column=0, sticky=N+S+E+W) 8

Re: [Tutor] cgi script to start another process in background

2009-02-26 Thread Ravi Kondamuru
I am running this on a freebsd 4.9 system running apache server. I started with code that was as simple as yours. But the problem is apache does not print "hello before the fork" until the child exists.I have read at various forums that apache buffers till the script exists and in this case till th

[Tutor] Tkinter Grid, Listbox expand

2009-02-26 Thread W W
Hi, I'm writing a Tkinter program and having severe problems with getting my listbox to expand when I resize the window. Here's my code so far: 1 from Tkinter import * 2 import os, shutil, tkFileDialog, tkMessageBox 3 4 class TkSync: 5 def __init__(self, root): 6 self.sbo

Re: [Tutor] learning new features of python

2009-02-26 Thread spir
Le Thu, 26 Feb 2009 18:16:59 + (GMT), ALAN GAULD s'exprima ainsi: > > > >> Similaraly in Alan Guald Learn to program link, he has given > > >> information on opening a file with file() and open() functions. > > > > > > And in V3 they took that back out again :-( > > > > ?? open() is in V3.

Re: [Tutor] Class definition...

2009-02-26 Thread Alan Gauld
"Spencer Parker" wrote I am looking for a good tutorial to walk through that really explains class definition. This has been one sticking point that always messes me up I assume from that you have been through the basic tutors like mine? Have you tried the deeper material in Dive into Pyt

Re: [Tutor] learning new features of python

2009-02-26 Thread ALAN GAULD
> >> Similaraly in Alan Guald Learn to program link, he has given information > >> on opening a file with file() and open() functions. > > > > And in V3 they took that back out again :-( > > ?? open() is in V3. file() is not. That's right, they have reverted to how it was in Python 1.X I changed

[Tutor] Class definition...

2009-02-26 Thread Spencer Parker
I am looking for a good tutorial to walk through that really explains class definition. This has been one sticking point that always messes me up for the most part. That and when people use "self". For some reason I just can't grasp what people say. Any good pointers to throw at me? I really w

Re: [Tutor] passig parameter with CGI...

2009-02-26 Thread Jay Deiman
Spencer Parker wrote: I am looking for a little instruction on how one would process a set of parameters being sent to it through CGI. I have a script that sends info to another script that lives on another server. The second script would then process the information that is passed to it thro

Re: [Tutor] cgi script to start another process in background

2009-02-26 Thread Jay Deiman
Ravi Kondamuru wrote: Hi, I am trying to write a python cgi script, that invokes another process and exists. Using the subprocess documentation on NO_WAIT, I am not having much success: pid = os.spawnlp(os.P_NOWAIT, "/bin/mycmd", "mycmd", "myarg") ==> pid = Popen(["/bin/mycmd", "myarg"]).pid

Re: [Tutor] learning new features of python

2009-02-26 Thread Kent Johnson
On Thu, Feb 26, 2009 at 10:35 AM, Alan Gauld wrote: > > "Bala subramanian" wrote >> Similaraly in Alan Guald Learn to program link, he has given information >> on >> opening a file with file() and open() functions. > > And in V3 they took that back out again :-( ?? open() is in V3. file() is no

Re: [Tutor] learning new features of python

2009-02-26 Thread Alan Gauld
"Bala subramanian" wrote Is there any website/tutorial that explains new features that are constantly getting embedded in python. The documentation for each release has a whats new document that is always worth reading. Similaraly in Alan Guald Learn to program link, he has given informat

Re: [Tutor] re.format a file

2009-02-26 Thread Kent Johnson
On Thu, Feb 26, 2009 at 8:43 AM, prasad rao wrote: > hello > Thank you Lie and Kent. > I forgot  about newline character and the fact that string can be sliced. > Thanks for your timely help > BTW I have gone through  the Python library reference and find no examples > in fileinput module. > z=fil

Re: [Tutor] re.format a file

2009-02-26 Thread A.T.Hofkamp
prasad rao wrote: helloThank you Lie and Kent. I forgot about newline character and the fact that string can be sliced. Thanks for your timely help BTW I have gone through the Python library reference and find no examples in fileinput module. The fileinput module only deals with reading and w

[Tutor] re.format a file

2009-02-26 Thread prasad rao
helloThank you Lie and Kent. I forgot about newline character and the fact that string can be sliced. Thanks for your timely help BTW I have gone through the Python library reference and find no examples in fileinput module. z=fileinput.input(file,inplace=1) for line in z: ???if len(line)<60:pa

Re: [Tutor] Linear Algebra weirdness

2009-02-26 Thread Robert Berman
Hi, I didn't get nearly as far as you. In [2]: from LinearAlgebra import * --- ImportError   Traceback (most recent call last) /home/bermanrl/ in () ImportError: No module named LinearAlgebra

Re: [Tutor] learning new features of python

2009-02-26 Thread Kent Johnson
On Thu, Feb 26, 2009 at 6:28 AM, Bala subramanian wrote: > Dear Friends, > > Is there any website/tutorial that explains new features that are constantly > getting embedded in python. Every new release comes with a "What's New in Python xx" document. This is often the best, and sometimes the only

Re: [Tutor] Convert a string of numbers to a list

2009-02-26 Thread Kent Johnson
On Thu, Feb 26, 2009 at 2:00 AM, wrote: > Hi, > > I am trying to convert an output from subprocess.Popen() from a byte string > to a list of numbers.  This is what Popen returns: > > print SAL.stdout.readlines() > > ['[335, 180, 201, 241, 199]\r\n'] For one line: In [11]: s = '[335, 180, 201, 24

Re: [Tutor] Linear Algebra weirdness

2009-02-26 Thread Kent Johnson
On Thu, Feb 26, 2009 at 12:32 AM, Mr Gerard Kelly wrote: > I am getting some very strange behaviour from the Linear Algebra module. > > Look at this code: > > from LinearAlgebra import * > > a=5 > print a > > And look at the output that I get when I run it: > > 50.0 > 0.0 > 0.25 > 0.0 > 0.5 > 0.0

Re: [Tutor] Convert a string of numbers to a list

2009-02-26 Thread A.T.Hofkamp
kkwai...@umich.edu wrote: Hi, I am trying to convert an output from subprocess.Popen() from a byte string to a list of numbers. This is what Popen returns: print SAL.stdout.readlines() ['[335, 180, 201, 241, 199]\r\n'] Except the string will be much longer in practice. I've experimented w

[Tutor] learning new features of python

2009-02-26 Thread Bala subramanian
Dear Friends, Is there any website/tutorial that explains new features that are constantly getting embedded in python. This would be helpful for python lovers to grow with python and adopt new styles of codes. Just for an example, i read in Mark Luts "learning python" book, the various forms of ex

Re: [Tutor] format a file

2009-02-26 Thread Kent Johnson
On Thu, Feb 26, 2009 at 4:09 AM, prasad rao wrote: > hello > I find it difficult to use horizontal scroll bar to read text documents. > So I want to split lines in the text file in to two lines. > > def  myforrmat(source,desty): > so=open(source) > de=open(desty,'w') > for line in

[Tutor] Convert a string of numbers to a list

2009-02-26 Thread kkwaiser
Hi, I am trying to convert an output from subprocess.Popen() from a byte string to a list of numbers. This is what Popen returns: print SAL.stdout.readlines() ['[335, 180, 201, 241, 199]\r\n'] Except the string will be much longer in practice. I've experimented with .rstrip and .split and

[Tutor] Linear Algebra weirdness

2009-02-26 Thread Mr Gerard Kelly
I am getting some very strange behaviour from the Linear Algebra module. Look at this code: from LinearAlgebra import * a=5 print a And look at the output that I get when I run it: 50.0 0.0 0.25 0.0 0.5 0.0 0.75 0.0 1.0 [[ 2.5000e-01 -2.5000e-01 -4.3750e-01 ..., 3.73459082e+

Re: [Tutor] format a file

2009-02-26 Thread Lie Ryan
Try thinking what happens when you do this: line = 'this is a rellly long line\n' first = line[:20] second = line[20:] print first print second . . . . . . . . . . Have you got it? The first would contain "this is a re" and the second "llly long linee

[Tutor] format a file

2009-02-26 Thread prasad rao
hello I find it difficult to use horizontal scroll bar to read text documents. So I want to split lines in the text file in to two lines. def myforrmat(source,desty): so=open(source) de=open(desty,'w') for line in so: ? if len(line)<60:de.write(line) ? if len(line)

Re: [Tutor] how to instantiate a class

2009-02-26 Thread spir
Le Thu, 26 Feb 2009 12:38:27 +0530, Abhishek Kumar s'exprima ainsi: > hello list, > > Below is the sample code of a class. > > > import > > Class ABC: > def __init__(self,a,b,c): > statement 1 > statement 2 >