Feb-01-2022, 06:04 PM
I have the following code, the first method, SendCommandV1, was given to me. My question is do I have to pass ser as an argument when I call SendCommand? Since ser is defined globally, I do not see any reason to pass ser through the argument.
Would the second method, SendCommandV2 be just as good?
Would the second method, SendCommandV2 be just as good?
ser = serial.serial('COM3', '9600') def SendCommandV1(ser, command_string): ser.write(command_string) def SendCommandV2(command_string): ser.write(command_string) SendCommandV1('ser, Hello World') SendCommandV2('Hello World') #is this OK?