How to execute code from other tab

edited October 2017 in Python Mode

Hello. I'm typing code in other tab, from processing, however a need to import the functions for me to execute. When I typing "import", the processing return error.


Tab 1 (main) import tab2


Tab 2

def foo(): print("Hello world! =)")

How I can to do this?


  • edited October 2017

    Ignore me. I apparently don't know anything about Python mode.

  • edited October 2017 Answer ✓

    • Under Python Mode, only the 1st main tab has the extension ".pyde".
    • All additional tabs use extension ".py" instead.
    • Therefore, we 1st need to import them into our main ".pyde" tab before they become available.
    • Let's say your tab 2 is called "".
    • And inside that ".py" tab, you've got a function called loadStuff(): def loadStuff():
    • A class called Stuff: class Stuff:
    • And even a constant variable called HOUR: HOUR = 60 * 60 * 1000

    HOUR = 60 * 60 * 1000
    def loadStuff(): pass
    class Stuff: pass
    • Now, in order to import everything from "" tab into the ".pyde" main tab, you can use the following: from My_Other_Stuff import *
    • You can even specify which 1s you actually want.
    • Let's say you need loadStuff() & HOUR, but not Stuff: from My_Other_Stuff import loadStuff, HOUR
    • And sometimes, you might prefer to access them all via a prefix:


    import My_Other_Stuff as Stuff
    print Stuff.HOUR
    things = Stuff.loadStuff()
    stuff = Stuff.Stuff()
  • Thank you GoToLoop for your answer about my question and about the format text on post.

Sign In or Register to comment.