spacepaste

  1.  
  2. there is a function which does some activities;
  3. def new(userlist=[]):
  4. for user in userlist:
  5. print("I am doing some stuff here for {}".format(user))
  6. # done the required activity on the user and now thinks on doing nested activity.
  7. nested_userlist = get_inviters(user)
  8. new(nested_userlist)
  9. # end of function
  10. def get_inviters(user):
  11. # code code
  12. return [...]
  13. What I can't do is, e.g. if I set a nested activity [recursion] level e.g. 5, I don't know how to handle it.
  14. It ends up going infinitive.
  15. What I want is, e.g. with the nested activity level of 2, it should do this
  16. main_users = [5 users here]
  17. For every main user in those 5 main users, go and do stuff for them;
  18. And then if there is a nested activity available at the current level, do it.
  19. If visualized:
  20. Main_user1:
  21. #some stuff here
  22. Nested_level1_user1:
  23. #some stuff here
  24. Nested_level2_user1:
  25. #some stuff here
  26. Nested_level2_user2:
  27. #some stuff here
  28. Nested_level1_user2:
  29. #some stuff here
  30. ....
  31. .
  32. .
  33. .
  34.