Generating a python class definition

54 views
Skip to first unread message

Liz Looney

unread,
Jun 12, 2019, 1:57:58 AM6/12/19
to Blockly
I'm interested in generating a python class definition. Has anyone else done this?

Coda Highland

unread,
Jun 12, 2019, 10:00:02 AM6/12/19
to blo...@googlegroups.com
I've not done it with Python, but I have done it with Javascript. It's entirely possible, but it's also a lot of work. Variable scoping and method calls are the two hardest parts, because neither of those exist in Blockly's built-in model.

There are a few different ways you could approach it, depending on exactly what you want to do with it and how rigorous you want to be with it. What's your goal?

/s/ Adam

On Wed, Jun 12, 2019 at 12:58 AM 'Liz Looney' via Blockly <blo...@googlegroups.com> wrote:
I'm interested in generating a python class definition. Has anyone else done this?

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/76d5c67e-d25d-445b-be2f-d481681e6514%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Liz Looney

unread,
Jun 12, 2019, 1:17:43 PM6/12/19
to Blockly
I think I just want to create a single class. But, I do want to have member fields as well as local variables. I've done a blockly environment which generates a single java class and it works pretty well. It's not perfect, but it's pretty good. I know Java a lot more than I know Python, so I'm worried I'll miss something. I know that to generate a field reference, I've got to do "self.foo", right? and each method has to have a "self" parameter, right?

Thanks for your help!
-Liz


On Wednesday, June 12, 2019 at 7:00:02 AM UTC-7, Coda Highland wrote:
I've not done it with Python, but I have done it with Javascript. It's entirely possible, but it's also a lot of work. Variable scoping and method calls are the two hardest parts, because neither of those exist in Blockly's built-in model.

There are a few different ways you could approach it, depending on exactly what you want to do with it and how rigorous you want to be with it. What's your goal?

/s/ Adam

On Wed, Jun 12, 2019 at 12:58 AM 'Liz Looney' via Blockly <blo...@googlegroups.com> wrote:
I'm interested in generating a python class definition. Has anyone else done this?

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blo...@googlegroups.com.

Coda Highland

unread,
Jun 12, 2019, 1:23:29 PM6/12/19
to blo...@googlegroups.com
Python should actually be easier than Java because Java is statically-typed.

You're right about Python syntax so far. The only gotcha I would watch out for is variable scoping, because Python's rules are different from pretty much any other language I can think of.

/s/ Adam

To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/4c8ab3b7-4442-456c-acfd-7ea21e73b075%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages