>
> In teaching Python, I find that analogs to other languages are helpful
> in explaining Python even if a person doesn't know the other language.
>     sorted(set(open(somefile)))
> is like:
>     cat somefile | sort | uniq       # different algorithm, same outcome
> or:
>    SELECT DISTINCT line FROM somelines ORDER BY line;


I think that it helps by making the learning curve less steep, although it
also has the potential to produce poor code because different languages may
have different idioms to solving different problems. Much like if try to
think in English and translate word by word to Spanish, for example (you'll
probably get by, but it won't really be like how a native in that language
does).

Leandro


2014-04-22 3:39 GMT-03:00 Raymond Hettinger <raymond.hettin...@gmail.com>:

>
> On Apr 18, 2014, at 1:21 AM, Jeff Allen <ja...@farowl.co.uk> wrote:
>
> The "think of tuples like a struct in C" explanation immediately reminded
> me that ...
>
>  On 16/04/2014 21:42, Taavi Burns wrote (in his excellent notes from the
> language summit):
>
>  The demographics have changed. How do
> we change the docs and ecosystem to avoid the assumption that Python
> programmers already know how to program in C?
>
>
> In teaching Python, I find that analogs to other languages are helpful
> in explaining Python even if a person doesn't know the other language.
>
>     sorted(set(open(somefile)))
>
> is like:
>
>     cat somefile | sort | uniq       # different algorithm, same outcome
>
> or:
>
>    SELECT DISTINCT line FROM somelines ORDER BY line;
>
> In particular, it is effective to say that tuples are used like structs in
> other languages
> or like records in database tables.
>
> I don't think we should go down the road of removing all the similes and
> metaphors
> from the docs.   While children don't usually benefit from them, adults
> face different
> learning challenges.  Usually, their biggest learning hurdle is
> figuring-out what is
> and what is not a valid comparison to other things they already know.
>
> One problem I have seen with the usual list vs tuple explanations is that
> they seem to suggest that the list-are-for-looping and
> tuples-are-like-records
> notions are baked into the implementation of lists and tuples.
>
> In fact, the distinction is extrinsic to their implementations.  It is
> only important
> because the rest of the language tends to treat them differently.  For
> example,
> you could store ['raymond', 'red'] as a list or as a tuple ('raymond',
> 'red'), but you
> wouldn't be punished until later when you tried:
>
>      'I think %s likes %s' % container     # str.__mod__ treats lists and
> tuples differently
>
> Likewise, there seems to be wide-spread confusion about make makes an
> object immutable.  People seem to miss that ints, tuples, None and str are
> immutable only because they lack any mutating methods,
>
>
> Raymond
>
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/leandropls%40cpti.cetuc.puc-rio.br
>
>
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to