simple error i hope

Clay Hobbs clay at lakeserv.net
Fri Aug 1 18:51:50 EDT 2008


On Fri, 2008-08-01 at 13:25 -0700, Emile van Sebille wrote:
> suhail shaik wrote:
> 
> >     print fileName
> >     file = fileName.split(".")
> ......^^^^  this is a list
> 
> you're shadowing a builtin -- generally a bad practice
> 
> >     print file
> >     textfile = file[0]+".txt"
> >     print textfile
> >     os.chdir(PNAME)
> >     file(textfile,'wt')
> 
> ......^^^^  and this is why
> 
> 
> HTH,
> 
> Emile
> 

It is also a good idea to open files with the open() function and not the
file() function.  They do the exact same thing, and take the exact same
parameters, just open() makes your code a bit more readable (or at least
that's what I think).

--Ratfink




More information about the Python-list mailing list