calculate field in Python

Discussion created by melodykee on Sep 29, 2011
Latest reply on Jan 16, 2012 by deleted-user-MS0lE1F_0-sy
I want to add a "TEXT" field in a shape file and assign this field with the file name string. The shape file only has one record. Here is my code:

import arcpy
from arcpy import env

# Set environment settings
env.workspace = "D:/Workspace"

fc = "01055p.shp"
tmp = fc.split('.')
tmp2 = tmp[0]

arcpy.AddField_management(fc, "file", "TEXT", "", "", 25)
arcpy.CalculateField_management(fc, "file", tmp2)

But I got error saying "CalculateField_management" failed to execute. Is there any problem with the script? Thanks!