support icon indicating copy to clipboard operation
support copied to clipboard

[Feature] Python code snippet within blocks

Open southlakefll opened this issue 1 year ago • 1 comments

I think I nice future feature would be to have a "python snippet" block. That would allow running of small sections of python code within a block. This would create an intermediate step for kids to do a little python without leaving the blocks environment.

This is a feature that is available in the M5Stack series of microcontrollers in their block coding environment Here is a screenshot of what it looks like in their software: Screenshot 2024-04-05 151804

and the python code that is generated: image

southlakefll avatar Apr 05 '24 19:04 southlakefll

Thanks for opening this topic.

Did you know you can combine blocks and Python? Here is an example. Let's say you have a few useful Python functions you wrote:

image

You can use them in your programs like this:

image


Making something directly inline might be easier for the occasional oneliner, but doing it in a Python file can also be a good learning experience and might be easier in the long run, since you have a proper editor with syntax highlighting and so on.

This can also be a nice way for teams to grow a library with useful functions over the years, which new team members can use with ease.

laurensvalk avatar Apr 06 '24 11:04 laurensvalk