Bhavesh Jadav
Bhavesh Jadav

Reputation: 705

Access object defined in class to other class

I have two files, lcd_init.py and test.py. Following is the code in lcd_init.py file

PINMAP = {
'RS': 7,
'E': 8,
'D0': 25,
'D1': 24,
'D2': 11,
'D3': 9,
'D4': 10,
'D5': 22,
'D6': 27,
'D7': 17,
'CS1': 4,
'CS2': 3,
'RST': 2,
'LED': 18,
}
display = pylcd.ks0108.Display(backend = pylcd.GPIOBackend, pinmap = PINMAP, debug = False)
draw = pylcd.ks0108.DisplayDraw(display)
display.commit(full = True)

display and draw are objects of Display and DisplayDraw class respectively. How do I access methods of display and draw object in test.py file?

Upvotes: 0

Views: 39

Answers (2)

Sajad Banooie
Sajad Banooie

Reputation: 360

 from lcd_init import display

 display.methodname()

Upvotes: 1

Rahul Reddy Vemireddy
Rahul Reddy Vemireddy

Reputation: 1155

To see all the methods of an object, try dir(object). If you know the methods of the class, you can directly call the methods object.method.

Upvotes: 1

Related Questions