Passing a randomly choosen file (function) to anothe function

i just saw this code on a simple madlib chooser, and im wondering, what it is and how does it work?

from whatever_folder_name_i_gave import elem1, elem2, elem_n..
import random

if __name__ == "__main__":
  p = random.choice ((elem1, elem2, elem_n..))
  p.function_name()

im interested in how does p.function_name() works,how it’s gets executed, i just cant figure it out.