Labeling with python

Discussion created by japanesegeogal on Sep 1, 2013
Latest reply on Sep 5, 2013 by mdenil

I am trying to give features labels with python code.

Here is the code I am using:

>>> import arcpy
... mxd = arcpy.mapping.MapDocument("CURRENT") 
... layer = arcpy.mapping.ListLayers(mxd, "")[0] 
... if layer.supports("LABELCLASSES"):
...     for lblclass in layer.labelClasses:
...       lblclass.showClassLabels = True
... lblclass.expression = "[type]"
... layer.showLabels = True
... arcpy.RefreshActiveView()

and I get this error:
Runtime error <type 'exceptions.NameError'>: name 'lblclass' is not defined

I thought this worked once, but not anymore..
Do I have to define "lblclass"??

If you could give me some help, I'd really appreciate it, thanks!