Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'beginner': 0.05; 'interpreter': 0.05; 'output': 0.05; 'beginners': 0.09; 'mess': 0.09; 'nice!': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'repeated': 0.09; 'subject:number': 0.09; 'def': 0.12; 'stored': 0.12; 'times,': 0.14; '(class': 0.16; 'advantage.': 0.16; "children's": 0.16; 'combined.': 0.16; 'creativity.': 0.16; 'formula': 0.16; 'instructor.': 0.16; 'it;': 0.16; 'magic': 0.16; 'manifest': 0.16; 'non-printing': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'repl': 0.16; 'scratch': 0.16; 'trivially': 0.16; 'utterly': 0.16; 'component': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'trying': 0.19; 'pieces': 0.19; 'input': 0.22; 'example': 0.22; 'programming': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'adds': 0.24; 'non': 0.24; 'together.': 0.24; 'sort': 0.25; "i've": 0.25; 'this:': 0.26; 'downloaded': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'function': 0.29; 'specifically': 0.29; 'wondering': 0.29; 'on,': 0.29; 'generally': 0.29; "doesn't": 0.30; 'subject:list': 0.30; "i'm": 0.30; 'getting': 0.31; 'towards': 0.31; 'usually': 0.31; 'breaking': 0.31; 'bunch': 0.31; 'idea,': 0.31; 'though.': 0.31; 'stuff': 0.32; 'another': 0.32; 'becomes': 0.33; 'screen': 0.34; 'subject:the': 0.34; 'could': 0.34; 'knowledge': 0.35; 'connection': 0.35; 'something': 0.35; 'objects': 0.35; 'but': 0.35; 'add': 0.35; 'there': 0.35; 'really': 0.36; 'shows': 0.36; 'similar': 0.36; 'should': 0.36; 'so,': 0.37; 'turn': 0.37; 'problems': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'little': 0.38; 'does': 0.39; '12,': 0.39; 'extremely': 0.39; 'functional': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'received:org': 0.40; 'called': 0.40; 'how': 0.40; 'skip:u 10': 0.60; 'units': 0.60; 'august': 0.61; 'helps': 0.61; 'our': 0.64; 'more': 0.64; 'different': 0.65; 'teach': 0.65; 'natural': 0.68; 'combining': 0.68; 'subject:get': 0.81; 'composing': 0.84; 'dry': 0.84; 'obvious.': 0.84; 'screwed.': 0.84; 'benefits:': 0.91; 'lot,': 0.93; 'numerous': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: "Neil D. Cerutti" Subject: Re: how to get the ordinal number in list Date: Tue, 12 Aug 2014 15:29:35 -0400 References: <53E658CD.5020904@gmail.com> <53e59035$0$29998$c3e8da3$5496439d@news.astraweb.com> <338e8fb0-c9ec-462a-b560-1c1ff77de17e@googlegroups.com> <154cc342-7f85-4d16-b636-a1a953913c98@googlegroups.com> <70c65ab0-0a9d-4705-a8a3-43b9ee0600a0@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: jackman.norwich.edu User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <70c65ab0-0a9d-4705-a8a3-43b9ee0600a0@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 77 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1407871797 news.xs4all.nl 2875 [2001:888:2000:d::a6]:44099 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76146 On 8/12/2014 2:20 PM, Rustom Mody wrote: > On Tuesday, August 12, 2014 11:10:48 PM UTC+5:30, Neil D. Cerutti wrote: >> Beginners are particularly poor, in relation to experts, at noticing the >> applicability of idea, and at combining ideas together. Breaking things >> into component parts has multiple benefits: > >> 1. The applicability of individual ideas becomes obvious. It's one thing >> to know about [].sort, and another thing to know when it's appropriate >> to sort something. > >> 2. The expert specifically shows how and why the ideas are combined. >> This helps build the connection for the beginner, whose knowledge is not >> stored as an expert stores it; i.e, in broad categories with multiple >> connections; but as disorganized data with very few connections. > > Nice! > > And how do we lead the beginners towards expertise? > In a way functional programming is to programming creativity > what lego is to children's spatial creativity. > > Specifically there are a bunch of pieces that need to fit: > > 1. Functional Programming: Nothing more than composing functions > [Maybe a bit simplistic but not unrealistic a defn] > 2. Trying this out at the interpreter > 3. Introspectable objects Functional programming could be particularly hard to teach since it is generally made up of numerous small units of work combined in a complex way. This is precisely the formula for something that beginners will find extremely challenging. When functional programming is dumbed down enough for a beginner to be able to grok it, the programming problems start to look really lame. It needn't be that way, of course, but it takes a good deal of creativity on the part of the instructor. If Factorial doesn't turn you on, you might be screwed. ;) > Some things follow from this: > > For the lego-game of playing with functions at the REPL to work and be > pleasant and rewarding: > > 1. functions should be non side-effecting; else same trials giving different > answers adds more confusion than understanding > 2. They should be non-printing else: > > def foo(x): return x+1 > def bar(x): print x+1 > > look similar when trivially tried but compositionally are utterly different > > In effect a printing function breaks the lego bricks That may be so, but printing stuff to the screen is very natural to people. I've downloaded Haskell a few times, but the knowledge that getting input and writing output requires something mysterious called gonads just frightens me. > [The P in the REPL is DRY enough that it does not usually need to be > repeated all over] A good REPL does help a lot, though. > 3. Abstractions (class instances) should be avoided in favor of > concrete data (lists, dicts, scalars) because they add undue mess at little > comprehension advantage. eg take the example of a regex match. It > returns some object and then we have to scratch our heads wondering > whats in the magic box. If instead of match, we use findall, the data > is manifest and obvious. I'm with you on regex: match objects suck. That and escaping. -- Neil Cerutti