7

Is there a way to change the default parser in the Field Calculator to Python?

So annoying to always change now that I'm trying to move away from using VBScript...

I'm using ArcGIS 10.1 for Desktop.

10

I do not think you will find a way to do this because there is an existing, not yet Under Consideration, ArcGIS Idea to have the 'Field Calculator default to Python'.

5

Esri is a little stuck with this because they want to preserve forward compatibility of old Python code people depend on. I really wish they would have changed the default by now though, as we get a lot of queries from users why their scripts fail in background processing -- because the default (VB) is not supported by arcpy 64 bit!

Here's an example wrapper function to use an alternate default parser. For new code, "PYTHON_9.3", not "PYTHON" is arguably the best parser to use in most situations.

import arcpy
def CalculateField2(in_table, field, expression, expression_type="PYTHON_9.3", code_block=None):
    """Calculate Field using PYTHON_9.3 parser as default instead of VB"""
    arcpy.CalculateField_management(in_table, field, expression, expression_type, code_block)
  • 5
    You're correct with the backwards compatibility reasons... Just a note though, in ArcGIS Pro, Python will be the only parser option. – KHibma Jul 7 '14 at 17:42
  • 1
    Yes, definitely VB is gone in AGP -- since VB isn't supported in 64 bit arcpy -- and ArcGIS Pro is native 64 bit!! – Curtis Price Jul 7 '14 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.