Given your level of Python, you don’t need to understand how this code works, but just what is it doing and how to use it for your purposes.
What that code is doing
Just launching a ROS2 program. As you know, every ROS2 program is identified by in which package is its code and which is its executable file.
How to use it
Very easy. You only need to know which ROS2 program you want to launch. That is identified by its package and its executable. Then, just copy/paste that code and substitute the content of package=‘turtlebot3_teleop’and executable=‘teleop_keyboard’with the proper package and executable names.
That is how you should proceed right now in order to advance in ROS2.
About the solution you propose, I don’t agree at all that is simpler, since you introduce a lot of new concepts and more complicated function. But if you think it is simpler for you, please keep using it. At the end, what matters is that we understand what we are doing in order to reach the goal.
I think it is a mater of learning styles. Some people like to cut and paste while other try break thing down into an understandable sequence of steps which they can use.