[python-uk] invalid syntax
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 print filename NameError: name 'filename' is not defined Please suggest me i am trying to read all the .mpg files from a directory.. thanks in advance ...please urgent help.. ___ python-uk mailing list python-uk@python.org http://mail.python.org/mailman/listinfo/python-uk
Re: [python-uk] invalid syntax
[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 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 ___ python-uk mailing list python-uk@python.org http://mail.python.org/mailman/listinfo/python-uk
Re: [python-uk] invalid syntax
> > for fileName in glob.glob('*.mpg'): > print filename > > > Variable names are case sensitive. -- Michael Connors ___ python-uk mailing list python-uk@python.org http://mail.python.org/mailman/listinfo/python-uk
Re: [python-uk] invalid syntax
Tim Golden wrote: Python is a case-sensitive language. You can' say "for fileName in..." in one line and then refer to "filename" in the next. Ooops. You *can't* say "for fileName in..." in one line and "filename" in the next. TJG ___ python-uk mailing list python-uk@python.org http://mail.python.org/mailman/listinfo/python-uk
Re: [python-uk] invalid syntax
I'm not sure this is the right place for your question, but check how you capitalised "filename" - in one case you used "fileName" and then called "print filename" - because it is all lowercase this variable is undefined, can't be printed, and you get an error. You would probably have better luck posting this kind of question on a python support forum (e.g. http://bytes.com). On Mon, Jul 21, 2008 at 3:38 PM, suhail shaik <[EMAIL PROTECTED]> 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 > print filename > NameError: name 'filename' is not defined > > > Please suggest me i am trying to read all the .mpg files from a directory.. > > thanks in advance ...please urgent help.. > > > > > ___ > python-uk mailing list > python-uk@python.org > http://mail.python.org/mailman/listinfo/python-uk > > ___ python-uk mailing list python-uk@python.org http://mail.python.org/mailman/listinfo/python-uk
Re: [python-uk] invalid syntax
thanks silly me...it was of great help. On 7/21/08, Michael Connors <[EMAIL PROTECTED]> wrote: > > > >> for fileName in glob.glob('*.mpg'): >> print filename >> >> >> Variable names are case sensitive. > -- > Michael Connors > > ___ > python-uk mailing list > python-uk@python.org > http://mail.python.org/mailman/listinfo/python-uk > > ___ python-uk mailing list python-uk@python.org http://mail.python.org/mailman/listinfo/python-uk
Re: [python-uk] invalid syntax
On 21 Jul 2008, at 15:38, suhail shaik wrote: ## #!/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 print filename NameError: name 'filename' is not defined Variables are case sensitive - so fileName and filename are not the same thing. -- Andy Armstrong, Just Another Perl Hacker :) ___ python-uk mailing list python-uk@python.org http://mail.python.org/mailman/listinfo/python-uk
Re: [python-uk] invalid syntax
In addition to what others have said, 2008/7/21 suhail shaik <[EMAIL PROTECTED]>: > command = "./hive2 -k kf/"+file+"/ -o "+file+".xml /data/test/"+fileName > print command > os.system(command) Whatever you are trying to do here, you might want to try doing purely in Python instead of mixing in shell. Doing it all in Python will make your script more likely to work cross-platform. ___ python-uk mailing list python-uk@python.org http://mail.python.org/mailman/listinfo/python-uk