Try this:
from PyQt4 import QtGui
app = QtGui.QApplication([])
w = QtGui.QWidget()
le = QtGui.QLineEdit(w)
lay = QtGui.QHBoxLayout()
w.setLayout(lay)
lay.addWidget(le)
le.setStyleSheet("border: 1px solid red;")
w.show()
app.exec_()
If you want to save the previous color do this:
ss = le.styleSheet() #original saved
le.setStyleSheet("border: 1px solid red;") #changed
le.setStyleSheet(ss) #back to original