Guest User

Untitled

a guest
Jan 22nd, 2016
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. FIGURE_TYPES = {
  2.     "circle": Circle,
  3.     "square": Square,
  4.     "rectangle": Rectangle
  5. }
  6.  
  7. def create_figures(input_data):
  8.     result = []
  9.     for f_info in input_data:
  10.         figure_type = f_info['type']
  11.         if figure_type in FIGURE_TYPES:
  12.             figure_class = FIGURE_TYPES[figure_type]
  13.             result.append(figure_class(**f_info))
  14.         else:
  15.             raise ValueError("Unsupported figure")
  16.     return result
Advertisement
Add Comment
Please, Sign In to add comment