I'm new learning as I go, I have read some of the Answers posted, and I've gotten this far, I was able to add a new field to a GBD, I wanted to have the Length be 50, but it created a field with 255, so I didn't get something quite right the code I used below the feature class is wax_ru the Field name is HN_AW Text is the Type of Field, and 50 is the Default Value I wanted, but as I stated it created the field with 255

import arcpy
from arcpy import env
env.workspace = "C:\Users\angelaw\OneDrive - TomTom\Resources\Australia\PSMA_MAY_2018\PSMA_Deltas_test\PSMA_MAY_deltas.gdb"

arcpy.AddField_management ("wax_ru", "HN_AW","TEXT",50)

You should specify parameter names, the code will be easier to understand and you dont have to keep track of parameter position. Also use r in front of path:

import arcpy
from arcpy import env
env.workspace = r"C:\Users\angelaw\OneDrive - TomTom\Resources\Australia\PSMA_MAY_2018\PSMA_Deltas_test\PSMA_MAY_deltas.gdb"

arcpy.AddField_management(in_table="wax_ru", field_name="HN_AW", field_type="TEXT", 

You are providing 50 as the fourth parameter which is field_precision. You can also add empty strings to line up 50 with the right parameter:

  • What does the r do? – AngelaS Jun 15 '18 at 12:42
  • 1
    @AngelaS: Without it some of the \-signs in combination with certain letters can be interpreted as for example a new line = path will not work – BERA Jun 15 '18 at 12:56
  • 1
    @AngelaS About the "r" before the string: stackoverflow.com/questions/2081640/… – Comrade Che Jun 15 '18 at 13:04

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