I've written a small tutorial on interfacing with Python. See Two ways communication between Python3 and Arduino
you could basically do all the heavy lifting on the python side as you say and just send commands through the Serial line. You "just" need to decide on a command language like
"SxAy" ➜ Servo #x to Angle y
"SxPy" ➜ Servo #x to pulsewidth y
The command could be followed by a new line as a separator. The Arduino code to read these commands is pretty straightforward. I would suggest to study Serial Input Basics to get the basics on how to handle this.
something like this would do
bool processCommand(const char* buf) {
if (buf[0] != 'S') return false; // wrong syntax
int servo, value;
char mode;
if (sscanf(buf, "S%d%c%d", &servo, &mode, &value) != 3) return false; // could not parse
if (mode != 'A' && mode != 'P') return false;
if (mode == 'A') Serial.printf("Servo #%d to Angle %d\n", servo, value);
else Serial.printf("Servo #%d to Pulsewidth %d\n", servo, value);
return true;
}
bool handleCommand() {
char buf[32];
int pos = 0;
while (Serial.available()) {
char c = Serial.read();
if (c == '\n') {
buf[pos] = 0;
return processCommand(buf);
} else if (pos < sizeof(buf) - 1) {
buf[pos++] = c;
}
}
return false;
}
void setup() {
Serial.begin(115200);
Serial.println("READY");
}
void loop() {
if (handleCommand()) {
// command processed
}
}