Passing variable to another Python Script


This question already has an answer here:


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


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

Testgui.writetoBOT(tgui, l)

Alternatively, you can make common space for this two scripts, it acn by database - sqllite

For example,

import sqlite3

con = sqlite3.connect('messages.db')
cur = con.cursor()
#cur.execute('CREATE TABLE message (id INTEGER PRIMARY KEY, name TEXT, content TEXT, read INTEGER)')

for x in range(100000):
    if x in range(1, 500): 
        cur.execute('INSERT INTO message (id, name, content, read) VALUES(NULL, "Guido", "van Rossum", 0)')

import sqlite3
import time

con = sqlite3.connect('messages.db')
cur = con.cursor()

def listen():
    messages = cur.execute('SELECT * FROM message WHERE read=0')
    if not messages:
        return False 
    for m in messages: 
        print 'get message ', m
        cur.execute("UPDATE message SET read=1 WHERE id=?", m[0])        
        print 'update db'
    return True

while True: 

You declared Testgui as a class. This is to be understood as a skeleton or wireframe (beware, this is a shortcut, not the reality). You need to first create a "real" object out from this skeleton in order to use it.


It is possible in classes to have methods (bound functions) that apply at class level. These are called static methods or class methods. They have to be decorated in python.

See for more information.

Need Your Help

Spring LDAP transactional manager

java spring spring-ldap

I have a confusing scenario regarding transaction rollbacks with Spring.

Backbone routes: optional params in root not matching

javascript backbone.js frontend single-page-application backbone-routing

I'm trying to get GitHub-esque route matching through Backbone. This means that hits to /:userName should get caught last, after every other route has been checked. In my current setup my unit rout...