FieldInfo object properties should be a property on Field objects

Idea created by johnmdye on Jan 30, 2015
    New
    Score20
    Why do we need FieldInfo objects? Why another object to tinker with? It would be great to just be rid of stupid fieldinfo objects and make all of those properties available on a field object.

    For example, DeleteField_management is slow, especially when you have a bunch of fields to delete. It's much faster to simply use a FieldInfo object to set a field's visibility to 'HIDDEN' and export the dataset, which then omits the hidden field from the new dataset. 

    To do that though, you have to type all of this excess code:
    if arcpy.Describe(FeatureLayer).dataType == "FeatureLayer":
        field_info = arcpy.Describe(FeatureLayer).fieldinfo
        for index in xrange(0, field_info.count):
            if field_info.getFieldName(index) == "SomeFieldToDelete":
                field_info.setVisible = "HIDDEN"
    If it were just a read/write property on a field object, here's your code:
    Field = arcpy.ListFields(FeatureLayer)
    for Field in Fields:
        if Field.name == "SomeFieldToDelete":
            Field.setVisible = "HIDDEN"

    Follow that up with an Export via TableToTable or FeatureClassToFeatureClass and voila, we're done. It doesn't seem like that much excess code but when you get into this with a lot of fields, having FieldInfo object properties as properties on Field objects is much more elegant and easier to manage.