If you're looking to create a custom function that gives you field information, you will want to look at these two pages:
ListFields MethodFieldObjectThe list fields method will give you a list of all the fields in your Feature Class. You can then loop through that list, getting information about each field using attributes of the field object. If this case, you'd want the "type" attribute to see if that field is a string or not.Code Example:import arcpy
def numberStringFieldsWithLayer(layer = None):
# If no layer is passed in, stop the function
if layer == None:
return None
# Get the count for each field with type "String"
n = 0
for field in arcpy.ListFields(layer):
if field.type == "String":
n += 1
return n
As far as calling this from another script, I think the best way to call your function would be to import that custom script. What you're essentially doing is creating your our custom module.Save the above code in a file called customModule.py. Before you can import that module, you need to add that folder to the list of paths Python looks in to import things from. Then you can import the module and call your custom function. Code example:# Add your custom module folder to the system paths
import sys
sys.path.append(r"Path\to\your\custom\module\folder")
# import your custom moudle
import customModule
# Make a layer object from your feature layer
streetsLayer = arcpy.mapping.Layer("streets")
# Call you custom function from the module
numberOfFieldsTypeString = customModule.numberStringFieldsWithLayer(streetsLayer)
# Remove your layer reference
del streetsLayer
# Print your results
print numberOfFieldsTypeString
This is pretty cool because it gives you a good introduction how to make code in other files to import to any project!Hope this helps,Matt