I hardly know where to begin, or end, but I'll try.
I want to create a python utility to do one very small, but repetitive, task: make a (known) subset of fields invisible in a map layer without having to fire up Arcmap.To my amazement, there is no way to do this.
I thought I was onto something when I find that one one can use arcpy.Describe() to get properties of a layer, one such property being a FieldInfo class. That class has a method called setVisible().
But no, there is apparently no way to get Describe() to access a layer in a map file unless one is already running arcmap using the interactive Python window. From a command line one can only access a standalone, .lyr, layer file.
And, to my amazement, the setVisibility() api does not work even then. Nothing changes.
My overwhelming impression of arcpy is that it is a poorly conceived, half baked, quite incomplete API with confusing terminology, and sketchy documentation. For instance: a layer file is treated quite differently to a layer. Apparently to get Describe() to get the properties of the layer (the kernel of the layer file tucked neatly inside) you have first to get the properties of a layer file. When you have done that the class instance returned has a property called -- trumpet roll -- "layer" which is: NO! not an instance of a layer class at all but another instance of Describe which then has layer properties one of which being an instance of FieldInfo. It is clear from the documentation that this cumbersome construct was some kind of afterthought. (The objects returned by describe do not even have a well defined class name: there is no "describe" class)
The documentation also blithely states that there are many properties of layers which the API does not support. Even the modification of quite simple layer properties are unsupported.. The suggested solution seems to be to construct out of band from the ground up an entire new layer and replace the offending layer with it.
Why, oh why, is this API so clunky? Sure, I can understand that certain operations are sufficiently complex that a simple Python API cannot really handle them. But to make certain fields in a layer hidden? Really? This API is now several years old, and it still seems really poor. Is there any chance that it is going to improve?