Re: simple error i hope

2008-08-01 Thread Maric Michaud
Le Saturday 02 August 2008 00:51:50 Clay Hobbs, vous avez écrit :
> 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).

The main point with open I think is to easy later evolution. While you could 
override "file" name as well as "open" by a custom funcion, it's a bad idea 
to override the name of the type because a simple isinstance(file_, file) 
won't work anymore if you do so.


-- 
_

Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list


Re: simple error i hope

2008-08-01 Thread Clay Hobbs

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

--
http://mail.python.org/mailman/listinfo/python-list


Re: simple error i hope

2008-08-01 Thread Emile van Sebille

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

--
http://mail.python.org/mailman/listinfo/python-list


simple error i hope

2008-08-01 Thread suhail shaik
hi ,

i am new to python..may be this may turn into a simple error but i am in
urgency please kindly help me


#!/usr/bin/python
#Globals here
ROOTDIR = "/vol/mmis/media/video/tvid2008/mediaVideos/test" # Root dir where
video files are located
PNAME = "/data/test_1/"
#DAILY_UPLOAD_PATH = "/mmis-ss9952/newsroom/du-dev/"

import os,glob
### MAIN ###
os.chdir(ROOTDIR)

for fileName in glob.glob('*.mpg'):
print fileName
file = fileName.split(".")
print file
textfile = file[0]+".txt"
print textfile
os.chdir(PNAME)
file(textfile,'wt')
os.chdir("/home/qmss2/workspace/sbd/")
command = "java MPEG_Play "+ROOTDIR+"/"+filename+"
"+"/data/test_1/"+textfile
print command
#os.system(command)


please tell me what is the error.
trace back is

file(textfile,'wt')
TypeError: 'list' object is not callable
--
http://mail.python.org/mailman/listinfo/python-list