If you look at the definition of StringPartition
, you'll see that it is just a stub loading a package, not a real function (in a fresh kernel, of course):
ClearAttributes[StringPartition, {Protected, ReadProtected}]
Definition@StringPartition
StringPartition := System`Dump`AutoLoad[Hold[StringPartition],
Hold[StringPart, StringPartition], "StringUtilities`"] /; System`Dump`TestLoad
The package redefines StringPartition
and protects it again:
StringPartition;
ClearAttributes[StringPartition, {Protected, ReadProtected}]
Definition@StringPartition
StringPartition[StringUtilitiesDump`args___]:=With[{StringUtilitiesDump`res=StringUtilitiesDump`oStringPartition[StringUtilitiesDump`args]},StringUtilitiesDump`res/;StringUtilitiesDump`res=!=$Failed]
This explains the behavior you observe. The workaround is to preload the package before making any new definitions as I made above. But remember that modifying built-in functions is dangerous and isn't recommened until you know exactly what you do...