"Unexpected EOF while parsing" in a very short code

1430
3
Jump to solution
03-26-2012 12:09 PM
AnneRiddle
New Contributor
I'm working on a longer piece of code and wanted to look at a list of rasters in a workspace to make sure I knew the formatting. Trying to create and print a list of raster names has continually raised a syntax error of 'unexpected EOF while parsing' for line six. (This would be followed by an indented "print raster" but I'm checking the syntax as I go).

>>> import arcpy >>> from arcpy import env >>> env.workspace=r"S:\FIRE\ben_data\1973to1980\Eco01" >>> rasterlist=arcpy.ListRasters >>>  >>> for raster in rasterlist: ...     print raster 


Does anyone have insight about why such an error would be raised on such a simple piece of code?

In addition, Python has continually auto-fills the last "raster" with "rasterlist" when I to execute the code block. Why is it doing this? (I understand I can just change that variable name--just wondering out of curiosity).
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MathewCoyle
Frequent Contributor
This line should have given you an error
rasterlist=arcpy.ListRasters

Proper syntax is
rasterlist=arcpy.ListRasters()

View solution in original post

0 Kudos
3 Replies
MathewCoyle
Frequent Contributor
This line should have given you an error
rasterlist=arcpy.ListRasters

Proper syntax is
rasterlist=arcpy.ListRasters()
0 Kudos
AnneRiddle
New Contributor
You're right, of course...serious case of the Mondays over here, apparently.

Any thoughts on the "auto-fill" on the last line?
0 Kudos
KimOllivier
Occasional Contributor III
I think that you have broken the unwritten rule:

Never name any folder, file, table, script, featureclass, field or variable starting with a digit.

Sure to end in tears, especially in raster dataset manipulation.
0 Kudos