Instantiating class in another file and passing variable

Hello

I was wondering how best to instantiate an instance of a class and pass it arguments from another class/file.

I’m doing something like this:

import OtherClass

class ADict():
...
colour_dict = {"colour": "blue}

OtherClass(colour_dict).paint()

would you expect this to work?
I’m getting unexpected argument for colour_dict where:

class OtherClass():
def __init__(self, colour_dict):
self.colour_dict  = colour_dict

def paint(self):
return self.colour_dict

This should help: https://stackoverflow.com/questions/12008991/python-create-instance-of-class-in-another-class-with-generic-example

1 Like