N
news.west.cox.net
I want to check a directory, see if there are any files in it... then open
each one and do something.
I have this...
files = os.listdir('/direcory')
if len(files) > 0:
for file in files:
f1 = file(file, "r")
do some other stuff
But this raises a TypeError:
TypeError: 'str' object is not callable
So I tried replacing the line f1 = file(file, "r") with f1 = file('%s'
%file, "r")
But that does not work either.
I know this is easy, anyone care to point out the solution.
Thanks.
--
Sean Berry ~ Internet Systems Programmer
BuildingOnline Inc.
The Building Industry's Web Design and Marketing Agency
Celebrating our 9th year in business, founded Aug. 1995
Ph: 888-496-6648 ~ Fax: 949-496-0036
--> Web Design Agency site: http://www.BuildingOnline.net
--> Building Industry Portal: http://www.BuildingOnline.com
--> Building Industry News: http://www.BuildingOnline.com/news/
--> Home Plans: http://www.eHomePlans.com
each one and do something.
I have this...
files = os.listdir('/direcory')
if len(files) > 0:
for file in files:
f1 = file(file, "r")
do some other stuff
But this raises a TypeError:
TypeError: 'str' object is not callable
So I tried replacing the line f1 = file(file, "r") with f1 = file('%s'
%file, "r")
But that does not work either.
I know this is easy, anyone care to point out the solution.
Thanks.
--
Sean Berry ~ Internet Systems Programmer
BuildingOnline Inc.
The Building Industry's Web Design and Marketing Agency
Celebrating our 9th year in business, founded Aug. 1995
Ph: 888-496-6648 ~ Fax: 949-496-0036
--> Web Design Agency site: http://www.BuildingOnline.net
--> Building Industry Portal: http://www.BuildingOnline.com
--> Building Industry News: http://www.BuildingOnline.com/news/
--> Home Plans: http://www.eHomePlans.com