[python-uk] invalid syntax

Tim Golden mail at timgolden.me.uk
Mon Jul 21 16:42:38 CEST 2008


[You'll get a better audience on the main Python list. This list is mostly used for UK-specific stuff like meetups, job openings etc.]

suhail shaik wrote:
> hi ...
> 
> ##################
> #!/usr/bin/python
> #Globals here
> ROOTDIR = "/home/qmss2/Desktop/sbd/hive2_ffmpegsvn/" # Root dir where ts 
> files are located (or recorded)
> PNAME = "/data/test/"
> #DAILY_UPLOAD_PATH = "/mmis-ss9952/newsroom/du-dev/"
> 
> import os,glob
> ### MAIN ###
> os.chdir(ROOTDIR)
> os.mkdir("kf")
> os.chdir(PNAME)
> for fileName in glob.glob('*.mpg'):
>     print filename
>    
>     file = fileName.split(".")
>     print file
>     os.chdir(ROOTDIR+"/kf")
>     os.mkdir(file)
>     command = "./hive2 -k kf/"+file+"/ -o "+file+".xml /data/test/"+fileName
>     print command
>     os.system(command)
> 
> #################
> 
> i get the following error...
> 
> File "/home/qmss2/Desktop/sbd/mpg.py", line 13, in <module>
>     print filename
> NameError: name 'filename' is not defined


Python is a case-sensitive language. You can' say "for fileName in..."
in one line and then refer to "filename" in the next.

Even apart from the other problems you're going to have when you
realise that file is a list (and that you're shadowing a builtin name).

TJG


More information about the python-uk mailing list