Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. class ForumBuilder:
  2.     def childern(self, parent, forums):
  3.         for forum in forums:
  4.             if forum.parent is None or parent.id != forum.parent.id:
  5.                 continue
  6.             parent.childs.append(forum)
  7.     def build(self, forums):
  8.         list = []
  9.         for forum in forums:
  10.             if forum.parent is None:
  11.                 list.append(forum)
  12.             self.childern(forum, forums)
  13.         return list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement