So I am making a basic directory system in python from scratch. I am pretty new to coding and am doing python as a Uni module. So I have made the functions for creating the tree from scratch, but now I have been tasked with actually just printing out the object as it is (not visually to see each step of the directory tree). So this is my code currently
class File:
pass
class Directory(File):
def __init__(self, name, left=None, right=None):
self.name = name
self.left = left
self.right = right
def __repr__(self):
return f"{self.name}, {self.left}, {self.right}"
class PlainFile(File):
def __init__(self, name):
self.name = name
def __str__(self):
return self.name
When I try to print root, I want to essentially see the whole thing. But it gives me the <main.blahblah when printing the names of the classes and other parts too. I think my def__repr__ needs to be recursive in nature but for the life of me I have no clue how to do it:( Please help!