I am new to python, I was googling and reading SO for this.
I have
pin.py :
from board import Board
class pin(object):
board_id = Int()
my_board = store.get(Board, board_id)
def __init__(self, val):
...
board.py :
from pin import Pin
class Board(object):
id = Int()
def __init__(self, val):
...
Board.pins = ReferenceSet(Board.id, Pin.board_id)
As you can see I need to be able to access both Pin and Board from the other class. I saw here to only do import pin
and import board
. But when I do that and then I do board.Board
or pin.Pin
for example in my pin.py I'll have my_board = store.get(board.Board, board_id)
it gives me this error
AttributeError: 'module' object has no attribute 'Board'
This wasn't happening when I had the code above, but only didn't have the circular import.
To clarify my question:
How do I do a circular import and call the classes from the files being imported?