On Wed, May 11, 2011 at 5:24 PM, Robert . <for...@zhub.co.uk> wrote: > Hi all, > > My first post ever! :) > I'm following the guide "Learn Python the Hard Way" and have reached a point > where I am struggling to understand the code and unfortunately the authors > guide hasn't cleared it up for me. (excercise 40 for reference) > > The main confusion is coming from 'cities['_find'] = find_city' I'm not sure > what this is really doing. > > From my learning, this should add an extra item to the dict with the index > name of "_find" and the value which is returned from "find_city" function.
No, that would be cities['_find'] = find_city() When you use cities['_find'] = find_city the value of the extra item is _the function find_city itself_. And thus later city_found = cities['_find'](cities,state) will be equivalent to city_found = find_city(cities,state) -- André Engels, andreeng...@gmail.com _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor