On Dec 25, 6:35 pm, "David Stanek" <dsta...@dstanek.com> wrote: > You won't need the dictionary at all if each type has a parse method.
How do you know what type to use if you don't have a if...elif..., dictionary, getattr, or some other sort of dispatching? Look at his requirements: there is a variable called "data_type" that controls how to parse the data. Whether he uses the variable to figure out what method to call, or to figure out what type of object to create to call the parse method of, some sort of dispatching is necessary. This is inevitable when type information is supplied through the input. To be honest I am a little concerned over the more-or-less knee-jerk suggestions to refactor this into a highly object-oriented approach. For the task at hand the OP's approach is fine (aside from the use of exec). Carl Banks -- http://mail.python.org/mailman/listinfo/python-list