A person who has been appointed or elected district attorney of any circuit cannot be deprived of his office by the attachment of the county in which he resides to a different judicial circuit. In such a case, the district attorney shall continue to discharge the duties of his office as though he resided in the circuit.