Re: combining the path and fileinput modules SOLVED

2006-11-27 Thread Gabriel Genellina
At Sunday 26/11/2006 01:29, wo_shi_big_stomach wrote: for line in fileinput.input(g, inplace=1, backup='.bak'): # just print 2nd and subsequent lines if not fileinput.isfirstline(): print line.rstrip('\n') # check first line only elif fileinput.isfirstline

Re: combining the path and fileinput modules SOLVED

2006-11-25 Thread wo_shi_big_stomach
Dennis Lee Bieber wrote: > On Sat, 25 Nov 2006 07:58:26 -0800, wo_shi_big_stomach > <[EMAIL PROTECTED]> declaimed the following in > comp.lang.python: > >> File "p2.py", line 23, in ? >> for line in fileinput.input(f,): >> File >> "/System/Library/Frameworks/Python.framework/Versions/2.3/l

Re: combining the path and fileinput modules

2006-11-25 Thread wo_shi_big_stomach
Gabriel Genellina wrote: > At Saturday 25/11/2006 00:14, wo_shi_big_stomach wrote: > >> > The filter should be applied to walkfiles. Something like this: >> > >> > dir = path(/home/wsbs/Maildir) >> > for f in filter(os.path.isfile, dir.walkfiles('*')): >> > # >> > # test: >> >

Re: combining the path and fileinput modules

2006-11-24 Thread Gabriel Genellina
At Saturday 25/11/2006 00:14, wo_shi_big_stomach wrote: > The filter should be applied to walkfiles. Something like this: > > dir = path(/home/wsbs/Maildir) > for f in filter(os.path.isfile, dir.walkfiles('*')): > # > # test: > # print f Thanks, this way f will print the

Re: combining the path and fileinput modules

2006-11-24 Thread wo_shi_big_stomach
Gabriel Genellina wrote: > The filter should be applied to walkfiles. Something like this: > > dir = path(/home/wsbs/Maildir) > for f in filter(os.path.isfile, dir.walkfiles('*')): > # > # test: > # print f Thanks, this way f will print the full pathname/filename. But f a

Re: combining the path and fileinput modules

2006-11-24 Thread Gabriel Genellina
At Thursday 23/11/2006 12:21, wo_shi_big_stomach wrote: >> dir = path(/home/wsbs/Maildir) >> for f in dir.walkfiles('*'): >> # >> # test: >> # print f > > Are you absolutely sure that f list doesn't contain > any path to directory, not file? > Add this: > > f = filter(os.p

Re: combining the path and fileinput modules

2006-11-23 Thread wo_shi_big_stomach
On 11/23/06 6:15 AM, Rob Wolfe wrote: > wo_shi_big_stomach wrote: >> Newbie to python writing a script to recurse a directory tree and delete >> the first line of a file if it contains a given string. I get the same >> error on a Mac running OS X 10.4.8 and FreeBSD 6.1. >> >> Here's the script: >>

Re: combining the path and fileinput modules

2006-11-23 Thread Rob Wolfe
wo_shi_big_stomach wrote: > Newbie to python writing a script to recurse a directory tree and delete > the first line of a file if it contains a given string. I get the same > error on a Mac running OS X 10.4.8 and FreeBSD 6.1. > > Here's the script: > > # start of program > > # p.pl - fix broken

combining the path and fileinput modules

2006-11-22 Thread wo_shi_big_stomach
Newbie to python writing a script to recurse a directory tree and delete the first line of a file if it contains a given string. I get the same error on a Mac running OS X 10.4.8 and FreeBSD 6.1. Here's the script: # start of program # p.pl - fix broken SMTP headers in email files # # recurses f