Passing variable to another Python Script
Question: I am having difficulty passing a variable from one function to another
function in another python script. I have read the other answers but they have
not really helped on this subject.

This is the first file I want to send the variable to( some code omitted for
clarity )

    
    
    # TestGUI.py
    
    from Tkinter import *
    import serial
    import os
    
    class Testgui:
        def __init__(self, master):
    
        def writetoBOT(self,instruct):
           ser = serial.Serial(6)
           ser.baudrate = 9600
           ser.parity = serial.PARITY_NONE #set parity check: no parity
           ser.timeout = 1            #non-block read
           ser.writeTimeout = 2     #timeout for writ
    
           if(ser.isOpen() == False):
               ser.open()
               print ser.portstr       # check which port was really used
               ser.write(instruct)
           else :
               ser.write(instruct)
    

This is the sceond file:

    
    
    # TestGUI_2.py
    
    from TestGUI import Testgui
    
    class Tracker:
        def __init__(self):
           pass
        def drive(self,cords, cords1):
           while( cords >= 320):        
               l='l'
               Testgui.writetoBOT(l)      # This is the problem line 
    

TypeError: unbound method writetoBOT() must be called with TestGUI instance as
first argument (got str instance instead)


Answer: `writetoBOT` takes 2 arguments: `self` and `instruct`. call it with a
`Testgui` instance:

    
    
    tgui=Testgui(your_master)
    tgui.writetoBOT(l)
    

If you want to call it with `Testgui` class, you still need to pass an
instance of `Testgui`:

    
    
    tgui=Testgui(your_master)
    Testgui.writetoBOT(tgui, l)
    

