How to import instances of a Class in Python?

class Tweeter:

    def __init__(self, api_key, api_secret_key, bearer_token, access_token, access_token_secret ):
        self.api_key = api_key
        self.api_secret_key = api_secret_key
        self.bearer_token = bearer_token
        self.access_token = access_token
        self.access_token_secret = access_token_secret

        auth = tweepy.OAuthHandler(self.api_key, self.api_secret_key)
        auth.set_access_token(self.access_token, self.access_token_secret)

        self.api = tweepy.API(auth)

How can I import an instance of a class from the file in which the instance was created to another .py file.

For example: instance1 = Tweeter(xargument,yargument, zargument)

How do import and/or call the instance that I created in another file without having to import the detail that clutter up the code.


Ideally, you'd use parameters to pass around your API client instance, rather than global application imports

You shouldn't need multiple (numbered) instances of it, either.

from classes import Tweeter  # for example

if __name__ == "__main__":
  t = Tweeter(...)
  some_function(t, some, other, args)