Re: File traversing

2012-04-17 Thread Nibin V M
thanks for a super fast reply Chris :) On Tue, Apr 17, 2012 at 8:06 PM, Chris Angelico wrote: > On Wed, Apr 18, 2012 at 12:31 AM, Nibin V M wrote: > > # python test.py > > File "test.py", line 1 > > with open('/etc/trueuserowners') as res_own_file: > > ^ > > IndentationError: unexpe

Re: File traversing

2012-04-17 Thread Chris Angelico
On Wed, Apr 18, 2012 at 12:31 AM, Nibin V M wrote: > # python test.py >   File "test.py", line 1 >     with open('/etc/trueuserowners') as res_own_file: >     ^ > IndentationError: unexpected indent Make sure your first code line is flush left. Since indentation indicates block structure (and not

Re: File traversing

2012-04-17 Thread Nibin V M
# python test.py File "test.py", line 1 with open('/etc/trueuserowners') as res_own_file: ^ IndentationError: unexpected indent [~]# cat test.py with open('/etc/trueuserowners') as res_own_file: all_res = set(line.strip().replace(' ', '').split(':')[1] for line in res_own_file if ':

Re: File traversing

2012-04-17 Thread Nibin V M
wow...thanks Karl :) On Tue, Apr 17, 2012 at 2:20 AM, Karl Knechtel wrote: > > > On Sun, Apr 15, 2012 at 5:51 AM, Chris Angelico wrote: > >> >> (You may also want to consider using the 'with' statement to guarantee >> a timely closing of the file. Outside the scope of this mail though.) >> >> I

Re: File traversing

2012-04-16 Thread Karl Knechtel
On Sun, Apr 15, 2012 at 5:51 AM, Chris Angelico wrote: > > (You may also want to consider using the 'with' statement to guarantee > a timely closing of the file. Outside the scope of this mail though.) > > I think this list is just to collect unique entries, yes? If so, a set > may be more to you

Re: File traversing

2012-04-16 Thread Nibin V M
Thank you Chris :) ..I will check it... On Sun, Apr 15, 2012 at 3:21 PM, Chris Angelico wrote: > On Sun, Apr 15, 2012 at 7:15 PM, Nibin V M wrote: > > res_own_file = open('/bah') > > res_own_list = res_own_file.readline() > > res_tot_list=[] > > while res_own_list: > > res_own_list=res_own_li

Re: File traversing

2012-04-15 Thread Chris Angelico
On Sun, Apr 15, 2012 at 7:15 PM, Nibin V M wrote: > res_own_file = open('/bah') > res_own_list = res_own_file.readline() > res_tot_list=[] > while res_own_list: >   res_own_list=res_own_list.strip() >   res_own_list=res_own_list.replace(' ', '') >   res_name=res_own_list.split(':') >   if res_name

File traversing

2012-04-15 Thread Nibin V M
Hello, First of all..I am very new to python with no background in development area! :) Ok, here is my problem.I have opened a file and I need to check each line of that file. I have done it with a while loop. res_own_file = open('/bah') res_own_list = res_own_file.readline() res_tot_list=[]