[Tutor] Syntax Error

Kris Kerwin kkerwin at insightbb.com
Fri Jan 6 02:41:09 CET 2006


Hi all,

I'm working on a little script, but every time that I run it, it comes 
back as a syntax error around line 24. However, I can't find anything 
wrong with it.

I figure that maybe I just need another set of eyes. Please take a 
look at this code, and let me know if you can find anything wrong 
with it that would cause a syntax error?

Thanks in advance!

Kris Kerwin

-------- Script ---------

#!/usr/bin/python

import commands
import string
import os

os.chdir('/home/kris/Mail/.inbox.directory')

file_string = commands.getoutput('tree -afi')
new_file_string = string.replace(file_string, ' ', '_SPACE_')
file_list = string.split(new_file_string)

# Pop of leading '.' directory.
file_list.pop(0)

# Pop of directory stats.
file_list.pop()

index = 1
while index < (len(file_list) + 1):
	file_name = file_list.pop()
	new_file_name = string.replace(file_name, '_SPACE_', ' ')
	unix_name = string.replace(new_file_name, ' ', '\ '
	file_type = commands.getoutput('file %s' % unix_name) # << Line 24
	
	if file_type == '%s: ASCII mail text, with very long lines' % 
new_file_name:
		file_contents = commands.getoutput('cat %s' % unix_name)
		print file_contents
		index = index + 1
			
	else:
		index = index + 1

os.chdir('/home/kris/bin/gmail_export/')
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dircat
Type: application/x-python
Size: 859 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20060105/4e252b71/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20060105/4e252b71/attachment.pgp 


More information about the Tutor mailing list