Re: Struggling with os.path.join and fileinput (was 'Path, strings, and lines'

2015-06-15 Thread MRAB
On 2015-06-16 03:00, Malik Rumi wrote: On Saturday, June 13, 2015 at 1:25:52 PM UTC-5, MRAB wrote: On 2015-06-13 05:48, Malik Rumi wrote: > On Friday, June 12, 2015 at 3:31:36 PM UTC-5, Ian wrote: >> On Fri, Jun 12, 2015 at 1:39 PM, Malik Rumi wrote: >> > I am trying to find a list of strings i

Re: Struggling with os.path.join and fileinput (was 'Path, strings, and lines'

2015-06-15 Thread Ian Kelly
On Mon, Jun 15, 2015 at 8:00 PM, Malik Rumi wrote: > I have struggled with this for several hours and not made much progress. I > was not sure if your 'names' variable was supposed to be the same as > 'filenames'. Also, it should be 'os.path.join', not os.join. Anyway, I > thought you had some

Struggling with os.path.join and fileinput (was 'Path, strings, and lines'

2015-06-15 Thread Malik Rumi
On Saturday, June 13, 2015 at 1:25:52 PM UTC-5, MRAB wrote: > On 2015-06-13 05:48, Malik Rumi wrote: > > On Friday, June 12, 2015 at 3:31:36 PM UTC-5, Ian wrote: > >> On Fri, Jun 12, 2015 at 1:39 PM, Malik Rumi wrote: > >> > I am trying to find a list of strings in a directory of files. Here is >

Re: Path, strings, and lines

2015-06-13 Thread MRAB
On 2015-06-13 05:48, Malik Rumi wrote: On Friday, June 12, 2015 at 3:31:36 PM UTC-5, Ian wrote: On Fri, Jun 12, 2015 at 1:39 PM, Malik Rumi wrote: > I am trying to find a list of strings in a directory of files. Here is my code: > > # -*- coding: utf-8 -*- > import os > import fileinput > > s2

Re: Path, strings, and lines

2015-06-12 Thread Malik Rumi
On Friday, June 12, 2015 at 6:48:18 PM UTC-5, Chris Angelico wrote: > On Sat, Jun 13, 2015 at 5:39 AM, Malik Rumi wrote: > > for line in lines: > > for item in fileinput.input(s2): > > if line in item: > > with open(line + '_list', 'a+') as l: > > l.append(

Re: Path, strings, and lines

2015-06-12 Thread Malik Rumi
On Friday, June 12, 2015 at 3:31:36 PM UTC-5, Ian wrote: > On Fri, Jun 12, 2015 at 1:39 PM, Malik Rumi wrote: > > I am trying to find a list of strings in a directory of files. Here is my > > code: > > > > # -*- coding: utf-8 -*- > > import os > > import fileinput > > > > s2 = os.listdir('/home/m

Re: Path, strings, and lines

2015-06-12 Thread Chris Angelico
On Sat, Jun 13, 2015 at 5:39 AM, Malik Rumi wrote: > for line in lines: > for item in fileinput.input(s2): > if line in item: > with open(line + '_list', 'a+') as l: > l.append(filename(), filelineno(), line) Ian's already answered your actual question, b

Re: Path, strings, and lines

2015-06-12 Thread Ian Kelly
On Fri, Jun 12, 2015 at 1:39 PM, Malik Rumi wrote: > I am trying to find a list of strings in a directory of files. Here is my > code: > > # -*- coding: utf-8 -*- > import os > import fileinput > > s2 = os.listdir('/home/malikarumi/Projects/P5/shortstories') Note that the filenames that will be

Path, strings, and lines

2015-06-12 Thread Malik Rumi
I am trying to find a list of strings in a directory of files. Here is my code: # -*- coding: utf-8 -*- import os import fileinput s2 = os.listdir('/home/malikarumi/Projects/P5/shortstories') with open('/home/malikarumi/Projects/P5/list_stories') as f: lines = f.readlines() for line in lin