[Tutor] data driven programming

Alan Gauld alan.gauld at btinternet.com
Fri Apr 4 10:51:34 CEST 2014

On 04/04/14 03:33, Alex Kleider wrote:

>> And to some extent Python is an example of a data driven
>> design since function (and method) calls are associated with
>> dictionaries (ie Python namespaces).
> Can you elaborate, please, on what you mean by pointing out that the
> fact that Python's function and method calls are associated with
> dictionaries makes it 'an example of data driven design?'  I'm not clear
> on that relationship.  Thanks, Alex

Most of Python is built on dictionaries under the surface.
When you define a function you create a function object
and associate it with a name. In other words you store
the name as a key in a dictionary and have the function
object as the value.

When you call the function Python looks up the name in
the dictionary and calls the associated object.
This is very similar to what was recommended to you
to avoid the long list of if/elif.

Alan G
Author of the Learn to Program web site

More information about the Tutor mailing list