AnsweredAssumed Answered

reusing a codeblock?

Question asked by desertsp on Sep 23, 2016
Latest reply on Sep 23, 2016 by Dan_Patterson

I'm using arcpy.CalculateField_management() with a large-ish codeblock. Is there a way to store the codeblock so it can be easily reused multiple times, and more importantly, easily edited? This is part of a larger script.

 

For instance (psuedo-code):

 

codeblock = "

line 1 statements

line 2 statements

   some indented statements

    # a comment

line 3 statements "

 

arcpy.CalculateField_management("1st_dataset_name","field_to_calculate","codeblock")

arcpy.CalculateField_management("2nd_dataset_name","field_to_calculate","codeblock")

 

What would be the proper way of doing this?

 

Thanks!

Outcomes