Next / Previous / Contents / TCC Help System / NM Tech homepage

14.13. PickList.__anglicize(): Convert “gray” to “grey”

This method returns its string argument with the first occurrence of "gray" replaced by "grey", if there is one.

huey
# - - -   P i c k L i s t . _ _ a n g l i c i z e

    def  __anglicize ( self, name ):
        """Anglicize a name.

          [ name is a string ->
              if name contains "gray" ->
                  return name with the first occurrence of "gray"
                  replaced by "grey"
              else -> return name ]
        """
        where  =  name.find ( "gray" )

        if  where >= 0:
            return name[:where] + "grey" + name[where+4:]
        else:
            where  =  name.find ( "Gray" )
            if  where >= 0:
                return name[:where] + "Grey" + name[where+4:]
            else:
                return name