简体   繁体   English

使用DRAKON和python的try:except:exception

[英]Using DRAKON with python's try: except: exceptions

Is anyone familiar with DRAKON? 有人熟悉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 我非常喜欢DRAKON可视化编辑器的想法并且一直在使用Python玩它 - 更多信息: 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. 到目前为止我遇到的唯一问题是python的尝试:除了:例外。 The only way I've attempted it is to use branches and then define try: and except: as separate actions below the branch. 我试过的唯一方法是使用分支然后定义try:和except:作为分支下面的单独动作。 The only thing with this is that DRAKON doesn't pick up the try: and automatically indent the exception code afterwards. 唯一的问题是DRAKON没有接受尝试:然后自动缩进异常代码。

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? 有没有办法处理尝试:除了:在DRAKON中以可视方式,或者你可能听说过另一个类似的python可视化编辑器项目?

Thanks. 谢谢。

You could put the whole "try: except:" construct inside one "Action" icon like this: 您可以将整个“try:except:”构造放在一个“Action”图标中,如下所示:

在DRAKON-Python中捕获异常

Both spaces and tabs can be used for indentation inside an icon. 空格和制表符都可用于图标内的缩进。

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: Drakon存在限制,因为它是一个代码生成器,但您可以做的是尽可能地重新分解代码并将其填充到动作块中:

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

Drakon works best if you follow suggested rules(skewer,happy route,branching etc). 如果您遵循建议的规则(串,快乐路线,分支等),Drakon效果最佳。

Once you construct algorithm base on this, it can help you solve complex problems fast. 基于此构建算法后,它可以帮助您快速解决复杂问题。

Hope thats help. 希望有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM