[Edu-sig] Python First: Free access for educators

Vern Ceder vceder at canterburyschool.org
Wed Mar 8 20:49:09 CET 2006


I also was thinking thinking of using a dictionary, for pretty much the 
same reasons.

+1

Vern

Anna Ravenscroft wrote:
> 
> 
> On 3/8/06, *w chun* <wescpy at gmail.com <mailto:wescpy at gmail.com>> wrote:
> 
>      > def switch(choice, functions = [cf0, cf1, cf2, cf3])
> 
> 
>     should we really be showing folks using a mutable object as a default
>     argument? ;-)
> 
>     i'd suggest: (1) changing it to a tuple, or (2) None and figure it out
>     after that.
> 
> 
> I prefer dicts for this sort of thing. That way "choice" could be 
> something meaningful. For example, I recently wrote a python script 
> showing how different sorting algorithms work (for my discrete math 
> class). I have a dict of algorithms, something like (I'm typing from 
> memory before my first cup of coffee - go gentle on me):
> 
> algs = {'quick':quicksort, 'merge':mergesort, "insert": insertionsort}
> choice = "quick" # however we get the choice..eg from the command line.
> if choice in algs:
>     choice(datatosort)
> ...
> 
> I really like not having to remember order. This way, I get the right 
> function easily. And I can print out the list of keys to remind me which 
> functions are available.
> 
> Anna
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Edu-sig mailing list
> Edu-sig at python.org
> http://mail.python.org/mailman/listinfo/edu-sig

-- 
This time for sure!
    -Bullwinkle J. Moose
-----------------------------
Vern Ceder, Director of Technology
Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804
vceder at canterburyschool.org; 260-436-0746; FAX: 260-436-5137


More information about the Edu-sig mailing list