Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using DRAKON with python's try: except: exceptions

Is anyone familiar with DRAKON?

I quite like the idea of the DRAKON visual editor and have been playing with it using Python -- more info: http://drakon-editor.sourceforge.net/python/python.html

The only thing I've had a problem with so far is python's try: except: exceptions. The only way I've attempted it is to use branches and then define try: and except: as separate actions below the branch. The only thing with this is that DRAKON doesn't pick up the try: and automatically indent the exception code afterwards.

Is there any way to handle try: except: in a visual way in DRAKON, or perhaps you've heard of another similar visual editor project for python?

Thanks.

like image 714
Leke Avatar asked Oct 08 '22 15:10

Leke


2 Answers

You could put the whole "try: except:" construct inside one "Action" icon like this:

Catching exceptions in DRAKON-Python

Both spaces and tabs can be used for indentation inside an icon.

like image 181
Stepan Mitkin Avatar answered Oct 13 '22 11:10

Stepan Mitkin


There are limitation exist in Drakon since it is a code generator, but what you can do is to re-factor the code as much as possible and stuff it inside action block:

try:
   function_1()
   function_2()
except:
   function_3()

Drakon works best if you follow suggested rules(skewer,happy route,branching etc).

Once you construct algorithm base on this, it can help you solve complex problems fast.

Hope thats help.

like image 41
user2429638 Avatar answered Oct 13 '22 09:10

user2429638