Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
For loop Action_Out?
-
When going through a list in a for loop, inside of a python script, I can print the whole list in the console, but I cannot use the workflow.set_output() function to pass the entire list to the next action.
It only passes the last item.
For example:
tags = linguistictagger.tag_string(text, linguistictagger.SCHEME_LEXICAL_CLASS) for tag in tags: lex = tag[0] word = tag[1] out = word + ' = ' + lex print(out)
This works, but
tags = linguistictagger.tag_string(text, linguistictagger.SCHEME_LEXICAL_CLASS) for tag in tags: lex = tag[0] word = tag[1] out = word + ' = ' + lex workflow.set_output(out)
This doesn't work.
-
The output is only passed to the next action after the script has finished. But you can of course build a string of multiple lines within the script, and then set the entire output after your loop has finished.
tags = linguistictagger.tag_string(text, linguistictagger.SCHEME_LEXICAL_CLASS) lines_out = [] for tag in tags: lex = tag[0] word = tag[1] out = word + ' = ' + lex lines_out.append(out) workflow.set_output('\n'.join(lines_out))
-
Or...
tags = linguistictagger.tag_string(text, linguistictagger.SCHEME_LEXICAL_CLASS) workflow.set_output('\n'.join(['{1} = {0}'.format(*tag) for tag in tags]))
-
Thank you so much! I have now finished my "Parts of Speech" workflow!
If anyone wants to check it out: