Upload Programs to Arduino with Python

Hi, I am currently trying to make a set of Python codes to upload Arduino codes for me. I am not sure if that is possible, but this is what I currently have:

import serial
import os
ser = serial.Serial('/dev/cu.usbmodem141201', 9600)
string = """#include <Stepper.h>
#define STEPS 200
Stepper stepper(STEPS, 11, 9, 10, 8);
void setup() {
	stepper.setSpeed(160);
}
void loop() {
	stepper.step(512);
	delay(1000);
	stepper.step(-512);
	delay(1000);
}"""
ser.write(string.encode('utf-8'))

Is this possible? I don't have any errors while processing this code, but Arduino does not receive the code, and my motor never turned. I tried using the Arduino app to upload code, and the Arduino code functions perfectly. I believe this means the problems is at the last line of this code. Can anyone help me? Thanks

:man_shrugging:

The code needs to be … compiled…

Change the preferences to be verbose for compiling and upload the blink example and Look at the bottom part of the IDE window when you upload code. You’ll see all the steps and commands required for your board. (Compile, link, upload etc)

Try to find a tutorial explaining what c++ is and the tool chain to go from the files for your program to binary code you can transfer into the flash memory of your arduino (or a computer). It’s not interpreted like Python.