Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

One Bell System - it used to work before they installed the Dimension!


devel / comp.lang.python / some problems for an introductory python test

SubjectAuthor
* some problems for an introductory python testHope Rouselle
+* Re: some problems for an introductory python testChris Angelico
|`* Re: some problems for an introductory python testHope Rouselle
| `* Re: some problems for an introductory python testChris Angelico
|  `- Re: some problems for an introductory python testHope Rouselle
+* Re: some problems for an introductory python testMats Wichmann
|`* Re: some problems for an introductory python testHope Rouselle
| +- Re: some problems for an introductory python testStefan Ram
| +* Re: some problems for an introductory python testChris Angelico
| |`* Re: some problems for an introductory python testHope Rouselle
| | `* Re: some problems for an introductory python testDennis Lee Bieber
| |  `* Re: some problems for an introductory python testHope Rouselle
| |   `- Re: some problems for an introductory python testHope Rouselle
| `* Re: some problems for an introductory python testTerry Reedy
|  `* Re: some problems for an introductory python testHope Rouselle
|   +* Re: some problems for an introductory python testTerry Reedy
|   |+* Re: some problems for an introductory python testGreg Ewing
|   ||`* Re: some problems for an introductory python testHope Rouselle
|   || `* Re: some problems for an introductory python testCameron Simpson
|   ||  `- Re: some problems for an introductory python testGreg Ewing
|   |`- Re: some problems for an introductory python testHope Rouselle
|   +- Re: some problems for an introductory python testWolfram Hinderer
|   +- Re: some problems for an introductory python testMRAB
|   +- Re: some problems for an introductory python testRob Cliffe
|   `- Re: some problems for an introductory python testChris Angelico
+- Re: some problems for an introductory python testChris Angelico
+- Re: some problems for an introductory python testMats Wichmann
+* Re: some problems for an introductory python testChris Angelico
|+* Re: some problems for an introductory python testHope Rouselle
||+* Re: some problems for an introductory python testChris Angelico
|||`* Re: some problems for an introductory python testHope Rouselle
||| +* Re: some problems for an introductory python testDennis Lee Bieber
||| |`* Re: some problems for an introductory python testHope Rouselle
||| | `* Re: some problems for an introductory python testDennis Lee Bieber
||| |  `- Re: some problems for an introductory python testHope Rouselle
||| `* Re: some problems for an introductory python testChris Angelico
|||  `- Re: some problems for an introductory python testHope Rouselle
||+* Re: some problems for an introductory python testChris Angelico
|||`* Re: some problems for an introductory python testHope Rouselle
||| +* Re: some problems for an introductory python testChris Angelico
||| |`* Re: some problems for an introductory python testHope Rouselle
||| | `* Re: some problems for an introductory python testChris Angelico
||| |  `- Re: some problems for an introductory python testHope Rouselle
||| +- Re: some problems for an introductory python testChris Angelico
||| +- Re: some problems for an introductory python testMRAB
||| +- Re: some problems for an introductory python testDennis Lee Bieber
||| +- Re: some problems for an introductory python testGrant Edwards
||| +- Re: some problems for an introductory python testDennis Lee Bieber
||| `- Re: some problems for an introductory python testCameron Simpson
||`- RE: some problems for an introductory python testAvi Gross
|`* Re: some problems for an introductory python testGrant Edwards
| +- Re: some problems for an introductory python testGreg Ewing
| `- Re: some problems for an introductory python testHope Rouselle
`- Re: some problems for an introductory python testAbhiram R

Pages:123
some problems for an introductory python test

<868s1acoo1.fsf@jevedi.xotimo>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14526&group=comp.lang.python#14526

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!O+egF2pf/b2T5ScsCS4ncA.user.46.165.242.75.POSTED!not-for-mail
From: hrouse...@jevedi.xotimo (Hope Rouselle)
Newsgroups: comp.lang.python
Subject: some problems for an introductory python test
Date: Mon, 09 Aug 2021 18:07:42 -0300
Organization: Aioe.org NNTP Server
Message-ID: <868s1acoo1.fsf@jevedi.xotimo>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="54075"; posting-host="O+egF2pf/b2T5ScsCS4ncA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:AFCsO2T044WsY9bxDPmmmJDtI9I=
 by: Hope Rouselle - Mon, 9 Aug 2021 21:07 UTC

I'm looking for questions to put on a test for students who never had
any experience with programming, but have learned to use Python's
procedures, default arguments, if-else, strings, tuples, lists and
dictionaries. (There's no OOP at all in this course. Students don't
even write ls.append(...). They write list.append(ls, ...)).

I'd like to put questions that they would have to write procedures that
would would be real-world type of stuff, without error checking,
exceptions and such. So if you think of something more or less cool
that uses loops, we can sometimes simplify it by assuming the input has
a certain fixed size.

I came up with the following question. Using strings of length 5
(always), write a procedure histogram(s) that consumes a string and
produces a dictionary whose keys are each substrings (of the string) of
length 1 and their corresponding values are the number of times each
such substrings appear. For example, histogram("aaaaa") = {"a": 5}.
Students can "loop through" the string by writing out s[0], s[1], s[2],
s[3], s[4].

I'd like even better questions. I'd like questions that would tell them
to write procedures that would also have inverses, so that one could
check the other of the other. (A second question would ask for the
inverse, but hopefully real world stuff. One such question could be
parsing a line separate by fields such as "root:0:0:mypass:Super User"
and another that gives them ["root", 0, 0, ...] and asks them to write
"root:0:0:mypass:..." You get the idea.)

Students know how to use str(). But they don't know how to use type(),
so they can't really check for the type of the input. I probably
couldn't ask them to write a prototype of a tiny subset of pickle, say.

I think you get the idea. I hope you can provide me with creativity. I
have been looking at books, but every one I look at they introduce loops
very quickly and off they go. Thank you!

Re: some problems for an introductory python test

<mailman.337.1628546415.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14528&group=comp.lang.python#14528

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Tue, 10 Aug 2021 08:00:02 +1000
Lines: 20
Message-ID: <mailman.337.1628546415.4164.python-list@python.org>
References: <868s1acoo1.fsf@jevedi.xotimo>
<CAPTjJmrFwxAwfPTYCwiCds8myD_0q7sgvzgcJZhoVsm9w9cqSQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de hBlHxb7M6Jjyn7RF/Y1tJQG7y4X21vyWE3eh4IAvhDJg==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=c5UpIcbe;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.046
X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'string': 0.05;
'subject:python': 0.06; 'aug': 0.09; 'subject:test': 0.09;
'chrisa': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris
angelico': 0.16; 'idea.': 0.16; 'loops': 0.16;
'received:209.85.166.53': 0.16; 'received:mail-
io1-f53.google.com': 0.16; 'wrote:': 0.16; 'values': 0.16; 'tue,':
0.18; 'to:addr:python-list': 0.23; 'probably': 0.24; 'seems':
0.26; 'length': 0.27; 'think': 0.31; 'but': 0.31; 'question.':
0.31; 'to:name:python': 0.32; 'message-id:@mail.gmail.com': 0.33;
'using': 0.33; 'received:209.85.166': 0.33; 'header:In-Reply-
To:1': 0.33; 'subject:for': 0.33; 'received:google.com': 0.34;
'example,': 0.35; 'following': 0.35; 'from:addr:gmail.com': 0.35;
'received:209.85': 0.38; 'received:209': 0.38; 'use': 0.38;
'students': 0.40; 'whether': 0.40; 'skip:h 10': 0.61; 'hope':
0.61; '10,': 0.61; 'look': 0.66; 'times': 0.66; 'subject:some':
0.69; "you'll": 0.75; 'quickly': 0.81; '2021': 0.84; 'go.': 0.84;
'strings': 0.84; 'produces': 0.93
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=Fovv6IR7oi5VPNnajpfyGorpWpUn5KEdHiDn+cnq69U=;
b=c5UpIcbeI0mu0hH38i419wn8rWM7v0OJN7/cyirJgchkozVCIuW4NDat6Vkj4iWN5W
tG9K5o5nmPsmsuVck1bPrgujf51AuNRo/9EBW+prH60NMF2uqNGxMxjmKYuQ3RWhDiOs
jDpdykxLrBsoHbPgefrO4iEO2QmQ6RYhtQKz1pOc0yse07Ii7T8YzPKbjKMgA8BTCURU
bTIwBSsKz6OdSiH4akbCV4t8HQLwUTQjc4BWnA+x9lctlEWGSTISjrNllHlEiypTh+CC
K6Oq2vW5+P4Of0FvtFd2wWz7qSpKXQhpJx4NODz408O7Pgcg7Y8ykBXkRVACmVOSGTfE
lwDw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=Fovv6IR7oi5VPNnajpfyGorpWpUn5KEdHiDn+cnq69U=;
b=H4M9xw27I4YsPQp7jyN5wKkYmSQ4TE8a9THVuoZgP1+CISaVKJcojS+P/xQVe8Z6Wb
4h+9MtSRR0aZX8+y7mP7ggS+aBM5IuilKV5JQ0bgvvQe2arXVeTddnjeKG53P8VKeTJC
ZEqJGmWXlFrN71AG1JigJpi26SdQAVZAePVqZEGth7xbRYW4B4iJP3+wxA+8OTShjDLB
L8o9h7xS5XkE3tMllFgTqnQ6aYeF9n7YC6gyC9TBGOMISZUNQ0q4Lmm7b4izwNTjCbJb
DOCsbf2WV7Abej0MxNr3TiOS4U5rksY08ExoYolS4TR4Jjic+X6sgjg7cCUDAp7Z+8Jt
c3Hw==
X-Gm-Message-State: AOAM5325Gd2CVA9MdWnXZCGaZ0YKigupTcL6/X9elevUL7MqKMm34Za5
V9CCDEWIKSd1lbtlrME7vooTNtH5BIDCsY1fQk2Xijuz
X-Google-Smtp-Source: ABdhPJyu5gZUxry7hbLd85HVTjTiePeGSID/dKW3ml7Ql8sGFQsvflOeG7x+dfXxmV4VFvzMJbatC07/t/JrKSAz5wI=
X-Received: by 2002:a05:6638:306:: with SMTP id
w6mr24162261jap.132.1628546413717;
Mon, 09 Aug 2021 15:00:13 -0700 (PDT)
In-Reply-To: <868s1acoo1.fsf@jevedi.xotimo>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAPTjJmrFwxAwfPTYCwiCds8myD_0q7sgvzgcJZhoVsm9w9cqSQ@mail.gmail.com>
X-Mailman-Original-References: <868s1acoo1.fsf@jevedi.xotimo>
 by: Chris Angelico - Mon, 9 Aug 2021 22:00 UTC

On Tue, Aug 10, 2021 at 7:25 AM Hope Rouselle <hrouselle@jevedi.xotimo> wrote:
> I came up with the following question. Using strings of length 5
> (always), write a procedure histogram(s) that consumes a string and
> produces a dictionary whose keys are each substrings (of the string) of
> length 1 and their corresponding values are the number of times each
> such substrings appear. For example, histogram("aaaaa") = {"a": 5}.
> Students can "loop through" the string by writing out s[0], s[1], s[2],
> s[3], s[4].

In other words, recreate collections.Counter? Seems decent, but you'll
need to decide whether you want them to use defaultdict, use
__missing__, or do it all manually.

> I think you get the idea. I hope you can provide me with creativity. I
> have been looking at books, but every one I look at they introduce loops
> very quickly and off they go. Thank you!

Probably because loops are kinda important? :)

ChrisA

Re: some problems for an introductory python test

<mailman.338.1628547469.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14529&group=comp.lang.python#14529

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: mat...@wichmann.us (Mats Wichmann)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Mon, 9 Aug 2021 16:14:14 -0600
Lines: 56
Message-ID: <mailman.338.1628547469.4164.python-list@python.org>
References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de +G6jIgb3ushwsyaUfOibww9lZaVGSOH8lhQaatblYjlg==
Return-Path: <mats@wichmann.us>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="1024-bit key; unprotected key"
header.d=pobox.com header.i=@pobox.com header.b=vaSZ27KU;
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.015
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; "python's": 0.05;
'subject:python': 0.06; 'oop,': 0.09; 'subject:test': 0.09;
'(over': 0.16; "(there's": 0.16; 'but...': 0.16; 'hides': 0.16;
'integer': 0.16; 'list()': 0.16; 'oop': 0.16; 'procedures,': 0.16;
'received:64.147': 0.16; 'strings,': 0.16; 'tuples,': 0.16;
'wrote:': 0.16; 'syntax': 0.16; 'python': 0.16; 'supported': 0.18;
'pm,': 0.20; 'programming': 0.21; 'object': 0.23; "i'd": 0.23;
'to:addr:python-list': 0.23; 'anything': 0.24; '>>>': 0.26;
'course.': 0.27; 'programming,': 0.27; 'creating': 0.27;
'default': 0.28; 'header:User-Agent:1': 0.31; 'it,': 0.31;
'there': 0.31; 'but': 0.31; "i'm": 0.32; 'class': 0.33; 'header
:In-Reply-To:1': 0.33; 'subject:for': 0.33; 'complex': 0.35;
'way': 0.37; 'lists': 0.37; "it's": 0.38; 'received:209': 0.38;
'use': 0.38; 'does': 0.38; 'put': 0.39; 'list': 0.39; 'students':
0.40; 'test': 0.40; 'could': 0.40; 'ago': 0.40; 'pretty': 0.40;
"skip:' 10": 0.40; "skip:' 20": 0.40; 'sorry': 0.61; 'hope': 0.61;
'everything': 0.64; 'experience': 0.64; 'received:64': 0.65;
'received:us': 0.65; 'great': 0.67; 'now,': 0.67; 'letting': 0.69;
'oriented': 0.69; 'subject:some': 0.69; 'commercial': 0.77;
'convenience': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=to
:references:from:subject:message-id:date:mime-version
:in-reply-to:content-type:content-transfer-encoding; s=sasl; bh=
/hiXH8Yi2JR0yZPL+1+KpqjoN453YkVOipuNoEUNhlI=; b=vaSZ27KUdeHxEFtd
H/tu3FKyHF67y6ZOnbULTEpzsEYlZ6NXLA9ppyWbBiXdGYTsx2B7OWHEaOQyEt9b
DDRzvAQqYWpi9HgiePSTOsmnPIiLFz9TDNoCdbXGrzlaz7SGVU07AtuzQv5aqmka
ff433khxNk41s3ER0cU9iF0MEEk=
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=wichmann.us;
h=to:references:from:subject:message-id:date:mime-version:in-reply-to:content-type:content-transfer-encoding;
s=2018-07.pbsmtp; bh=N9rY5la7NVlEvPV967v306Zcd6ZZPpUJXTu+xLyr/98=;
b=oeTb3cviMoM+6MXaedyeIEO2tmvPsyqLUHLExzb111QXuuI3/6f42D5N1Pb/ZPlKQ2riPph8kC4ass8ZbrL0qeRVffcZsaCEvpWsMkwPtwH9sv3ColPLKlpIIkKFiY9uqTQmh1tQADUW3RWExbZua5CJSzkqBkH/T5iwZPaapP4=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
In-Reply-To: <868s1acoo1.fsf@jevedi.xotimo>
Content-Language: en-US
X-Pobox-Relay-ID: 225D0BD4-F95F-11EB-B62A-8B3BC6D8090B-81526775!pb-smtp1.pobox.com
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
X-Mailman-Original-References: <868s1acoo1.fsf@jevedi.xotimo>
 by: Mats Wichmann - Mon, 9 Aug 2021 22:14 UTC

On 8/9/21 3:07 PM, Hope Rouselle wrote:
> I'm looking for questions to put on a test for students who never had
> any experience with programming, but have learned to use Python's
> procedures, default arguments, if-else, strings, tuples, lists and
> dictionaries. (There's no OOP at all in this course. Students don't
> even write ls.append(...). They write list.append(ls, ...)).

Nitpickery... there *is* OOP in the course, they just don't know it.

Long long ago (over 20 yrs now) I developed a Python course for a
commercial training provider, and in it I claimed one of the great
things about Python was it supported all kinds of object oriented
programming techniques, but you could also use it without doing anything
object oriented. If I wrote a course now, I'd never make that claim,
because everything you do in Python is pretty much object oriented.

>>> x = list()
>>> type(x)
<class 'list'>
>>> dir(x)
['__add__', '__class__', '__class_getitem__', '__contains__',
'__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__',
'__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__',
'__hash__', '__iadd__', '__imul__', '__init__', '__init_subclass__',
'__iter__', '__le__', '__len__', '
__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__',
'__sizeof__', '__str__', '__subclasshook__', 'append', 'clear', 'copy',
'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']

list is a class and it has methods... it's "object-oriented"!

Even if you do

x = 2 + 3

you're actually creating an integer object with a value of 2, and
calling its add method to add the integer object with the value of 3 to
it. The syntax hides it, but in a way it's just convenience that it does
so...

>>> 2 + 3
5 >>> x = 2
>>> x.__add__(3)
5

sorry for nitpicking :) But... don't be afraid of letting them know
it's OOP, and it''s not huge and complex and scary!

Re: some problems for an introductory python test

<mailman.339.1628555708.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14530&group=comp.lang.python#14530

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Tue, 10 Aug 2021 10:34:54 +1000
Lines: 35
Message-ID: <mailman.339.1628555708.4164.python-list@python.org>
References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<CAPTjJmoQqPErXw2WAN-FgjZq3k2AnZLEYvOruyRJ0r7nNcRCnA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de +/Svk9AwCHM6YjUJAwaQAQjRZkaHe/QOJzZrcaLBEB5w==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=GLGhSgek;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.020
X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'subject:python': 0.06;
'aug': 0.09; 'methods,': 0.09; 'oop,': 0.09; 'subject:test': 0.09;
'but...': 0.16; 'chrisa': 0.16; 'from:addr:rosuav': 0.16;
'from:name:chris angelico': 0.16; 'hides': 0.16; 'instead.': 0.16;
'integer': 0.16; 'mats': 0.16; 'oop': 0.16; 'slot': 0.16;
'things,': 0.16; 'wichmann': 0.16; 'wrote:': 0.16; 'syntax': 0.16;
'tue,': 0.18; 'way.': 0.20; 'python,': 0.21; 'classes': 0.23;
'object': 0.23; "i'd": 0.23; 'to:addr:python-list': 0.23; '>>>':
0.26; 'creating': 0.27; "isn't": 0.29; 'it,': 0.31; 'but': 0.31;
'nature': 0.32; 'to:name:python': 0.32; 'message-
id:@mail.gmail.com': 0.33; 'received:209.85.166': 0.33; 'header
:In-Reply-To:1': 0.33; 'subject:for': 0.33; 'same': 0.34;
'received:google.com': 0.34; "we're": 0.35; 'complex': 0.35;
'from:addr:gmail.com': 0.35; 'able': 0.36; 'two': 0.37; 'way':
0.37; 'received:209.85': 0.38; "it's": 0.38; 'received:209': 0.38;
'does': 0.38; 'among': 0.61; 'sorry': 0.61; '10,': 0.61; 'gives':
0.63; 'look': 0.66; 'plus': 0.68; 'adds': 0.69; 'exists': 0.69;
'letting': 0.69; 'result,': 0.69; 'slots': 0.69; 'subject:some':
0.69; 'highlight': 0.77; '2021': 0.84; 'convenience': 0.91;
'magic': 0.93
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=hkb47JIJYOm1Jn9l+VcODaJX5Aa7VSPY3Uh4gHoXGmM=;
b=GLGhSgekE9CS8WhXG/+HOYipcbRNFRHY+czIy5Z5STlRMW1usODvN4WsxFXDgHsICM
552I4TcG3us6ge+OH4Ct4yQHSdccJApwYdFyUHnuh9wqWevONU9vx/845UPyOiBNLIvT
ieVMLx8+QCFS3JwMkPn9OBCcw8sUB4lwPO7lMXPE4fELMJwNvcjN+/4ZGFUEiPlvDmxR
hbWyW5AS8XXGO8w8zo03xVXKbt8c/ZEEMKUz5dhk6WmIDGIIfBeLIDXQhoYAzG/BTJKv
wGy1aH7nacXiRQnqSru7YVxklLttbHbVwJbGKJEbikU/gnCVQ869hpUNt0QXvdque0Xi
YWRg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=hkb47JIJYOm1Jn9l+VcODaJX5Aa7VSPY3Uh4gHoXGmM=;
b=V0tdbI1IWTBn6Bal2W230ft1jMMLaytboMjaeyRGk3Y3fD7XV0lihCR4mk/74ycBcb
NzvadI2wxqwj6t7UyeN003LTMVJH4dSb9yuYZV5c/1eVbsMksG3Kc3xVeIQhCA+IekCN
raa7b9nC8HS7/l3jvZnodjsRQz9YgAO4M0qTmRDgfhCIZV5GzQyL2EnMrCacp7mQ3vyq
GfYY/1E9fKVPQ7os35eoWLDyMQG8/+PZQv54vKfWYhDPusHt1dlFVzckZkxXxvE8/ajm
pT7E5iXgZWnO9eHdM1ndFjZasN70wTtitjKmooiLsMnE0WtnVy3UX/A8sYI0dIgDmIO0
lAJg==
X-Gm-Message-State: AOAM531/wuuD/wfw7+VQ8sugeRuGacpxozbAUfO3dagNPA7wn45/txMq
dX4n9lrv6Jm+PMz2+WknzH69e5KY35qpMXd5Txm1ms78
X-Google-Smtp-Source: ABdhPJwbWAbq5zXj9qXBMFCGo/9aUTpPQJTpSzdVzUd1nrlzUkmGFqXZWvQ/UqJjch1YyCxH6NMqkogZWLSP0gj+x3A=
X-Received: by 2002:a92:3f0b:: with SMTP id m11mr95440ila.265.1628555705155;
Mon, 09 Aug 2021 17:35:05 -0700 (PDT)
In-Reply-To: <9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAPTjJmoQqPErXw2WAN-FgjZq3k2AnZLEYvOruyRJ0r7nNcRCnA@mail.gmail.com>
X-Mailman-Original-References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
 by: Chris Angelico - Tue, 10 Aug 2021 00:34 UTC

On Tue, Aug 10, 2021 at 8:19 AM Mats Wichmann <mats@wichmann.us> wrote:
> Even if you do
>
> x = 2 + 3
>
> you're actually creating an integer object with a value of 2, and
> calling its add method to add the integer object with the value of 3 to
> it. The syntax hides it, but in a way it's just convenience that it does
> so...
>
> >>> 2 + 3
> 5
> >>> x = 2
> >>> x.__add__(3)
> 5
>
>
> sorry for nitpicking :) But... don't be afraid of letting them know
> it's OOP, and it''s not huge and complex and scary!
>

Since we're nitpicking already, "2 + 3" isn't the same as
"(2).__add__(3)"; among other things, it's able to call
(3).__radd__(2) instead. Plus there's technicalities about type slots
and such.

If you want to highlight the OOP nature of Python, rather than looking
at magic methods, I'd first look at polymorphism. You can add a pair
of integers; you can add a pair of tuples; you can add a pair of
strings. Each one logically adds two things together and gives a
result, and they're all spelled the exact same way. Dunder methods are
a way for custom classes to slot into that same polymorphism, but the
polymorphism exists first and the dunders come later.

ChrisA

Re: some problems for an introductory python test

<mailman.340.1628566783.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14531&group=comp.lang.python#14531

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: mat...@wichmann.us (Mats Wichmann)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Mon, 9 Aug 2021 21:39:37 -0600
Lines: 17
Message-ID: <mailman.340.1628566783.4164.python-list@python.org>
References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<CAPTjJmoQqPErXw2WAN-FgjZq3k2AnZLEYvOruyRJ0r7nNcRCnA@mail.gmail.com>
<c495f0ee-cc76-709c-e2fb-7dde4567d853@wichmann.us>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de FtnBtGMVrHZLI7M+Oi2U5gFT9SnALmdczDzJGZkIFGrg==
Return-Path: <mats@wichmann.us>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="1024-bit key; unprotected key"
header.d=pobox.com header.i=@pobox.com header.b=lCYUq4md;
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.023
X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'subject:python': 0.06;
'angelico': 0.09; 'deeper': 0.09; 'it"': 0.09; 'methods,': 0.09;
'subject:test': 0.09; 'chrisa': 0.16; 'oop': 0.16;
'received:64.147': 0.16; 'slot': 0.16; 'wrote:': 0.16; 'pm,':
0.20; 'way.': 0.20; 'python,': 0.21; 'classes': 0.23; "i'd": 0.23;
'to:addr:python-list': 0.23; 'chris': 0.26; "didn't": 0.29;
'header:User-Agent:1': 0.31; 'think': 0.31; 'but': 0.31; 'nature':
0.32; 'realize': 0.32; 'header:In-Reply-To:1': 0.33;
'subject:for': 0.33; 'same': 0.34; 'two': 0.37; 'way': 0.37;
'received:209': 0.38; 'could': 0.40; 'gives': 0.63; 'received:64':
0.65; 'received:us': 0.65; 'look': 0.66; 'adds': 0.69; 'exists':
0.69; 'result,': 0.69; 'subject:some': 0.69; 'highlight': 0.77;
'magic': 0.93
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=subject:to
:references:from:message-id:date:mime-version:in-reply-to
:content-type:content-transfer-encoding; s=sasl; bh=CH/AMuwNFw7H
dL4rkva9RSjELxnu6XViH/XMmUazFwM=; b=lCYUq4mdgMlRGasS2ZAlA5NVClQ+
/OAoiP37mHUaD4Ijpbsf/0z9me7Uj2vw43MqmIsTPaofXyb2mgU8RLP9VHsmlGIZ
P3az9dxnL9PhNfgO3SkpN2wmnz8fdr8oxoedbTdI4F93ao6KEOsbIlrajnHgII5H
9nLDC0j5/Be5yak=
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=wichmann.us;
h=subject:to:references:from:message-id:date:mime-version:in-reply-to:content-type:content-transfer-encoding;
s=2018-07.pbsmtp; bh=CH/AMuwNFw7HdL4rkva9RSjELxnu6XViH/XMmUazFwM=;
b=cC7Af1APnYrW7dB1majYMCwUrEQrRlng/roWxFGzu6LGkBC/lBJUP84oPLCrPZ8u4ExvtMfUAVvuEzv0YfqWEdwfBpDufgYmdejjG9XpP/WgWFUVsHwVcS7xY38X9dgnd5L+UlGVcTpqx1gUMTt9nIDwlmevJ0gArzskZS9V/p8=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
In-Reply-To: <CAPTjJmoQqPErXw2WAN-FgjZq3k2AnZLEYvOruyRJ0r7nNcRCnA@mail.gmail.com>
Content-Language: en-US
X-Pobox-Relay-ID: 96C175BE-F98C-11EB-97E7-8B3BC6D8090B-81526775!pb-smtp1.pobox.com
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <c495f0ee-cc76-709c-e2fb-7dde4567d853@wichmann.us>
X-Mailman-Original-References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<CAPTjJmoQqPErXw2WAN-FgjZq3k2AnZLEYvOruyRJ0r7nNcRCnA@mail.gmail.com>
 by: Mats Wichmann - Tue, 10 Aug 2021 03:39 UTC

On 8/9/21 6:34 PM, Chris Angelico wrote:

> If you want to highlight the OOP nature of Python, rather than looking
> at magic methods, I'd first look at polymorphism. You can add a pair
> of integers; you can add a pair of tuples; you can add a pair of
> strings. Each one logically adds two things together and gives a
> result, and they're all spelled the exact same way. Dunder methods are
> a way for custom classes to slot into that same polymorphism, but the
> polymorphism exists first and the dunders come later.
>
> ChrisA
>

not disagreeing... and yeah I could have thought deeper about the
answer, but I still think "notthing has been OOP" -> "yes it has, they
just didn't realize it" was worth mentioning

Re: some problems for an introductory python test

<mailman.341.1628569106.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14532&group=comp.lang.python#14532

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!news.szaf.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Tue, 10 Aug 2021 14:18:13 +1000
Lines: 23
Message-ID: <mailman.341.1628569106.4164.python-list@python.org>
References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<CAPTjJmoQqPErXw2WAN-FgjZq3k2AnZLEYvOruyRJ0r7nNcRCnA@mail.gmail.com>
<c495f0ee-cc76-709c-e2fb-7dde4567d853@wichmann.us>
<CAPTjJmo_zoqB1MbbmzsAMLUGVcevs1Nz-cJk0Y6-Q7typbP3Mw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de VsquuZ/Pra0ddE0jjCLJSgSVFV5RwFNeKSRA0i6RNmYw==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=OTxeuU+8;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.012
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:python': 0.06;
'angelico': 0.09; 'aug': 0.09; 'deeper': 0.09; 'it"': 0.09;
'methods,': 0.09; 'subject:test': 0.09; 'chrisa': 0.16;
'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16;
'mats': 0.16; 'oop': 0.16; 'slot': 0.16; 'wichmann': 0.16;
'wrote:': 0.16; 'tue,': 0.18; 'pm,': 0.20; 'way.': 0.20;
'python,': 0.21; 'classes': 0.23; "i'd": 0.23; 'to:addr:python-
list': 0.23; 'chris': 0.26; "didn't": 0.29; 'think': 0.31; 'but':
0.31; 'nature': 0.32; 'realize': 0.32; 'to:name:python': 0.32;
'message-id:@mail.gmail.com': 0.33; 'received:209.85.166': 0.33;
'header:In-Reply-To:1': 0.33; 'subject:for': 0.33; 'same': 0.34;
'received:google.com': 0.34; 'yes,': 0.35; 'from:addr:gmail.com':
0.35; 'two': 0.37; 'way': 0.37; 'received:209.85': 0.38;
'received:209': 0.38; 'could': 0.40; '10,': 0.61; 'gives': 0.63;
'look': 0.66; 'adds': 0.69; 'exists': 0.69; 'result,': 0.69;
'subject:some': 0.69; 'highlight': 0.77; '2021': 0.84;
'absolutely': 0.84; 'magic': 0.93
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=3Jb6uJWpRIHPdtcgEHpqjQcRe1TyQ4Dnv+R0Q0/aut8=;
b=OTxeuU+8zlfE8BLS0z+VsMZG5F/J6VZN5ZR+86aL9GUXqi6KFRwU6lzXSOtrfmnK+a
NYlS5E5+axeKPIIRI5/wy/rhJrvGcH72DtsXIRuDOPOJvt6iZmnwtWlxUgzlcS1NjK5s
BhbfehqupBTQ9jgR2N5hcSibHt5oGAi7HRfjDmfVQxHRbhbGsyTJtd5cZj2tFCxOU72Y
FurqTnfpUl3Gj+sq4r5EVJ6jMtxJ3lMwGEuLqbozvwjxO9ogyXAXLwyL4RhFM0u4cAAz
amK6is0T/9GrDX5MIdSlsHYqVEG2aFi1YpRSE+8b6qGZqKCiYOJKPoIJV7WnPzjz7Uyb
e+/g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=3Jb6uJWpRIHPdtcgEHpqjQcRe1TyQ4Dnv+R0Q0/aut8=;
b=dz3/JRjV7nSucWVcMSKTHQCr+c8ugQ64O5Q4PPTJ+TjhHGPLrXA66S+DdFaftWj0xI
PLlKyDVxQ1Ki4bOKEwr8z4EBG/2HpetoAS838mL9ygRDYtRItv6Nckl/bLHW6kYj3be5
qokheT8Thp1/A5Qyur4JgzUnkbvyM2zTWtQJJyPu6csYSHAAp8oFksMhuKlpBq/1pPV5
N55R6wHpi4ZLvxb0T6ruu4dsHQiG8O0HChz8HESOaHDNBldtiJcpBOdMQDQbmA0aLrs7
eI+M/IVgSxo1ToyJ8DcrUv0Il6MsjTOCZN1KrFBrFVcWic0l21eG6OAXfJkkTrplCEJb
z7Rw==
X-Gm-Message-State: AOAM533ver3Awil6Apjqe+We06jwAorGsUwFd7Dgsdmlh+z+5dboxNGb
iLrsGKlUbzfsV/kzVqTwUwUjzJOCNtRdiPrSKqzhlLEF
X-Google-Smtp-Source: ABdhPJyny9XUWChYPxF3bk4Jk+e/w5RNnGyLeyNAuO8pgeE1JVvFkNmLO2WQhsGOOJms/2OH1X+jmo8Td/QUQUeQ9yU=
X-Received: by 2002:a02:2a07:: with SMTP id w7mr25476687jaw.96.1628569104658;
Mon, 09 Aug 2021 21:18:24 -0700 (PDT)
In-Reply-To: <c495f0ee-cc76-709c-e2fb-7dde4567d853@wichmann.us>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAPTjJmo_zoqB1MbbmzsAMLUGVcevs1Nz-cJk0Y6-Q7typbP3Mw@mail.gmail.com>
X-Mailman-Original-References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<CAPTjJmoQqPErXw2WAN-FgjZq3k2AnZLEYvOruyRJ0r7nNcRCnA@mail.gmail.com>
<c495f0ee-cc76-709c-e2fb-7dde4567d853@wichmann.us>
 by: Chris Angelico - Tue, 10 Aug 2021 04:18 UTC

On Tue, Aug 10, 2021 at 1:41 PM Mats Wichmann <mats@wichmann.us> wrote:
>
>
> On 8/9/21 6:34 PM, Chris Angelico wrote:
>
> > If you want to highlight the OOP nature of Python, rather than looking
> > at magic methods, I'd first look at polymorphism. You can add a pair
> > of integers; you can add a pair of tuples; you can add a pair of
> > strings. Each one logically adds two things together and gives a
> > result, and they're all spelled the exact same way. Dunder methods are
> > a way for custom classes to slot into that same polymorphism, but the
> > polymorphism exists first and the dunders come later.
> >
> > ChrisA
> >
>
> not disagreeing... and yeah I could have thought deeper about the
> answer, but I still think "notthing has been OOP" -> "yes it has, they
> just didn't realize it" was worth mentioning

Oh yes, absolutely agree.

ChrisA

Re: some problems for an introductory python test

<868s19bh70.fsf@jevedi.xotimo>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14534&group=comp.lang.python#14534

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!LrhSxzwDgsLbOh6Rhfo3Cw.user.46.165.242.75.POSTED!not-for-mail
From: hrouse...@jevedi.xotimo (Hope Rouselle)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Tue, 10 Aug 2021 09:46:43 -0300
Organization: Aioe.org NNTP Server
Message-ID: <868s19bh70.fsf@jevedi.xotimo>
References: <868s1acoo1.fsf@jevedi.xotimo>
<CAPTjJmrFwxAwfPTYCwiCds8myD_0q7sgvzgcJZhoVsm9w9cqSQ@mail.gmail.com>
<mailman.337.1628546415.4164.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="42786"; posting-host="LrhSxzwDgsLbOh6Rhfo3Cw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:PuEjJDKsCOmT2Id25krYDO8Vgck=
 by: Hope Rouselle - Tue, 10 Aug 2021 12:46 UTC

Chris Angelico <rosuav@gmail.com> writes:

> On Tue, Aug 10, 2021 at 7:25 AM Hope Rouselle <hrouselle@jevedi.xotimo> wrote:
>> I came up with the following question. Using strings of length 5
>> (always), write a procedure histogram(s) that consumes a string and
>> produces a dictionary whose keys are each substrings (of the string) of
>> length 1 and their corresponding values are the number of times each
>> such substrings appear. For example, histogram("aaaaa") = {"a": 5}.
>> Students can "loop through" the string by writing out s[0], s[1], s[2],
>> s[3], s[4].
>
> In other words, recreate collections.Counter? Seems decent, but you'll
> need to decide whether you want them to use defaultdict, use
> __missing__, or do it all manually.

Yes, the course introduces very little so there is a lot of recreation
going on. Hm, I don't know defaultdict and I don't know how to use
__missing__. The course does introduce dict.get(), though. If students
use dict.get(), then the procedure could essentially be:

def histogram(s):
d = {}
d[s[0]] = d.get(s[0], 0) + 1
d[s[1]] = d.get(s[1], 0) + 1
d[s[2]] = d.get(s[2], 0) + 1
d[s[3]] = d.get(s[3], 0) + 1
d[s[4]] = d.get(s[4], 0) + 1
return d

>> I think you get the idea. I hope you can provide me with creativity. I
>> have been looking at books, but every one I look at they introduce loops
>> very quickly and off they go. Thank you!
>
> Probably because loops are kinda important? :)

Totally important. But each course author thinks they know better.
Sometimes a college professor can do very little to help her students.
I am actually fond of functional programming as a first course using a
language with as little syntax as possible. Python is very nice but
it's not a small language. It's easy to see courses spending an entire
semester on introducing syntax and this one is no different. I think
it's more interesting to see all the syntax in a few minutes and spend
the semester on strategies.

Re: some problems for an introductory python test

<86sfzha1ac.fsf@jevedi.xotimo>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14535&group=comp.lang.python#14535

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!LrhSxzwDgsLbOh6Rhfo3Cw.user.46.165.242.75.POSTED!not-for-mail
From: hrouse...@jevedi.xotimo (Hope Rouselle)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Tue, 10 Aug 2021 10:15:39 -0300
Organization: Aioe.org NNTP Server
Message-ID: <86sfzha1ac.fsf@jevedi.xotimo>
References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<mailman.338.1628547469.4164.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="4084"; posting-host="LrhSxzwDgsLbOh6Rhfo3Cw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:1a9x7OtIHsuh5AjOLEUDFcMAw8Y=
 by: Hope Rouselle - Tue, 10 Aug 2021 13:15 UTC

Mats Wichmann <mats@wichmann.us> writes:

> On 8/9/21 3:07 PM, Hope Rouselle wrote:
>> I'm looking for questions to put on a test for students who never had
>> any experience with programming, but have learned to use Python's
>> procedures, default arguments, if-else, strings, tuples, lists and
>> dictionaries. (There's no OOP at all in this course. Students don't
>> even write ls.append(...). They write list.append(ls, ...)).
>
> Nitpickery... there *is* OOP in the course, they just don't know it.
>
> Long long ago (over 20 yrs now) I developed a Python course for a
> commercial training provider, and in it I claimed one of the great
> things about Python was it supported all kinds of object oriented
> programming techniques, but you could also use it without doing
> anything object oriented. If I wrote a course now, I'd never make that
> claim, because everything you do in Python is pretty much object
> oriented.
>
>>>> x = list()
>>>> type(x)
> <class 'list'>
>>>> dir(x)
> ['__add__', '__class__', '__class_getitem__', '__contains__',
> '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__',
> '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__',
> '__hash__', '__iadd__', '__imul__', '__init__', '__init_subclass__',
> '__iter__', '__le__', '__len__', '
> __lt__', '__mul__', '__ne__', '__new__', '__reduce__',
> '__reduce_ex__', '__repr__', '__reversed__', '__rmul__',
> '__setattr__', '__setitem__', '__sizeof__', '__str__',
> '__subclasshook__', 'append', 'clear', 'copy', 'count', 'extend',
> 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
>
> list is a class and it has methods... it's "object-oriented"!
>
>
> Even if you do
>
> x = 2 + 3
>
> you're actually creating an integer object with a value of 2, and
> calling its add method to add the integer object with the value of 3
> to it. The syntax hides it, but in a way it's just convenience that it
> does so...
>
>>>> 2 + 3
> 5
>>>> x = 2
>>>> x.__add__(3)
> 5
>
>
> sorry for nitpicking :) But... don't be afraid of letting them know
> it's OOP, and it''s not huge and complex and scary!

I totally agree with you but I didn't know that even numbers were like
that in Python. In fact, I still don't quite believe it...

>>> 2.__add__(3)
SyntaxError: invalid syntax

But then I tried:

>>> (2).__add__(3)
5

Now I do believe it! :-) Awesome. I had no idea.

(*) More opinions

So, yeah, the idea of a course like that is to try to simplify the world
to students, but it totally backfires in my opinion. There is so much
syntax to learn, so many little details... We spend the entire semester
discussing these little details.

I posted here recently a study of the semantics of slices. When I
finally got it, I concluded it's not very simple. The course introduces
a few examples and expects students to get it all from these examples.
I would rather not introduce slices but teach students enough to write
procedures that give them the slices. The slices are the fish; learning
to write the procedures is the know-how. (I'm fine with even teaching
them how to write procedures to add or subtract numbers [and the rest of
arithmetic], although none of them would find mysterious what is the
meaning of arithmetic expressions such as 3 + 6 - 9, even taking
precedence of operators into account. That's syntax they already know.
If we teach them the syntax of procedures, we could be essentially done
with syntax.)

Re: some problems for an introductory python test

<86lf599zse.fsf@jevedi.xotimo>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14536&group=comp.lang.python#14536

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!LrhSxzwDgsLbOh6Rhfo3Cw.user.46.165.242.75.POSTED!not-for-mail
From: hrouse...@jevedi.xotimo (Hope Rouselle)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Tue, 10 Aug 2021 10:48:01 -0300
Organization: Aioe.org NNTP Server
Message-ID: <86lf599zse.fsf@jevedi.xotimo>
References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<CAPTjJmoQqPErXw2WAN-FgjZq3k2AnZLEYvOruyRJ0r7nNcRCnA@mail.gmail.com>
<c495f0ee-cc76-709c-e2fb-7dde4567d853@wichmann.us>
<CAPTjJmo_zoqB1MbbmzsAMLUGVcevs1Nz-cJk0Y6-Q7typbP3Mw@mail.gmail.com>
<mailman.341.1628569106.4164.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="34221"; posting-host="LrhSxzwDgsLbOh6Rhfo3Cw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
Cancel-Lock: sha1:VlVspRXvKU5ngYhT9YHDjpXn0fQ=
X-Notice: Filtered by postfilter v. 0.9.2
 by: Hope Rouselle - Tue, 10 Aug 2021 13:48 UTC

Chris Angelico <rosuav@gmail.com> writes:

[...]

>> not disagreeing... and yeah I could have thought deeper about the
>> answer, but I still think "notthing has been OOP" -> "yes it has, they
>> just didn't realize it" was worth mentioning
>
> Oh yes, absolutely agree.

At the same time, inside the machine nothing is OOP --- so all the OOP
is no OOP at all and they just didn't realize it? This seems to show
that OOP is about perspective. An essential thing for OOP is the
keeping of states. Closures can keep state, so having procedures as
first-class values allows us to say we are doing OOP too. (Arguments of
procedures are messages and function application is message passing,
with closures keeping a state --- and all the rest of OOP can be
implemented with enough such functional technology.) In summary, OOP
should not be defined as some special syntax, otherwise there is no OOP
in ``2 + 2''.

Having said that, I totally agree with all the nitpicking.

Re: some problems for an introductory python test

<slices-20210810181354@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14537&group=comp.lang.python#14537

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: 10 Aug 2021 17:15:14 GMT
Organization: Stefan Ram
Lines: 33
Expires: 1 Dec 2021 11:59:58 GMT
Message-ID: <slices-20210810181354@ram.dialup.fu-berlin.de>
References: <868s1acoo1.fsf@jevedi.xotimo> <9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us> <mailman.338.1628547469.4164.python-list@python.org> <86sfzha1ac.fsf@jevedi.xotimo>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de BwPcB5DRBtXxi+xfpi23pgyCeSkVngP3hyQkpLKtVvJAET
X-Copyright: (C) Copyright 2021 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Tue, 10 Aug 2021 17:15 UTC

Hope Rouselle <hrouselle@jevedi.xotimo> writes:
>I posted here recently a study of the semantics of slices. When I
>finally got it, I concluded it's not very simple.

On December 10, 2017 I posted a procedure "sl" here that
yields (I hope) the same slice values from a sequence
"sequence" as the inbuilt slices.

def wrap( x, length ):
if x < 0: x += length
return x

def clip( x, length, is_negative ):
if x > length - is_negative: x = length - is_negative
if x < 0: x = -is_negative
return x

def clipandwrap( x, length, is_negative ):
x = wrap( x, length )
x = clip( x, length, is_negative )
return x

def sl( sequence, start, top, step ):
is_negative = +( step <= 0 )
clipwrap = lambda var: clipandwrap( var, len( sequence ), is_negative )
start = clipwrap( start )
top = clipwrap( top )
i = start
while i > top if is_negative else i < top:
yield sequence[ i ]
i += step

Re: some problems for an introductory python test

<mailman.342.1628621276.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14538&group=comp.lang.python#14538

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Wed, 11 Aug 2021 04:47:42 +1000
Lines: 90
Message-ID: <mailman.342.1628621276.4164.python-list@python.org>
References: <868s1acoo1.fsf@jevedi.xotimo>
<CAPTjJmrFwxAwfPTYCwiCds8myD_0q7sgvzgcJZhoVsm9w9cqSQ@mail.gmail.com>
<mailman.337.1628546415.4164.python-list@python.org>
<868s19bh70.fsf@jevedi.xotimo>
<CAPTjJmpJRW+AUX6f6DUk7S9nmLPo-f1AG9bnCs=XGBb=7spZpQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de MVlh9N5VyLST/ERP9pKfNwvh4YrF7lNK0zKl3hQhSpsA==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=it6a16Bv;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.007
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'def': 0.04; 'string':
0.05; 'subject:python': 0.06; 'world"': 0.07; '"hello': 0.09;
'angelico': 0.09; 'aug': 0.09; 'else:': 0.09; 'order,': 0.09;
'subject:test': 0.09; 'though.': 0.09; 'writes:': 0.09; 'import':
0.14; 'chrisa': 0.16; 'defaultdict': 0.16; 'from:addr:rosuav':
0.16; 'from:name:chris angelico': 0.16; 'insertion': 0.16;
'introduces': 0.16; 'loops,': 0.16; 'result.': 0.16; 'things,':
0.16; 'wrote:': 0.16; 'values': 0.16; 'tue,': 0.18; 'advanced':
0.23; 'skip:_ 10': 0.23; "what's": 0.23; 'to:addr:python-list':
0.23; 'leave': 0.25; '>>>': 0.26; 'chris': 0.26; 'seems': 0.26;
'11,': 0.27; 'length': 0.27; 'wrong': 0.27; 'use,': 0.29; 'there':
0.31; 'but': 0.31; 'question.': 0.31; 'wondering': 0.32;
'to:name:python': 0.32; 'message-id:@mail.gmail.com': 0.33;
'using': 0.33; 'class': 0.33; 'received:209.85.166': 0.33; 'header
:In-Reply-To:1': 0.33; 'subject:for': 0.33; 'same': 0.34;
'received:google.com': 0.34; 'example,': 0.35; 'following': 0.35;
'yes,': 0.35; 'from:addr:gmail.com': 0.35; 'received:209.85':
0.38; 'others': 0.38; 'received:209': 0.38; 'going': 0.38; 'use':
0.38; 'does': 0.38; 'students': 0.40; 'whether': 0.40; 'could':
0.40; 'skip:h 10': 0.61; 'hope': 0.61; '10,': 0.61; 'here': 0.62;
'lot': 0.62; 'your': 0.64; 'clear': 0.65; 'times': 0.66;
'counter': 0.69; 'subject:some': 0.69; 'shows': 0.70; 'little':
0.75; "you'll": 0.75; 'features': 0.76; '....': 0.81; '2021':
0.84; 'exercise': 0.84; 'recreation': 0.84; 'strings': 0.84;
'retain': 0.91; 'produces': 0.93
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=+6X9x0HZ2KmphwOQysFaE7RImq1rITRJMvqjv1hOlfw=;
b=it6a16BvuSPro728icRyPWPKIEgcBcW2s9GQctuq5U1j8a3VUVnFXR09cDzTmoscPF
bwDHq7XqAtaTC4JPq0MihRvK+U4xOh8GqT17vFDSL6F+/UgYJQUA33lu6ZYdRX8MwPDK
RnqihHWJhhQowWbMjC9X+8sNAi9Dk4y+V8iuCBglDFLLXh+e92Z6Va30AukMvWYMYgo7
KHdm16fHodeO9E5L4ibxCwCX8hs0fCkBEXytnfXdad1TGstx0huCZ7FRuLp4IvOj5rCt
e/GNtzQEubDC3tu6btqiU+2x9FywZ8984ewGnzpG+yVv1adDFQG/mGq0XZgIrmS0CAxX
mIBw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=+6X9x0HZ2KmphwOQysFaE7RImq1rITRJMvqjv1hOlfw=;
b=Gf/ly4QPUM3gGvWljvGmlQND3hjGmYEuP8GMPDNBwuO73MGhCu3LpmqR3g1C8zMSww
fRYQHEb2YUvX7kBEE+hFUErQO4X1Tao6A5lPrCEwXghQa18Wb0YR8EC6cK4IsD1OtrLV
bgKUb/9MKWlR0328GqVrlEwwhpZU5WqgnnqktyPsNPj9kb6sMe1CKw2MIYAWJbpQ4rft
oqjBZq1T2CpXsamC8aQ0lio+Dp8b+xKWW0hHV35i0tDYYBKD3YMdsZXH9QIr5kgYoY3D
7MpIh4729ew2wKFt6XRby009seg2akTeu3CmPBrk2O4QfgIDvvnQ7n2+S/Xgtb/CzuuQ
CjSQ==
X-Gm-Message-State: AOAM530JTuJm2CfZU5ZRG1zodKG8GJQgefWhwNE11GAOP+OAzRrZBdlb
q3U7/lDFHU4uTVRI8UT4nXhWx1SD7L9WR9/J98CPy7k46CI=
X-Google-Smtp-Source: ABdhPJxbcspEpDCFhvBhANQZeDrg6BJ6dR1HGwMcQ42GV1J9R/zUb7XOOXbJfKrkx3mbWMCmqhqEpG+sh5NeS40NXTU=
X-Received: by 2002:a6b:f817:: with SMTP id o23mr356892ioh.205.1628621273330;
Tue, 10 Aug 2021 11:47:53 -0700 (PDT)
In-Reply-To: <868s19bh70.fsf@jevedi.xotimo>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAPTjJmpJRW+AUX6f6DUk7S9nmLPo-f1AG9bnCs=XGBb=7spZpQ@mail.gmail.com>
X-Mailman-Original-References: <868s1acoo1.fsf@jevedi.xotimo>
<CAPTjJmrFwxAwfPTYCwiCds8myD_0q7sgvzgcJZhoVsm9w9cqSQ@mail.gmail.com>
<mailman.337.1628546415.4164.python-list@python.org>
<868s19bh70.fsf@jevedi.xotimo>
 by: Chris Angelico - Tue, 10 Aug 2021 18:47 UTC

On Wed, Aug 11, 2021 at 4:14 AM Hope Rouselle <hrouselle@jevedi.xotimo> wrote:
>
> Chris Angelico <rosuav@gmail.com> writes:
>
> > On Tue, Aug 10, 2021 at 7:25 AM Hope Rouselle <hrouselle@jevedi.xotimo> wrote:
> >> I came up with the following question. Using strings of length 5
> >> (always), write a procedure histogram(s) that consumes a string and
> >> produces a dictionary whose keys are each substrings (of the string) of
> >> length 1 and their corresponding values are the number of times each
> >> such substrings appear. For example, histogram("aaaaa") = {"a": 5}.
> >> Students can "loop through" the string by writing out s[0], s[1], s[2],
> >> s[3], s[4].
> >
> > In other words, recreate collections.Counter? Seems decent, but you'll
> > need to decide whether you want them to use defaultdict, use
> > __missing__, or do it all manually.
>
> Yes, the course introduces very little so there is a lot of recreation
> going on. Hm, I don't know defaultdict and I don't know how to use
> __missing__. The course does introduce dict.get(), though. If students
> use dict.get(), then the procedure could essentially be:
>
> def histogram(s):
> d = {}
> d[s[0]] = d.get(s[0], 0) + 1
> d[s[1]] = d.get(s[1], 0) + 1
> d[s[2]] = d.get(s[2], 0) + 1
> d[s[3]] = d.get(s[3], 0) + 1
> d[s[4]] = d.get(s[4], 0) + 1
> return d

There's nothing wrong with getting students to recreate things, but
there are so many different levels on which you could do this, which
will leave your more advanced students wondering what's legal. :) Here
are several ways to do the same thing:

>>> s = "hello world"

>>> from collections import Counter; Counter(s)
Counter({'l': 3, 'o': 2, 'h': 1, 'e': 1, ' ': 1, 'w': 1, 'r': 1, 'd': 1})

>>> from collections import defaultdict
>>> hist = defaultdict(int)
>>> for ltr in s: hist[ltr] += 1
....
>>> hist
defaultdict(<class 'int'>, {'h': 1, 'e': 1, 'l': 3, 'o': 2, ' ': 1,
'w': 1, 'r': 1, 'd': 1})

>>> class Incrementer(dict):
.... def __missing__(self, key): return 0
....
>>> hist = Incrementer()
>>> for ltr in s: hist[ltr] += 1
....
>>> hist
{'h': 1, 'e': 1, 'l': 3, 'o': 2, ' ': 1, 'w': 1, 'r': 1, 'd': 1}

>>> hist = {}
>>> for ltr in s: hist[ltr] = hist.get(ltr, 0) + 1
....
>>> hist
{'h': 1, 'e': 1, 'l': 3, 'o': 2, ' ': 1, 'w': 1, 'r': 1, 'd': 1}

>>> hist = {}
>>> for ltr in s:
.... if ltr in hist: hist[ltr] += 1
.... else: hist[ltr] = 1
....
>>> hist
{'h': 1, 'e': 1, 'l': 3, 'o': 2, ' ': 1, 'w': 1, 'r': 1, 'd': 1}

>>> hist = {}
>>> for ltr in s:
.... try: hist[ltr] += 1
.... except KeyError: hist[ltr] = 1
....
>>> hist
{'h': 1, 'e': 1, 'l': 3, 'o': 2, ' ': 1, 'w': 1, 'r': 1, 'd': 1}

A Counter shows the values ranked, all the others retain insertion
order, but they all get to the same result.

It seems *very* strange to have an exercise like this without looping.
That seems counterproductive. But if you're expecting them to not use
loops, you'll want to also be very clear about what other features
they're allowed to use - or alternatively, stipulate what they ARE
allowed to use, eg "Use only indexing and the get() method".

ChrisA

Re: some problems for an introductory python test

<mailman.343.1628622186.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14539&group=comp.lang.python#14539

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Wed, 11 Aug 2021 05:02:52 +1000
Lines: 97
Message-ID: <mailman.343.1628622186.4164.python-list@python.org>
References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<mailman.338.1628547469.4164.python-list@python.org>
<86sfzha1ac.fsf@jevedi.xotimo>
<CAPTjJmqA1=LR94juniaMRC=Vi=u0h_Sbneqf0qn1wqgELMRwgw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de UPi/lOC49zhZXdk0gdQ+ZgRwS4hZp4XUz3cUUhu+RQLw==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=dxdMYqO9;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.017
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'students.': 0.03; 'def':
0.04; 'subject:python': 0.06; 'explicitly': 0.07; 'simple.': 0.07;
'python.': 0.07; ':-)': 0.09; 'aspect': 0.09; 'aug': 0.09;
'fact,': 0.09; 'infinite': 0.09; 'operators': 0.09;
'subject:test': 0.09; 'looks': 0.11; 'problem.': 0.14; '(*)':
0.16; "(i'm": 0.16; 'arithmetic': 0.16; 'chrisa': 0.16;
'classes,': 0.16; 'examples.': 0.16; 'expects': 0.16;
'expressions': 0.16; 'frank,': 0.16; 'from:addr:rosuav': 0.16;
'from:name:chris angelico': 0.16; 'idea.': 0.16; 'introduces':
0.16; 'operators:': 0.16; 'procedures,': 0.16; 'renaming': 0.16;
'semantics': 0.16; 'semester': 0.16; 'syntax,': 0.16;
'syntaxerror:': 0.16; 'toy': 0.16; 'transforming': 0.16;
'useless': 0.16; 'wrote:': 0.16; 'syntax': 0.16; 'that.': 0.16;
'python': 0.16; 'it?': 0.18; 'calls': 0.20; 'language': 0.22;
'school': 0.23; 'languages': 0.23; 'skip:_ 10': 0.23; 'teach':
0.23; 'to:addr:python-list': 0.23; 'header': 0.24; 'code': 0.24;
'idea': 0.25; '>>>': 0.26; 'examples': 0.26; 'recently': 0.26;
'register': 0.27; '11,': 0.27; 'done': 0.28; "didn't": 0.29;
"isn't": 0.29; 'it,': 0.31; 'there': 0.31; 'but': 0.31; 'explain':
0.31; 'teaching': 0.31; 'cpu': 0.32; 'right,': 0.32;
'to:name:python': 0.32; 'message-id:@mail.gmail.com': 0.33;
'using': 0.33; 'class': 0.33; 'received:209.85.166': 0.33;
'unless': 0.33; 'work.': 0.33; 'header:In-Reply-To:1': 0.33;
'subject:for': 0.33; 'received:google.com': 0.34; 'complex': 0.35;
'invalid': 0.35; 'from:addr:gmail.com': 0.35; 'able': 0.36;
'work,': 0.37; "that's": 0.37; 'really': 0.37; 'received:209.85':
0.38; 'those': 0.38; "it's": 0.38; 'received:209': 0.38; 'going':
0.38; 'use': 0.38; 'learning': 0.38; 'does': 0.38; 'list': 0.39;
'taking': 0.40; 'students': 0.40; 'enough': 0.40; 'could': 0.40;
'feel': 0.61; 'hope': 0.61; 'entire': 0.61; 'ten': 0.61; 'simply':
0.62; 'here': 0.62; 'lot': 0.62; 'down': 0.62; 'finally': 0.63;
'numbers': 0.63; 'ever': 0.63; 'once': 0.64; 'world': 0.64;
'your': 0.64; 'instead,': 0.65; 'spend': 0.65; 'skip:t 20': 0.67;
'free': 0.68; 'benefit': 0.68; 'order': 0.68; 'account.': 0.69;
'exactly': 0.69; 'discussing': 0.69; 'subject:some': 0.69; 'away':
0.70; 'terms': 0.72; 'know.': 0.72; 'operations': 0.74; 'easy':
0.75; 'little': 0.75; 'skip:f 20': 0.76; 'details.': 0.77; 'left':
0.79; '....': 0.81; '2021': 0.84; '(general': 0.84; 'awesome.':
0.84; 'casting': 0.84; 'internet?': 0.84; 'it...': 0.84; 'learn,':
0.84; 'mysterious': 0.84; 'pretend': 0.84; 'procedures': 0.84;
'worrying': 0.84; 'study': 0.89; 'concluded': 0.91; 'tiny': 0.91;
'magic': 0.93
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=cA+UUxrnAlZPI296FQEzzRF/wjT1muHiggPDJ4gIvyU=;
b=dxdMYqO9o0vzdCZHFoRICnuzdgFRJer5TQtRPgfICzJjGYaSyUrUZz04YcV+B809+p
pmKaNDxMl2wUJXNtaLd2RVp1OjbXNFFyDYmJCyIgy6H4DSwRtiGp/nmskyYZqp44K37a
ontKEyHjdcql5w4StDclF5ofsGSJHYIiFDywniEqbk76xjfG4tiJgXw3aYBMuvQNaPb9
hwNEFYHh5GdKGOOL0b/BubFMb4oe2CR0JWSwaCTIoZZds03zELb04oV09yuXzKKrH1MK
UA7Y23wAGDdiTaDFTOu/M6PAusY7KkUSpdA2CmIUIs+MV8jGyyNtdp2QWAvf+KGYriqc
/nGA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=cA+UUxrnAlZPI296FQEzzRF/wjT1muHiggPDJ4gIvyU=;
b=FWuDOuwAL2MEnG+Zsi3ZbPECuExLzC8Gd2BABy+D8OLHjXJzaCJwXdzubNzAme+jWY
Rkwn/DT+Cx9lptfXBPgPF0xLhxomZ6ivQgasAqfYG+x+vfCcTzosWIdR6WY+aTgfSVbO
m7CIstVkkNoBIl+CGRM9J6RmSMoFO9Q/oJrvRAnijmDQMZQcrA8W/4UDasLv+TRqIyGd
hVFLuHe2oXg+5l0w/7ywxF+SUXFFyQRMCyUfqc5Qr5ogmbgQ2qu0XuFVcDh/ALbbrTn8
pFJY6YAKccmFCyuBOR3+gRoHGzICMvppQxYWphmNnEDdlcGwMfnlhxeVV0DvQRsGyuvu
KWkQ==
X-Gm-Message-State: AOAM533FNSuUg8VfyTaCo3rllylNcOy7ajZvr1CSQEvFO4vdv6SfkSRe
c+//DWiV9aEOdLV7MHCrlj/QycnLZ3GmJKexlWejeW54rY8=
X-Google-Smtp-Source: ABdhPJyBUvxF8JrMvJXenT3xsXHmpJQAFtDTUB5Tj26X76Sa9KNj78w/pST7fn5p7i1WaSTQ6E25/EHyhIuVum7FVAY=
X-Received: by 2002:a92:db4b:: with SMTP id w11mr667973ilq.297.1628622183291;
Tue, 10 Aug 2021 12:03:03 -0700 (PDT)
In-Reply-To: <86sfzha1ac.fsf@jevedi.xotimo>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAPTjJmqA1=LR94juniaMRC=Vi=u0h_Sbneqf0qn1wqgELMRwgw@mail.gmail.com>
X-Mailman-Original-References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<mailman.338.1628547469.4164.python-list@python.org>
<86sfzha1ac.fsf@jevedi.xotimo>
 by: Chris Angelico - Tue, 10 Aug 2021 19:02 UTC

On Wed, Aug 11, 2021 at 4:18 AM Hope Rouselle <hrouselle@jevedi.xotimo> wrote:
>
> I totally agree with you but I didn't know that even numbers were like
> that in Python. In fact, I still don't quite believe it...
>
> >>> 2.__add__(3)
> SyntaxError: invalid syntax

Yeah, that's because "2." looks like the beginning of a float.

> But then I tried:
>
> >>> (2).__add__(3)
> 5
>
> Now I do believe it! :-) Awesome. I had no idea.

You can also do it this way:

>>> x = 2
>>> x.__add__(3)
5

But don't teach this; it ignores several problems. Notably, a subclass
should be able to (re)define operators:

>>> class FancyNumber(int):
.... def __repr__(self): return "FancyNumber(%d)" % self
.... def __add__(self, other): return type(self)(int(self) + other)
.... def __radd__(self, other): return type(self)(other + int(self))
....
>>> FancyNumber(2) + 3
FancyNumber(5)
>>> 2 + FancyNumber(3)
FancyNumber(5)
>>> FancyNumber(2).__add__(3)
FancyNumber(5)
>>> (2).__add__(FancyNumber(3))
5

With the + operator, you always get a FancyNumber back. Explicitly
calling the dunder method fails. (General principle: Dunder methods
are for defining, not for calling, unless you're in the process of
defining a dunder.)

> (*) More opinions
>
> So, yeah, the idea of a course like that is to try to simplify the world
> to students, but it totally backfires in my opinion. There is so much
> syntax to learn, so many little details... We spend the entire semester
> discussing these little details.

Agreed, and if you try to teach all the syntax, you're inevitably
going to get bogged down like that.

> I posted here recently a study of the semantics of slices. When I
> finally got it, I concluded it's not very simple. The course introduces
> a few examples and expects students to get it all from these examples.
> I would rather not introduce slices but teach students enough to write
> procedures that give them the slices. The slices are the fish; learning
> to write the procedures is the know-how. (I'm fine with even teaching
> them how to write procedures to add or subtract numbers [and the rest of
> arithmetic], although none of them would find mysterious what is the
> meaning of arithmetic expressions such as 3 + 6 - 9, even taking
> precedence of operators into account. That's syntax they already know.
> If we teach them the syntax of procedures, we could be essentially done
> with syntax.)

A language like Python is useful, not because every tiny part of it is
easy to explain, but because the language *as a whole* does what is
expected of it. Toy languages are a lot easier to explain on a
concrete level (look up Brainf*ck - it has very few operations and
each one can be very simply defined), and that might be tempting in
terms of "hey, we can teach the entire language in ten minutes", but
they're utterly useless for students.

Instead, my recommendation would be: Entice students with power.
Pretend you're teaching some aspect of magic at a wizards' school and
make sure your students feel massively OP. Sure, they might not
understand what makes those cantrips work, but they know that they DO
work. You can have students casting print calls left and right, doing
complex incantations with list comprehensions, and even defining their
own classes, all without ever worrying about the details of how it all
works. Then once the "wow" is achieved, you can delve into the details
of how things actually function, transforming progressively from
"wizardry" to "science".

And to be quite frank, a lot of code IS magic to most programmers.
Which isn't a problem. Do you REALLY need to understand how your CPU
does register renaming in order to benefit from it? Or do you need to
know every detail of the TCP packet header before using the internet?
Not likely. Those details hide away under the covers, and we make
happy use of them. There's infinite knowledge out there, and you - and
your students - are free to dip into exactly as much as you're
comfortable with.

ChrisA

Re: some problems for an introductory python test

<mailman.344.1628623474.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14540&group=comp.lang.python#14540

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Wed, 11 Aug 2021 05:24:20 +1000
Lines: 48
Message-ID: <mailman.344.1628623474.4164.python-list@python.org>
References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<CAPTjJmoQqPErXw2WAN-FgjZq3k2AnZLEYvOruyRJ0r7nNcRCnA@mail.gmail.com>
<c495f0ee-cc76-709c-e2fb-7dde4567d853@wichmann.us>
<CAPTjJmo_zoqB1MbbmzsAMLUGVcevs1Nz-cJk0Y6-Q7typbP3Mw@mail.gmail.com>
<mailman.341.1628569106.4164.python-list@python.org>
<86lf599zse.fsf@jevedi.xotimo>
<CAPTjJmp9OvxGuMH9Mj66Ha19zf8xjaBsBGOy-gdaeVKu9v+9Ww@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de Uqm/cnG26lwRLGLphcYoMAdMU+jb8kol7Wdxe8fyqfrg==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=Z19Vxivn;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.006
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:python': 0.06;
'despite': 0.07; 'angelico': 0.09; 'api,': 0.09; 'aug': 0.09;
'concept.': 0.09; 'deeper': 0.09; 'it"': 0.09; 'python)': 0.09;
'received:209.85.166.179': 0.09; 'subject:test': 0.09;
'variables,': 0.09; 'writes:': 0.09; 'problem.': 0.14;
'abstraction': 0.16; 'chrisa': 0.16; 'from:addr:rosuav': 0.16;
'from:name:chris angelico': 0.16; 'inheritance,': 0.16;
'machine,': 0.16; 'oop': 0.16; 'syntax,': 0.16; 'tenets': 0.16;
'times,': 0.16; 'useful.': 0.16; 'wrote:': 0.16; 'values': 0.16;
'python': 0.16; 'it?': 0.18; 'code.': 0.19; "i've": 0.22;
'language': 0.22; 'machine': 0.22; 'object': 0.23; 'to:addr
:python-list': 0.23; 'code': 0.24; 'written': 0.24; 'chris': 0.26;
'seems': 0.26; '11,': 0.27; 'normally': 0.27; 'keeping': 0.27;
'function': 0.28; 'done': 0.28; "didn't": 0.29; 'text': 0.29;
'there': 0.31; 'think': 0.31; 'code,': 0.31; 'but': 0.31;
'available.': 0.32; 'language.': 0.32; 'realize': 0.32;
'to:name:python': 0.32; 'message-id:@mail.gmail.com': 0.33;
'using': 0.33; 'received:209.85.166': 0.33; 'header:In-Reply-
To:1': 0.33; 'subject:for': 0.33; 'particular': 0.34; 'same':
0.34; 'received:google.com': 0.34; 'processed': 0.35; 'yes,':
0.35; 'from:addr:gmail.com': 0.35; 'able': 0.36; 'inside': 0.37;
'way': 0.37; "that's": 0.37; 'special': 0.37; 'received:209.85':
0.38; 'those': 0.38; "it's": 0.38; 'received:209': 0.38; 'source':
0.38; 'someone': 0.39; 'messages': 0.40; 'enough': 0.40;
'otherwise': 0.40; 'could': 0.40; 'hope': 0.61; 'skip:o 10': 0.62;
'our': 0.63; 'your': 0.64; 'essential': 0.65; 'in.': 0.65; 'too.':
0.65; '[1]': 0.68; 'history': 0.68; 'that,': 0.68; 'time,': 0.69;
'implemented': 0.69; 'subject:some': 0.69; 'manager': 0.70;
'features': 0.76; 'boy': 0.77; 'states.': 0.81; '2021': 0.84;
'absolutely': 0.84; "else's": 0.84; 'perspective.': 0.84;
'procedures': 0.84; 'sad': 0.91; 'central': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=E4DSaWW8mklzOgqTvkzfgdaBkcJvhu/+L9lw4zv9Uck=;
b=Z19VxivncYntBwdo8kMS72IpQD95f4WqjCd5ZEF4qt989YUPfcBgJWn/W7S89mUmMq
5v/qooB2u2rmCjx+0raeeeLTuERFUbjT0nDq2NW2FQqEfV2ruTIW9kdI3Odw0xY/UxPE
F0SrelF6CMQbk3arYNTSYT9KBHKQ/Di2y5JB40ibhEiVo9vk7zcFe6skcMfYqbqaiK7n
W4bOBWRLKZz0EVb9vYoMksLUfANs5IYMPYAInJf3BNqSE59/LxESkym74/4ZWWp9Xo/d
aBq6gq3VSPsGCodwLXszxPbbvByFDIqhRLS2LjF/rV9AtZLRh4GEfweKZGCucg2GsZx8
t95g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=E4DSaWW8mklzOgqTvkzfgdaBkcJvhu/+L9lw4zv9Uck=;
b=NiJ806gjUkUCfn9yt4bXM83kqAk8E7Vnaioxq8GXLlbkgVuebcbN7qZkrarqhGSR8K
zv0LMu4jxU+smFAN8a/y9CuP5B3gSsCCCqcsTkvTMtcCIDvEqBiUyOrTvSLmaYVfUVni
353fYPMpomqBIphIXN8PfvT+9FZkXEQqCu5bterK8lVIqSaVMZwd+/qIFeKayWZ13Zbi
jpbpMqr14GIuUV3mmiFbf1GaP4Sa1P8Ie/+AVJwu5Fljfn1TYsApUS49NG+WT0MaaDZ0
g6BINXphJ8t3+In62SJbgsJpaEFW/7VsqkOYtTooFLlgGCGzuw6tskgIwD8Pw6suZP8F
R/XA==
X-Gm-Message-State: AOAM530IrWb3jw1T9dFymRjzWf9xC9oJwWXNB3Brs41l42J5owpAr5Ig
hmn+BGyLEuDIi8zc7eL3Fb96AywuXiu8ilSNc7r3jGoC
X-Google-Smtp-Source: ABdhPJyiR6ifu43IEKlJvMycab4Vu+/ZxXGr6jqD/1rKVc8xak2zGgI8WUkSnGwJDJyVQ/2GmdE9gz2Oo0w7dk3vdzU=
X-Received: by 2002:a92:dc52:: with SMTP id x18mr1144818ilq.300.1628623471741;
Tue, 10 Aug 2021 12:24:31 -0700 (PDT)
In-Reply-To: <86lf599zse.fsf@jevedi.xotimo>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAPTjJmp9OvxGuMH9Mj66Ha19zf8xjaBsBGOy-gdaeVKu9v+9Ww@mail.gmail.com>
X-Mailman-Original-References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<CAPTjJmoQqPErXw2WAN-FgjZq3k2AnZLEYvOruyRJ0r7nNcRCnA@mail.gmail.com>
<c495f0ee-cc76-709c-e2fb-7dde4567d853@wichmann.us>
<CAPTjJmo_zoqB1MbbmzsAMLUGVcevs1Nz-cJk0Y6-Q7typbP3Mw@mail.gmail.com>
<mailman.341.1628569106.4164.python-list@python.org>
<86lf599zse.fsf@jevedi.xotimo>
 by: Chris Angelico - Tue, 10 Aug 2021 19:24 UTC

On Wed, Aug 11, 2021 at 4:18 AM Hope Rouselle <hrouselle@jevedi.xotimo> wrote:
>
> Chris Angelico <rosuav@gmail.com> writes:
>
> [...]
>
> >> not disagreeing... and yeah I could have thought deeper about the
> >> answer, but I still think "notthing has been OOP" -> "yes it has, they
> >> just didn't realize it" was worth mentioning
> >
> > Oh yes, absolutely agree.
>
> At the same time, inside the machine nothing is OOP --- so all the OOP
> is no OOP at all and they just didn't realize it? This seems to show
> that OOP is about perspective. An essential thing for OOP is the
> keeping of states. Closures can keep state, so having procedures as
> first-class values allows us to say we are doing OOP too. (Arguments of
> procedures are messages and function application is message passing,
> with closures keeping a state --- and all the rest of OOP can be
> implemented with enough such functional technology.) In summary, OOP
> should not be defined as some special syntax, otherwise there is no OOP
> in ``2 + 2''.
>
> Having said that, I totally agree with all the nitpicking.

Object orientation is a particular abstraction concept. It's not a
feature of the machine, it's a feature of the language that you write
your source code in. I've done OOP using IDL and CORBA, writing my
code in C and able to subclass someone else's code that might have
been written in some other language. [1] Central tenets of OOP
(polymorphism, inheritance, etc) can be implemented at a lower level
using whatever makes sense, but *at the level that you're writing*,
they exist, and are useful.

Data types, variables, control flow, these are all abstractions. But
they're such useful abstractions that we prefer to think that way in
our code. So, *to us*, those are features of our code. To the
computer, of course, they're just text that gets processed into
actually-executable code, but that's not a problem.

So I would say that (in Python) there IS object orientation in "2 +
2", and even in the Python C API, there is object orientation, despite
C not normally being considered an object-oriented language.

ChrisA

[1] And boy oh boy was that good fun. The OS/2 Presentation Manager
had a wealth of power available. Good times, sad that's history now.

Re: some problems for an introductory python test

<mailman.345.1628624729.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14541&group=comp.lang.python#14541

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: tjre...@udel.edu (Terry Reedy)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Tue, 10 Aug 2021 15:41:35 -0400
Lines: 17
Message-ID: <mailman.345.1628624729.4164.python-list@python.org>
References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<mailman.338.1628547469.4164.python-list@python.org>
<86sfzha1ac.fsf@jevedi.xotimo> <seukpg$16e4$1@ciao.gmane.io>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de Gcwqx09UXXZ0zWI8dAmUsQkz1J8nfkUgC60cfofpOEDw==
Return-Path: <python-python-list@m.gmane-mx.org>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:python': 0.06;
'message-id:@ciao.gmane.io': 0.09; 'received:ciao.gmane.io': 0.09;
'received:gmane.io': 0.09; 'received:list': 0.09; 'subject:test':
0.09; 'terry': 0.09; '>>>>': 0.16; 'easier.': 0.16;
'from:addr:udel.edu': 0.16; 'received:116.202': 0.16;
'received:116.202.254': 0.16; 'received:116.202.254.214': 0.16;
'syntaxerror:': 0.16; 'wrote:': 0.16; 'syntax': 0.16; 'to:addr
:python-list': 0.23; '>>>': 0.26; 'space': 0.26; 'header:User-
Agent:1': 0.31; 'but': 0.31; 'am,': 0.31; 'header:In-Reply-To:1':
0.33; 'subject:for': 0.33; 'invalid': 0.35; 'hope': 0.61;
'subject:some': 0.69; 'received:116': 0.71
X-Injected-Via-Gmane: http://gmane.org/
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
In-Reply-To: <86sfzha1ac.fsf@jevedi.xotimo>
Content-Language: en-US
X-Mailman-Approved-At: Tue, 10 Aug 2021 15:45:29 -0400
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <seukpg$16e4$1@ciao.gmane.io>
X-Mailman-Original-References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<mailman.338.1628547469.4164.python-list@python.org>
<86sfzha1ac.fsf@jevedi.xotimo>
 by: Terry Reedy - Tue, 10 Aug 2021 19:41 UTC

On 8/10/2021 9:15 AM, Hope Rouselle wrote:
>>>> 2.__add__(3)
> SyntaxError: invalid syntax
>
> But then I tried:
>
>>>> (2).__add__(3)
> 5

Add a space is easier.
>>> 2 .__add__(3)
5 >>>

--
Terry Jan Reedy

Re: some problems for an introductory python test

<867dgtc8a1.fsf@jevedi.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14543&group=comp.lang.python#14543

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!LrhSxzwDgsLbOh6Rhfo3Cw.user.46.165.242.75.POSTED!not-for-mail
From: hrouse...@jevedi.com (Hope Rouselle)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Tue, 10 Aug 2021 18:13:58 -0300
Organization: Aioe.org NNTP Server
Message-ID: <867dgtc8a1.fsf@jevedi.com>
References: <868s1acoo1.fsf@jevedi.xotimo>
<CAPTjJmrFwxAwfPTYCwiCds8myD_0q7sgvzgcJZhoVsm9w9cqSQ@mail.gmail.com>
<mailman.337.1628546415.4164.python-list@python.org>
<868s19bh70.fsf@jevedi.xotimo>
<CAPTjJmpJRW+AUX6f6DUk7S9nmLPo-f1AG9bnCs=XGBb=7spZpQ@mail.gmail.com>
<mailman.342.1628621276.4164.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="33973"; posting-host="LrhSxzwDgsLbOh6Rhfo3Cw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:CVoq+NnbttlyzXFIy0VIwGsj9TQ=
 by: Hope Rouselle - Tue, 10 Aug 2021 21:13 UTC

Chris Angelico <rosuav@gmail.com> writes:

> On Wed, Aug 11, 2021 at 4:14 AM Hope Rouselle <hrouselle@jevedi.xotimo> wrote:
>>
>> Chris Angelico <rosuav@gmail.com> writes:
>>
>> > On Tue, Aug 10, 2021 at 7:25 AM Hope Rouselle
>> > <hrouselle@jevedi.xotimo> wrote:
>> >> I came up with the following question. Using strings of length 5
>> >> (always), write a procedure histogram(s) that consumes a string and
>> >> produces a dictionary whose keys are each substrings (of the string) of
>> >> length 1 and their corresponding values are the number of times each
>> >> such substrings appear. For example, histogram("aaaaa") = {"a": 5}.
>> >> Students can "loop through" the string by writing out s[0], s[1], s[2],
>> >> s[3], s[4].
>> >
>> > In other words, recreate collections.Counter? Seems decent, but you'll
>> > need to decide whether you want them to use defaultdict, use
>> > __missing__, or do it all manually.
>>
>> Yes, the course introduces very little so there is a lot of recreation
>> going on. Hm, I don't know defaultdict and I don't know how to use
>> __missing__. The course does introduce dict.get(), though. If students
>> use dict.get(), then the procedure could essentially be:
>>
>> def histogram(s):
>> d = {}
>> d[s[0]] = d.get(s[0], 0) + 1
>> d[s[1]] = d.get(s[1], 0) + 1
>> d[s[2]] = d.get(s[2], 0) + 1
>> d[s[3]] = d.get(s[3], 0) + 1
>> d[s[4]] = d.get(s[4], 0) + 1
>> return d
>
> There's nothing wrong with getting students to recreate things, but
> there are so many different levels on which you could do this, which
> will leave your more advanced students wondering what's legal. :) Here
> are several ways to do the same thing:

[... very impressive set of solutions...]

> It seems *very* strange to have an exercise like this without looping.

It is. I agree.

> That seems counterproductive.

It is.

> But if you're expecting them to not use loops, you'll want to also be
> very clear about what other features they're allowed to use - or
> alternatively, stipulate what they ARE allowed to use, eg "Use only
> indexing and the get() method".

Yes, I will do that. I mean the course does that all the time. They
cannot use anything that has not been introduced. That's another
problem because the course introduces various things and students can't
quite keep everything in mind. The suggestion to make up a list of
things is mostly ignored by nearly all of them. :-)

Re: some problems for an introductory python test

<861r71c7nw.fsf@jevedi.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14544&group=comp.lang.python#14544

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!LrhSxzwDgsLbOh6Rhfo3Cw.user.46.165.242.75.POSTED!not-for-mail
From: hrouse...@jevedi.com (Hope Rouselle)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Tue, 10 Aug 2021 18:27:15 -0300
Organization: Aioe.org NNTP Server
Message-ID: <861r71c7nw.fsf@jevedi.com>
References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<mailman.338.1628547469.4164.python-list@python.org>
<86sfzha1ac.fsf@jevedi.xotimo> <seukpg$16e4$1@ciao.gmane.io>
<mailman.345.1628624729.4164.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="44042"; posting-host="LrhSxzwDgsLbOh6Rhfo3Cw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:9VWHp2O7K5tvtPfZFT+f39qYr7w=
 by: Hope Rouselle - Tue, 10 Aug 2021 21:27 UTC

Terry Reedy <tjreedy@udel.edu> writes:

> On 8/10/2021 9:15 AM, Hope Rouselle wrote:
>>>>> 2.__add__(3)
>> SyntaxError: invalid syntax
>> But then I tried:
>>
>>>>> (2).__add__(3)
>> 5
>
> Add a space is easier.
>>>> 2 .__add__(3)
> 5
>>>>

Hah. That's brilliant! So cool.

Re: some problems for an introductory python test

<mailman.348.1628656421.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14546&group=comp.lang.python#14546

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: tjre...@udel.edu (Terry Reedy)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Tue, 10 Aug 2021 23:22:43 -0400
Lines: 34
Message-ID: <mailman.348.1628656421.4164.python-list@python.org>
References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<mailman.338.1628547469.4164.python-list@python.org>
<86sfzha1ac.fsf@jevedi.xotimo> <seukpg$16e4$1@ciao.gmane.io>
<mailman.345.1628624729.4164.python-list@python.org>
<861r71c7nw.fsf@jevedi.com> <sevfq5$2jb$1@ciao.gmane.io>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de EaJc8qmCODyODvMHqoZljgM81A9p1maO+rTywuF3roAg==
Return-Path: <python-python-list@m.gmane-mx.org>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:python': 0.06;
'message-id:@ciao.gmane.io': 0.09; 'received:ciao.gmane.io': 0.09;
'received:gmane.io': 0.09; 'received:list': 0.09; 'subject:test':
0.09; 'terry': 0.09; 'writes:': 0.09; '>>>>>': 0.16; '>>>>>>':
0.16; 'easier.': 0.16; 'from:addr:udel.edu': 0.16;
'received:116.202': 0.16; 'received:116.202.254': 0.16;
'received:116.202.254.214': 0.16; 'syntaxerror:': 0.16; 'wrote:':
0.16; 'syntax': 0.16; 'python': 0.16; 'pm,': 0.20; 'to:addr
:python-list': 0.23; 'code': 0.24; 'anything': 0.24; 'cannot':
0.24; '>>>': 0.26; 'space': 0.26; 'header:User-Agent:1': 0.31;
'but': 0.31; 'am,': 0.31; 'expect': 0.31; 'header:In-Reply-To:1':
0.33; 'subject:for': 0.33; 'invalid': 0.35; 'two': 0.37; "that's":
0.37; 'mean': 0.37; 'really': 0.37; 'hope': 0.61; 'subject:some':
0.69; 'received:116': 0.71; 'little': 0.75
X-Injected-Via-Gmane: http://gmane.org/
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
In-Reply-To: <861r71c7nw.fsf@jevedi.com>
Content-Language: en-US
X-Mailman-Approved-At: Wed, 11 Aug 2021 00:33:40 -0400
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <sevfq5$2jb$1@ciao.gmane.io>
X-Mailman-Original-References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<mailman.338.1628547469.4164.python-list@python.org>
<86sfzha1ac.fsf@jevedi.xotimo> <seukpg$16e4$1@ciao.gmane.io>
<mailman.345.1628624729.4164.python-list@python.org>
<861r71c7nw.fsf@jevedi.com>
 by: Terry Reedy - Wed, 11 Aug 2021 03:22 UTC

On 8/10/2021 5:27 PM, Hope Rouselle wrote:
> Terry Reedy <tjreedy@udel.edu> writes:
>
>> On 8/10/2021 9:15 AM, Hope Rouselle wrote:
>>>>>> 2.__add__(3)
>>> SyntaxError: invalid syntax
>>> But then I tried:
>>>
>>>>>> (2).__add__(3)
>>> 5
>>
>> Add a space is easier.
>>>>> 2 .__add__(3)
>> 5
>>>>>
>
> Hah. That's brilliant! So cool.

Python is a little looser about whitespace than one might expect from
reading 'normal' code when the result is unambiguous in that it cannot
really mean anything other than what it does. Two other examples:

>>> if3: print('yes!')
yes!
>>> [0] [0]
0

--
Terry Jan Reedy

Re: some problems for an introductory python test

<inhgq1FiairU1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14547&group=comp.lang.python#14547

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: greg.ew...@canterbury.ac.nz (Greg Ewing)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Wed, 11 Aug 2021 20:41:35 +1200
Lines: 15
Message-ID: <inhgq1FiairU1@mid.individual.net>
References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<mailman.338.1628547469.4164.python-list@python.org>
<86sfzha1ac.fsf@jevedi.xotimo> <seukpg$16e4$1@ciao.gmane.io>
<mailman.345.1628624729.4164.python-list@python.org>
<861r71c7nw.fsf@jevedi.com> <sevfq5$2jb$1@ciao.gmane.io>
<mailman.348.1628656421.4164.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net TDwsNfMXSrFY6bEfIwURpAlt6HouAzWCGEVpOEzipubrerWXcO
Cancel-Lock: sha1:bOK0D2AAmNvCr8j25a+1BU1f7H4=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:78.0)
Gecko/20100101 Thunderbird/78.4.0
In-Reply-To: <mailman.348.1628656421.4164.python-list@python.org>
Content-Language: en-US
 by: Greg Ewing - Wed, 11 Aug 2021 08:41 UTC

On 11/08/21 3:22 pm, Terry Reedy wrote:
> Python is a little looser about whitespace than one might expect from
> reading 'normal' code when the result is unambiguous in that it cannot
> really mean anything other than what it does.
>
> >>> if3: print('yes!')
> yes!

That may not be doing what you think it's doing. Consider also

>>> if0: print('yes!')
yes!

--
Greg

Re: some problems for an introductory python test

<86sfzgb2sz.fsf@jevedi.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14548&group=comp.lang.python#14548

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!il4IBmfmUgeqNoOM5XsmXA.user.46.165.242.75.POSTED!not-for-mail
From: hrouse...@jevedi.com (Hope Rouselle)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Wed, 11 Aug 2021 09:09:48 -0300
Organization: Aioe.org NNTP Server
Message-ID: <86sfzgb2sz.fsf@jevedi.com>
References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<mailman.338.1628547469.4164.python-list@python.org>
<86sfzha1ac.fsf@jevedi.xotimo> <seukpg$16e4$1@ciao.gmane.io>
<mailman.345.1628624729.4164.python-list@python.org>
<861r71c7nw.fsf@jevedi.com> <sevfq5$2jb$1@ciao.gmane.io>
<mailman.348.1628656421.4164.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="5731"; posting-host="il4IBmfmUgeqNoOM5XsmXA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:fsRCPoy1ewxRq3TiztpCqRQFgP8=
 by: Hope Rouselle - Wed, 11 Aug 2021 12:09 UTC

Terry Reedy <tjreedy@udel.edu> writes:

> On 8/10/2021 5:27 PM, Hope Rouselle wrote:
>> Terry Reedy <tjreedy@udel.edu> writes:
>>
>>> On 8/10/2021 9:15 AM, Hope Rouselle wrote:
>>>>>>> 2.__add__(3)
>>>> SyntaxError: invalid syntax
>>>> But then I tried:
>>>>
>>>>>>> (2).__add__(3)
>>>> 5
>>>
>>> Add a space is easier.
>>>>>> 2 .__add__(3)
>>> 5
>>>>>>
>> Hah. That's brilliant! So cool.
>
> Python is a little looser about whitespace than one might expect from
> reading 'normal' code when the result is unambiguous in that it cannot
> really mean anything other than what it does. Two other examples:
>
>>>> if3: print('yes!')
> yes!

That's cool to know too, but I would have expected that. Programming
languages tend to ignore whitespace as much as possible. (But someone
followed-up with more details... I'll get there.) But the next one...

>>>> [0] [0]
> 0

Oh! This almost fooled me. It's just a list containing the integer
zero followed by the index-operator (or however the brackets are called
in this case.)

At first I thought maybe there was an implicit operator between lists
just like it happens with strings.

>>> "a" "," "b"
'a,b'

But which operator would it be? It wasn't concatenation, of course. So
I looked at what type() thought of it. Then I tried changing numbers:

>>> [1] [1]
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
[1] [1]
IndexError: list index out of range

And that's when it hit me. :-) Thanks!

Re: some problems for an introductory python test

<86mtpob2q2.fsf@jevedi.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14549&group=comp.lang.python#14549

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!il4IBmfmUgeqNoOM5XsmXA.user.46.165.242.75.POSTED!not-for-mail
From: hrouse...@jevedi.com (Hope Rouselle)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Wed, 11 Aug 2021 09:11:33 -0300
Organization: Aioe.org NNTP Server
Message-ID: <86mtpob2q2.fsf@jevedi.com>
References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<mailman.338.1628547469.4164.python-list@python.org>
<86sfzha1ac.fsf@jevedi.xotimo> <seukpg$16e4$1@ciao.gmane.io>
<mailman.345.1628624729.4164.python-list@python.org>
<861r71c7nw.fsf@jevedi.com> <sevfq5$2jb$1@ciao.gmane.io>
<mailman.348.1628656421.4164.python-list@python.org>
<inhgq1FiairU1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="5731"; posting-host="il4IBmfmUgeqNoOM5XsmXA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:5y8//8W5/YPOJHTPQsdsQZAh/Yg=
 by: Hope Rouselle - Wed, 11 Aug 2021 12:11 UTC

Greg Ewing <greg.ewing@canterbury.ac.nz> writes:

> On 11/08/21 3:22 pm, Terry Reedy wrote:
>> Python is a little looser about whitespace than one might expect
>> from reading 'normal' code when the result is unambiguous in that it
>> cannot really mean anything other than what it does.
>> >>> if3: print('yes!')
>> yes!
>
> That may not be doing what you think it's doing. Consider also
>
>>>> if0: print('yes!')
> yes!

So, yes, that's puzzling.

>>> 0 == False
True
>>> if0: print("yes")
yes
>>> if(0): print("yes")

>>>

What's going on there?

Re: some problems for an introductory python test

<86czqkb1z9.fsf@jevedi.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14550&group=comp.lang.python#14550

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!il4IBmfmUgeqNoOM5XsmXA.user.46.165.242.75.POSTED!not-for-mail
From: hrouse...@jevedi.com (Hope Rouselle)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Wed, 11 Aug 2021 09:27:38 -0300
Organization: Aioe.org NNTP Server
Message-ID: <86czqkb1z9.fsf@jevedi.com>
References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<mailman.338.1628547469.4164.python-list@python.org>
<86sfzha1ac.fsf@jevedi.xotimo>
<CAPTjJmqA1=LR94juniaMRC=Vi=u0h_Sbneqf0qn1wqgELMRwgw@mail.gmail.com>
<mailman.343.1628622186.4164.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="21394"; posting-host="il4IBmfmUgeqNoOM5XsmXA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
Cancel-Lock: sha1:PMfKiKm8rg0+Incm06idAFc5/As=
X-Notice: Filtered by postfilter v. 0.9.2
 by: Hope Rouselle - Wed, 11 Aug 2021 12:27 UTC

Chris Angelico <rosuav@gmail.com> writes:

> On Wed, Aug 11, 2021 at 4:18 AM Hope Rouselle <hrouselle@jevedi.xotimo> wrote:
>>
>> I totally agree with you but I didn't know that even numbers were like
>> that in Python. In fact, I still don't quite believe it...
>>
>> >>> 2.__add__(3)
>> SyntaxError: invalid syntax
>
> Yeah, that's because "2." looks like the beginning of a float.
>
>> But then I tried:
>>
>> >>> (2).__add__(3)
>> 5
>>
>> Now I do believe it! :-) Awesome. I had no idea.
>
> You can also do it this way:
>
>>>> x = 2
>>>> x.__add__(3)
> 5
>
> But don't teach this; it ignores several problems.

I wouldn't. This is all Python-stuff. The course chooses a language
like Python, but it is not trying to teach Python --- it is trying to
teach computer programming, that is, strategies in high-precision.

[...]

>> (*) More opinions
>>
>> So, yeah, the idea of a course like that is to try to simplify the world
>> to students, but it totally backfires in my opinion. There is so much
>> syntax to learn, so many little details... We spend the entire semester
>> discussing these little details.
>
> Agreed, and if you try to teach all the syntax, you're inevitably
> going to get bogged down like that.

Indeed.

>> I posted here recently a study of the semantics of slices. When I
>> finally got it, I concluded it's not very simple. The course introduces
>> a few examples and expects students to get it all from these examples.
>> I would rather not introduce slices but teach students enough to write
>> procedures that give them the slices. The slices are the fish; learning
>> to write the procedures is the know-how. (I'm fine with even teaching
>> them how to write procedures to add or subtract numbers [and the rest of
>> arithmetic], although none of them would find mysterious what is the
>> meaning of arithmetic expressions such as 3 + 6 - 9, even taking
>> precedence of operators into account. That's syntax they already know.
>> If we teach them the syntax of procedures, we could be essentially done
>> with syntax.)
>
> A language like Python is useful, not because every tiny part of it is
> easy to explain, but because the language *as a whole* does what is
> expected of it. Toy languages are a lot easier to explain on a
> concrete level (look up Brainf*ck - it has very few operations and
> each one can be very simply defined), and that might be tempting in
> terms of "hey, we can teach the entire language in ten minutes", but
> they're utterly useless for students.

Sure. I would never use a toy language like that. I think we need a
compromise --- some syntax, but not too much; in fact, just a little bit
of syntax. For instance, could we do away with slices? We could. If
we learn one way of looping, we can build slices with procedures. This
is a good opportunity in fact --- it will show students how slices
really work and how to get what they want with it. (Then towards the
end we could give out a lecture for anyone interested in Python ---
``while we didn't show you how Pythonists usually write, here's a few
things that Pythonists would do that we didn't do in this course...'')

> Instead, my recommendation would be: Entice students with power.
> Pretend you're teaching some aspect of magic at a wizards' school and
> make sure your students feel massively OP. Sure, they might not
> understand what makes those cantrips work, but they know that they DO
> work. You can have students casting print calls left and right, doing
> complex incantations with list comprehensions, and even defining their
> own classes, all without ever worrying about the details of how it all
> works. Then once the "wow" is achieved, you can delve into the details
> of how things actually function, transforming progressively from
> "wizardry" to "science".

I really like that, but I would predict that, in a typical university,
professors are not really willing to go that way. Everything has to be
extremely simple --- and a mess is made in trying to achive that. (In a
sense, professors are all failing terribly. They're lucky that nobody
is giving them a grade based on how effective they are as evidenced by
the facts, however such thing would be done in practice if one were to
take it seriously.)

> And to be quite frank, a lot of code IS magic to most programmers.

Definitely. You guys are showing me so much Python here that I've never
seen --- which I expect, because I'm only paying attention at Python now
since I'm conducting students through a course that's using it. (I
admire the language, but I never used it in any project on my own. I
probably would if I were not in love with other similar technology.)

> Which isn't a problem. Do you REALLY need to understand how your CPU
> does register renaming in order to benefit from it? Or do you need to
> know every detail of the TCP packet header before using the internet?
> Not likely.

Not at all. (Although, of course, we like to know these stuff.)

> Those details hide away under the covers, and we make happy use of
> them. There's infinite knowledge out there, and you - and your
> students - are free to dip into exactly as much as you're comfortable
> with.

``A man after my own heart.''

Re: some problems for an introductory python test

<868s18b1p7.fsf@jevedi.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14551&group=comp.lang.python#14551

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!il4IBmfmUgeqNoOM5XsmXA.user.46.165.242.75.POSTED!not-for-mail
From: hrouse...@jevedi.com (Hope Rouselle)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Wed, 11 Aug 2021 09:33:40 -0300
Organization: Aioe.org NNTP Server
Message-ID: <868s18b1p7.fsf@jevedi.com>
References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<CAPTjJmoQqPErXw2WAN-FgjZq3k2AnZLEYvOruyRJ0r7nNcRCnA@mail.gmail.com>
<c495f0ee-cc76-709c-e2fb-7dde4567d853@wichmann.us>
<CAPTjJmo_zoqB1MbbmzsAMLUGVcevs1Nz-cJk0Y6-Q7typbP3Mw@mail.gmail.com>
<mailman.341.1628569106.4164.python-list@python.org>
<86lf599zse.fsf@jevedi.xotimo>
<CAPTjJmp9OvxGuMH9Mj66Ha19zf8xjaBsBGOy-gdaeVKu9v+9Ww@mail.gmail.com>
<mailman.344.1628623474.4164.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="26079"; posting-host="il4IBmfmUgeqNoOM5XsmXA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
Cancel-Lock: sha1:qat1PDMsiM6/aZ66+gWNyM5CPUQ=
X-Notice: Filtered by postfilter v. 0.9.2
 by: Hope Rouselle - Wed, 11 Aug 2021 12:33 UTC

Chris Angelico <rosuav@gmail.com> writes:

> On Wed, Aug 11, 2021 at 4:18 AM Hope Rouselle <hrouselle@jevedi.xotimo> wrote:
>>
>> Chris Angelico <rosuav@gmail.com> writes:
>>
>> [...]
>>
>> >> not disagreeing... and yeah I could have thought deeper about the
>> >> answer, but I still think "notthing has been OOP" -> "yes it has, they
>> >> just didn't realize it" was worth mentioning
>> >
>> > Oh yes, absolutely agree.
>>
>> At the same time, inside the machine nothing is OOP --- so all the OOP
>> is no OOP at all and they just didn't realize it? This seems to show
>> that OOP is about perspective. An essential thing for OOP is the
>> keeping of states. Closures can keep state, so having procedures as
>> first-class values allows us to say we are doing OOP too. (Arguments of
>> procedures are messages and function application is message passing,
>> with closures keeping a state --- and all the rest of OOP can be
>> implemented with enough such functional technology.) In summary, OOP
>> should not be defined as some special syntax, otherwise there is no OOP
>> in ``2 + 2''.
>>
>> Having said that, I totally agree with all the nitpicking.
>
> Object orientation is a particular abstraction concept. It's not a
> feature of the machine, it's a feature of the language that you write
> your source code in. I've done OOP using IDL and CORBA, writing my
> code in C and able to subclass someone else's code that might have
> been written in some other language. [1] Central tenets of OOP
> (polymorphism, inheritance, etc) can be implemented at a lower level
> using whatever makes sense, but *at the level that you're writing*,
> they exist, and are useful.
>
> Data types, variables, control flow, these are all abstractions. But
> they're such useful abstractions that we prefer to think that way in
> our code. So, *to us*, those are features of our code. To the
> computer, of course, they're just text that gets processed into
> actually-executable code, but that's not a problem.

Total agreement.

> So I would say that (in Python) there IS object orientation in "2 +
> 2", and even in the Python C API, there is object orientation, despite
> C not normally being considered an object-oriented language.

But would you say that 2 + 2 is also an illustration of object
orientation in any other language too?

Regarding C, I have many times said that myself. If I wrote assembly,
I'm sure I would do my best to create things like procedures --- a label
and some bureaucracy to get arguments in and a return value out.

> ChrisA
>
> [1] And boy oh boy was that good fun. The OS/2 Presentation Manager
> had a wealth of power available. Good times, sad that's history now.

I know OS/2 only by name. I never had the pleasure of using it. In
fact, I don't even know how it looks. I must be a little younger than
you are. But not too younger because I kinda remember its name. Was it
a system that might have thought of competing against Microsoft Windows?
:-) That's what my memory tells me about it.

Re: some problems for an introductory python test

<mailman.349.1628701831.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14553&group=comp.lang.python#14553

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: wolfram....@googlemail.com (Wolfram Hinderer)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Wed, 11 Aug 2021 19:10:27 +0200
Lines: 22
Message-ID: <mailman.349.1628701831.4164.python-list@python.org>
References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<mailman.338.1628547469.4164.python-list@python.org>
<86sfzha1ac.fsf@jevedi.xotimo> <seukpg$16e4$1@ciao.gmane.io>
<mailman.345.1628624729.4164.python-list@python.org>
<861r71c7nw.fsf@jevedi.com> <sevfq5$2jb$1@ciao.gmane.io>
<30ad3e32-c7f5-e255-4c18-0147a56c3346@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de uKlk6Uk+0tSyWDen2QjLkAFK6IryK9cLlnaXSdEdqIzg==
Return-Path: <wolfram.hinderer@googlemail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=googlemail.com header.i=@googlemail.com header.b=G8rD9Jhp;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.010
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:python': 0.06;
'from:addr:googlemail.com': 0.09; 'schrieb': 0.09; 'subject:test':
0.09; 'terry': 0.09; 'looks': 0.11; 'indexing,': 0.16; "isn't.":
0.16; 'received:192.168.2': 0.16; 'python': 0.16; 'message-
id:@gmail.com': 0.19; 'maybe': 0.20; 'to:addr:python-list': 0.23;
'code': 0.24; 'anything': 0.24; 'cannot': 0.24; '>>>': 0.26;
'space': 0.26; 'white': 0.27; 'header:User-Agent:1': 0.31; 'but':
0.31; 'expect': 0.31; "wouldn't": 0.32; 'header:In-Reply-To:1':
0.33; 'subject:for': 0.33; 'received:google.com': 0.34; 'missing':
0.35; 'two': 0.37; 'received:192.168': 0.37; 'mean': 0.37;
'really': 0.37; 'received:209.85': 0.38; 'received:209': 0.38;
'normal': 0.60; 'here': 0.62; 'subject:some': 0.69; 'little':
0.75; 'difference.': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=googlemail.com; s=20161025;
h=from:subject:to:references:message-id:date:user-agent:mime-version
:in-reply-to:content-transfer-encoding;
bh=tAps6xgoKh0UQKuLa6GBAjNcY+E/cQZOXz5gTljcL1c=;
b=G8rD9JhpacgKqAPmkd8shQ583UQLbR7Ro1BJxeuEJpq2PCQbFpq+lstk/CZmsgezDy
OXOG5h8yDyXLzdnq0vbFgt5vbbRJS7EP0WU3/CWL27iUQIAv6Y2fn5YekfdP4Rw9lv8h
sim6vZe4utQb9o/RtD65CbbDAdi75axtUa9cUgq4h6ihFak95fwlPoVUKudQKrR2Qnv0
EpOcB+KOc2JC0ufriEo2JsQ9xWgXgx3x5D3l9c1uozP2+dCGmjHzbLLZcKv6T4hoyWk0
xEL4L5uTO7lQplO0Zj5FFSqNc6Rh78QJhCpx71PwrQs/vxxLbtY9tBCpvJOQNjYcjX9I
YqTA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:from:subject:to:references:message-id:date
:user-agent:mime-version:in-reply-to:content-transfer-encoding;
bh=tAps6xgoKh0UQKuLa6GBAjNcY+E/cQZOXz5gTljcL1c=;
b=CUnpdty+Xh+t7uPPf6qWJtb9vI41zfjCRHmItDrlou0CiDsQSyVnuYiLCBu1Iwl16y
QJAfIqPM3/ResUJEaio/hXlndlLYovYNLtNuw4pEo3Do1wgGh41zkVK2vP+Xavg4OavU
ZJydk0HHZn8K0M+JQbwwwAD+gzVmYg5qZAskViJuWI6BT8959bXOLJhXOPYAYvsVhpeO
3Bg6QV8FwgYWWB/7Nu0n7K5zW8sz4gVRaRGkwO1zJMR2krma/DOcBXEw1uLAWbvJdGlF
CIfwDdZhzaLWI+8rGZB4ehI2lHDvQ9zo82YoTg9LG46mUdugn9eWoznAnE8du65BzzTP
XX7g==
X-Gm-Message-State: AOAM533+4vIvam9Wh8c3gjxm3x0vcmAOlbRMvkJWkhjOJZO8AbagWcNQ
o9M3BAnQMeAlRnwepyul9M/IoJVTq3I=
X-Google-Smtp-Source: ABdhPJys/rCcBhqDnNDZMoZeuFx9sLuK352yu8imc9SHwb81MBhG8/E1kmxdLyW0KV7vXRsp6cdqCg==
X-Received: by 2002:a5d:51d2:: with SMTP id n18mr15984053wrv.325.1628701828840;
Wed, 11 Aug 2021 10:10:28 -0700 (PDT)
X-Google-Original-From: Wolfram Hinderer <wolfram.hinderer@gmail.com>
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
In-Reply-To: <sevfq5$2jb$1@ciao.gmane.io>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <30ad3e32-c7f5-e255-4c18-0147a56c3346@gmail.com>
X-Mailman-Original-References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<mailman.338.1628547469.4164.python-list@python.org>
<86sfzha1ac.fsf@jevedi.xotimo> <seukpg$16e4$1@ciao.gmane.io>
<mailman.345.1628624729.4164.python-list@python.org>
<861r71c7nw.fsf@jevedi.com> <sevfq5$2jb$1@ciao.gmane.io>
 by: Wolfram Hinderer - Wed, 11 Aug 2021 17:10 UTC

Am 11.08.2021 um 05:22 schrieb Terry Reedy:
> Python is a little looser about whitespace than one might expect from
> reading 'normal' code when the result is unambiguous in that it cannot
> really mean anything other than what it does.  Two other examples:
>
> >>> if3: print('yes!')
> yes!
> >>> [0]  [0]
> 0

Not sure what you mean here - is it a joke? The first looks like an if
statement, but isn't. The missing space *does* make a difference. (Try
"if0" instead.)

The second is normal indexing, which allows white space. I wouldn't
consider that surprising, but maybe I should? (Honest question, I really
don't know.)

--
Wolfram Hinderer

Re: some problems for an introductory python test

<mailman.350.1628705615.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14554&group=comp.lang.python#14554

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: pyt...@mrabarnett.plus.com (MRAB)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Wed, 11 Aug 2021 19:10:24 +0100
Lines: 27
Message-ID: <mailman.350.1628705615.4164.python-list@python.org>
References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<mailman.338.1628547469.4164.python-list@python.org>
<86sfzha1ac.fsf@jevedi.xotimo> <seukpg$16e4$1@ciao.gmane.io>
<mailman.345.1628624729.4164.python-list@python.org>
<861r71c7nw.fsf@jevedi.com> <sevfq5$2jb$1@ciao.gmane.io>
<30ad3e32-c7f5-e255-4c18-0147a56c3346@gmail.com>
<6382edc7-ac3f-7b7b-a183-c109f9fb5b8b@mrabarnett.plus.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de vKTcE+mbrrWuqEDabKvNwg7DNsV0ANwdFJ2JWdsYnX2A==
Return-Path: <python@mrabarnett.plus.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=plus.com header.i=@plus.com header.b=KG1DOljB;
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.003
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:python': 0.06;
'from:addr:python': 0.09; 'received:192.168.1.64': 0.09;
'schrieb': 0.09; 'subject:test': 0.09; 'terry': 0.09; 'looks':
0.11; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab':
0.16; 'indexing,': 0.16; "isn't.": 0.16; 'mean.': 0.16; 'message-
id:@mrabarnett.plus.com': 0.16; 'received:plus.net': 0.16;
'wrote:': 0.16; 'python': 0.16; 'maybe': 0.20; 'to:addr:python-
list': 0.23; 'code': 0.24; 'anything': 0.24; 'cannot': 0.24;
'>>>': 0.26; 'space': 0.26; 'white': 0.27; 'header:User-Agent:1':
0.31; 'received:192.168.1': 0.31; 'but': 0.31; 'expect': 0.31;
'python-list': 0.32; "wouldn't": 0.32; 'header:In-Reply-To:1':
0.33; 'subject:for': 0.33; 'missing': 0.35; 'two': 0.37;
'received:192.168': 0.37; 'mean': 0.37; 'really': 0.37; "it's":
0.38; 'normal': 0.60; 'here': 0.62; 'received:212': 0.68;
'subject:some': 0.69; 'little': 0.75; 'difference.': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019;
t=1628705425; bh=XfBdECYvrzJHlEERJyOYUJM2EhrnTWiIz6cYUKXsFuo=;
h=Subject:To:References:From:Date:In-Reply-To;
b=KG1DOljBRlkC3kCspHGB/GQ0r66Jglbpv6EPq82r36knJilflETddUtYl6lobWjIZ
1gQsBkoUrhSGOtCT1lXS5Cj9UV02hTAkqzCBpCj8PnIFuII1lLO7iWRRG5d8l9YX/j
AbFXpsvA2fbRJ49B1VUn+SnY7S04W+x5OyFkD2vma2h897uXBdsHw9nrt758WFAKu0
VdZooL4fbswkp+rhNQE3m0SP3iT1G0PNCH8RZkYAU1r4lyNcvvcuvEf7T9b3SKhQ0H
RM5l5dIevcYfn1wCsS7Doqii/FQXEluXEGR/FgUwgl/izrw5omSJPHb20+1TTikH2/
qPmYNCHT53AnQ==
X-Clacks-Overhead: "GNU Terry Pratchett"
X-CM-Score: 0.00
X-CNFS-Analysis: v=2.3 cv=H+BAP9Qi c=1 sm=1 tr=0
a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17
a=IkcTkHD0fZMA:10 a=I-5NkEm0Hlx2qugnExUA:9 a=QEXdDO2ut3YA:10
X-AUTH: mrabarnett@:2500
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
In-Reply-To: <30ad3e32-c7f5-e255-4c18-0147a56c3346@gmail.com>
Content-Language: en-GB
X-CMAE-Envelope: MS4wfOqw8gzvhrLMEzEQJttDdchv25cVcjOC5TInThjxNLKZJALVKGpYO4bP9+VjCf8pdHIH/t8jrdyrOWx0Bmv67XM8u0C8Td0RRZvDWU2mRLCPaNT5gdkH
aEKNLl6g42gGZpzImJDSywx0lJf4cVKBX4w3hI2Ad4sQPILwBIgejiQYL4uQBaUOBu4UxvidBj5jUw==
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <6382edc7-ac3f-7b7b-a183-c109f9fb5b8b@mrabarnett.plus.com>
X-Mailman-Original-References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<mailman.338.1628547469.4164.python-list@python.org>
<86sfzha1ac.fsf@jevedi.xotimo> <seukpg$16e4$1@ciao.gmane.io>
<mailman.345.1628624729.4164.python-list@python.org>
<861r71c7nw.fsf@jevedi.com> <sevfq5$2jb$1@ciao.gmane.io>
<30ad3e32-c7f5-e255-4c18-0147a56c3346@gmail.com>
 by: MRAB - Wed, 11 Aug 2021 18:10 UTC

On 2021-08-11 18:10, Wolfram Hinderer via Python-list wrote:
>
>
> Am 11.08.2021 um 05:22 schrieb Terry Reedy:
>> Python is a little looser about whitespace than one might expect from
>> reading 'normal' code when the result is unambiguous in that it cannot
>> really mean anything other than what it does.  Two other examples:
>>
>> >>> if3: print('yes!')
>> yes!
>> >>> [0]  [0]
>> 0
>
> Not sure what you mean here - is it a joke? The first looks like an if
> statement, but isn't. The missing space *does* make a difference. (Try
> "if0" instead.)
>
I see what you mean. It's a type annotation:

var: type

where the "type" is a print statement!

> The second is normal indexing, which allows white space. I wouldn't
> consider that surprising, but maybe I should? (Honest question, I really
> don't know.)
>

Re: some problems for an introductory python test

<mailman.351.1628712943.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=14556&group=comp.lang.python#14556

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: some problems for an introductory python test
Date: Thu, 12 Aug 2021 06:15:28 +1000
Lines: 166
Message-ID: <mailman.351.1628712943.4164.python-list@python.org>
References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<CAPTjJmoQqPErXw2WAN-FgjZq3k2AnZLEYvOruyRJ0r7nNcRCnA@mail.gmail.com>
<c495f0ee-cc76-709c-e2fb-7dde4567d853@wichmann.us>
<CAPTjJmo_zoqB1MbbmzsAMLUGVcevs1Nz-cJk0Y6-Q7typbP3Mw@mail.gmail.com>
<mailman.341.1628569106.4164.python-list@python.org>
<86lf599zse.fsf@jevedi.xotimo>
<CAPTjJmp9OvxGuMH9Mj66Ha19zf8xjaBsBGOy-gdaeVKu9v+9Ww@mail.gmail.com>
<mailman.344.1628623474.4164.python-list@python.org>
<868s18b1p7.fsf@jevedi.com>
<CAPTjJmoDofU-X3Q7+j1E5_G-d=evsgbsWdbeHNDBBiBprt3v2A@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de it1IjhS5QHTvPUJq+dyWowLY3k+TR27/zD2KGsCt5fqQ==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=GyPJohCT;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '(for': 0.05; 'fairly':
0.05; 'gui': 0.05; 'kernel': 0.05; "python's": 0.05;
'subject:python': 0.06; 'despite': 0.07; 'linux': 0.07; 'queue':
0.07; 'scripts.': 0.07; 'space,': 0.07; 'thing.': 0.07; ':-)':
0.09; 'aimed': 0.09; 'angelico': 0.09; 'api,': 0.09; 'aug': 0.09;
'broad': 0.09; 'concept.': 0.09; 'deeper': 0.09; 'describe': 0.09;
'ended': 0.09; 'fact,': 0.09; 'identical': 0.09; 'it"': 0.09;
'moved': 0.09; 'myself.': 0.09; 'neat': 0.09; 'python)': 0.09;
'subject:test': 0.09; 'types.': 0.09; 'variables,': 0.09;
'window.': 0.09; 'writes:': 0.09; 'problem.': 0.14; '3.x': 0.16;
'5:00': 0.16; 'abstraction': 0.16; 'arbitrary': 0.16; 'are.':
0.16; 'arguments': 0.16; 'bash': 0.16; 'chrisa': 0.16;
'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16;
'guis': 0.16; 'heavily': 0.16; 'inheritance,': 0.16;
'integrations': 0.16; 'interpreter': 0.16; 'machine,': 0.16; 'ms-
dos': 0.16; 'naming': 0.16; 'notable': 0.16; 'oop': 0.16;
'purely': 0.16; 'regain': 0.16; 'resolving': 0.16; 'signals,':
0.16; 'slow': 0.16; 'standards,': 0.16; 'strings,': 0.16;
'support,': 0.16; 'syntax,': 0.16; 'tenets': 0.16; 'things,':
0.16; 'times,': 0.16; 'useful.': 0.16; 'wrote:': 0.16; 'memory':
0.16; 'values': 0.16; 'python': 0.16; 'instead': 0.17; 'api':
0.18; 'it?': 0.18; 'applications': 0.18; 'code.': 0.19; 'uses':
0.19; 'name.': 0.20; 'thu,': 0.20; 'way.': 0.20; 'programming':
0.21; 'option': 0.21; "i've": 0.22; 'language': 0.22; 'machine':
0.22; 'languages': 0.23; 'object': 0.23; 'ran': 0.23; "i'd": 0.23;
'to:addr:python-list': 0.23; 'command': 0.24; 'run': 0.24; 'code':
0.24; 'probably': 0.24; 'written': 0.24; 'chris': 0.26; 'seems':
0.26; 'zip': 0.27; 'performance': 0.74; 'day.': 0.74; 'easy':
0.75; 'little': 0.75; 'tools': 0.75; 'features': 0.76;
'marketing': 0.76; 'boy': 0.77; 'businesses,': 0.77;
'collaborate': 0.77; 'features.': 0.77; 'languages,': 0.77;
'left': 0.79; 'out.': 0.80; 'states.': 0.81; 'click': 0.82;
'2021': 0.84; 'variety': 0.84; '(like': 0.84; 'absolutely': 0.84;
'agreement.': 0.84; 'became': 0.84; 'compatible.': 0.84;
'control.': 0.84; "else's": 0.84; 'feature,': 0.84; 'gigabytes':
0.84; 'keystroke': 0.84; 'luck': 0.84; 'mouse': 0.84; 'os.': 0.84;
'perspective.': 0.84; 'procedures': 0.84; 'reliability': 0.84;
'remarkably': 0.84; 'spectacular': 0.84; 'strings': 0.84;
'time).': 0.84; 'behind': 0.88; '(we': 0.91; 'assembly,': 0.91;
'illustration': 0.91; 'sad': 0.91; 'younger': 0.91; 'line,': 0.93;
'locked': 0.93; 'pleasure': 0.93; 'central': 0.95; 'hidden': 0.95;
'ibm': 0.95; 'subsequent': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=SN4LIk6i/hjcrE6luH7tPoNaAUoZUYFG6HzSf9ngMvc=;
b=GyPJohCT0kPFkNQsaBSpHIOmqdDPO5x7xdZ1ZtJ12QUCaxXUDEvWtzVn6+SBOmE2Fi
9EiTOiCJ0ZPXZgdlZFWeeMWkGlGBLg2Xcyf79ihbXr9lx3s2DwAmXKJNNzIknaXwtP2i
RVNP9IDf0B7BM5alw/5kgbFXYovBMCzVBbmUvQau/Dd4r1KtANZTyIa3bTapQuMI3FO6
Uea7HtYJwBQStgGuR9khl2yn5+VLo9Ki3BzNdYX4hplLwlE9pT8dOatx/hx6LobXzBNA
u5cvq2/8S82gL4y61X1RfaXqM2gcICwjqcDGeQZl0zmvuVccXsrKwfKsZa/flUV4C7s1
gSEA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=SN4LIk6i/hjcrE6luH7tPoNaAUoZUYFG6HzSf9ngMvc=;
b=Z7CparsbKpAiUKym/+4SvBYkEOwP71XDS8Da8Vpk4XvN2jDXXdSV83/wEX9y1hIO5Q
tPZTleAlaI9b7Fug7LnMSwTFZtnYtvcAf9EO8dehFOnDS8oAYUpN6Yqy7uxc29sdpTt0
coF5m8Qho3b1jOCNRdGqbQlPxIl85FQubj2mDTWRu+HS/ykJz1X/n8r3I0rQm+lZnq8M
qoqxPuDo+1HZ0wv4TyftwOGIKgMISqRBRH4NgtMgBwGxKf/gujMQX/EfZvSy8hH+7Sl5
8N9rlWLfC6t2zkkO94CsEpQk2Jt30YPrxlD90UQ2oOLaDnfNov48K2hTCh4pgrJOS9Y+
cZNQ==
X-Gm-Message-State: AOAM533EQFQ15sfqjumJd3PkXTTmJ8xZqxpqocMsMEsUzqrbujO4/STa
nz3E6rtWMvS05iO5gFG37/vt+1ebAA46y7V91sjqie1i
X-Google-Smtp-Source: ABdhPJwOpcNOubv0RGVeNQyr9ET6ZLHWiHmSx1lFLttEEQlqxPOEyUmpSzJuQDbk/NrL5DKqxy2/SCOza6CPPmRMVpA=
X-Received: by 2002:a02:2a07:: with SMTP id w7mr549840jaw.96.1628712939949;
Wed, 11 Aug 2021 13:15:39 -0700 (PDT)
In-Reply-To: <868s18b1p7.fsf@jevedi.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAPTjJmoDofU-X3Q7+j1E5_G-d=evsgbsWdbeHNDBBiBprt3v2A@mail.gmail.com>
X-Mailman-Original-References: <868s1acoo1.fsf@jevedi.xotimo>
<9e930795-7664-4e75-48b6-afa03c666e48@wichmann.us>
<CAPTjJmoQqPErXw2WAN-FgjZq3k2AnZLEYvOruyRJ0r7nNcRCnA@mail.gmail.com>
<c495f0ee-cc76-709c-e2fb-7dde4567d853@wichmann.us>
<CAPTjJmo_zoqB1MbbmzsAMLUGVcevs1Nz-cJk0Y6-Q7typbP3Mw@mail.gmail.com>
<mailman.341.1628569106.4164.python-list@python.org>
<86lf599zse.fsf@jevedi.xotimo>
<CAPTjJmp9OvxGuMH9Mj66Ha19zf8xjaBsBGOy-gdaeVKu9v+9Ww@mail.gmail.com>
<mailman.344.1628623474.4164.python-list@python.org>
<868s18b1p7.fsf@jevedi.com>
 by: Chris Angelico - Wed, 11 Aug 2021 20:15 UTC

On Thu, Aug 12, 2021 at 5:00 AM Hope Rouselle <hrouselle@jevedi.com> wrote:
>
> Chris Angelico <rosuav@gmail.com> writes:
>
> > On Wed, Aug 11, 2021 at 4:18 AM Hope Rouselle <hrouselle@jevedi.xotimo> wrote:
> >>
> >> Chris Angelico <rosuav@gmail.com> writes:
> >>
> >> [...]
> >>
> >> >> not disagreeing... and yeah I could have thought deeper about the
> >> >> answer, but I still think "notthing has been OOP" -> "yes it has, they
> >> >> just didn't realize it" was worth mentioning
> >> >
> >> > Oh yes, absolutely agree.
> >>
> >> At the same time, inside the machine nothing is OOP --- so all the OOP
> >> is no OOP at all and they just didn't realize it? This seems to show
> >> that OOP is about perspective. An essential thing for OOP is the
> >> keeping of states. Closures can keep state, so having procedures as
> >> first-class values allows us to say we are doing OOP too. (Arguments of
> >> procedures are messages and function application is message passing,
> >> with closures keeping a state --- and all the rest of OOP can be
> >> implemented with enough such functional technology.) In summary, OOP
> >> should not be defined as some special syntax, otherwise there is no OOP
> >> in ``2 + 2''.
> >>
> >> Having said that, I totally agree with all the nitpicking.
> >
> > Object orientation is a particular abstraction concept. It's not a
> > feature of the machine, it's a feature of the language that you write
> > your source code in. I've done OOP using IDL and CORBA, writing my
> > code in C and able to subclass someone else's code that might have
> > been written in some other language. [1] Central tenets of OOP
> > (polymorphism, inheritance, etc) can be implemented at a lower level
> > using whatever makes sense, but *at the level that you're writing*,
> > they exist, and are useful.
> >
> > Data types, variables, control flow, these are all abstractions. But
> > they're such useful abstractions that we prefer to think that way in
> > our code. So, *to us*, those are features of our code. To the
> > computer, of course, they're just text that gets processed into
> > actually-executable code, but that's not a problem.
>
> Total agreement.
>
> > So I would say that (in Python) there IS object orientation in "2 +
> > 2", and even in the Python C API, there is object orientation, despite
> > C not normally being considered an object-oriented language.
>
> But would you say that 2 + 2 is also an illustration of object
> orientation in any other language too?

In some languages it is; in others, it's not. For instance, REXX
doesn't have polymorphism. You can add two numbers together using x+y,
or you can concatenate two strings with x||y. There's no concept of
doing the same operation (spelled the same way) on different data
types. (Partly that's because REXX doesn't actually *have* data types,
but it does a pretty good job of simulating strings, bignums, floats,
arrays, mappings, etc.)

But in many modern programming languages, yes, it would be a
demonstration of some of the object orientation features.

> Regarding C, I have many times said that myself. If I wrote assembly,
> I'm sure I would do my best to create things like procedures --- a label
> and some bureaucracy to get arguments in and a return value out.

Oh absolutely. But you'd also have the option to shortcut things if
you wanted to. For better or for worse.

> > [1] And boy oh boy was that good fun. The OS/2 Presentation Manager
> > had a wealth of power available. Good times, sad that's history now.
>
> I know OS/2 only by name. I never had the pleasure of using it. In
> fact, I don't even know how it looks. I must be a little younger than
> you are. But not too younger because I kinda remember its name. Was it
> a system that might have thought of competing against Microsoft Windows?
> :-) That's what my memory tells me about it.

History lesson!

Once upon a time, IBM and Microsoft looked at what Intel was
producing, and went, hey, we need to design an operating system that
can take advantage of the fancy features of this 80286 thing. So they
collaborate on this plan to make a 16-bit protected mode OS.
Unfortunately, things didn't work out too well, partly because this
was when Microsoft was at its most monopolistic, and they ended up
parting company. IBM continued to make OS/2, but Microsoft took their
part of the code and made Windows NT out of it.

(Aside: Windows NT's 16-bit applications and OS/2's 16-bit
applications were actually identical and compatible. Unfortunately,
Win32 introduced a very new API, so as soon as everyone moved to
32-bit everything, the schism became problematic. But it was actually
possible to package up a single .EXE file with a 16-bit MS-DOS loader,
a Win32 loader, and an OS/2 32-bit loader, all happily coexisting.
PKZIP, the original definition of the zip file format, did exactly
that, or at least had two out of the three (I don't quite remember if
it went the whole way), making it extremely convenient to zip and
unzip files on different computers.)

In the latter half of the 1990s, Windows came in three broad flavours:
the 16-bit Windows 3.x line, which ran purely on top of DOS; the
32-bit Windows 95 line, which was the "home" OS and had to be heavily
compatible with Windows 3, but still doing more things; and the
Windows NT line, which was aimed at businesses. OS/2 was a viable
option for businesses, but almost nobody took it seriously as a home
OS. And Microsoft was using its marketing machine to push Windows
fairly hard, so most people went that way.

OS/2 had all kinds of amazing features (for its time). The default
file system, HPFS ("High Performance File System"... IBM was good at
many things, but imaginative naming wasn't one of them), did a
spectacular job of maintaining reliability and performance on the
ever-growing hard disks of the time. Yes, it coped remarkably well,
even on *gigantic* drives that could carry, ooh, an entire gigabyte of
data! I'm not kidding! We even had a drive that had TWO gigabytes of
space, and HPFS managed it beautifully! Plus, it had this fancy
concept of "extended attributes"; on older systems (like MS-DOS's
"FAT" family), a file might be Read-Only, Hidden, a System file, or
needing to be Archived, and that was it - but on HPFS, you could
attach arbitrary data like "File type: DeScribe Word Processor" or
"Double click action: Run CASMake.cmd". This allowed the GUI to store
all kinds of information *on the file itself* instead of needing
hidden files (or, in Windows' case, the registry) to track that kind
of thing.

The default command interpreter and shell on OS/2 was fairly primitive
by today's standards, and was highly compatible with the MS-DOS one,
but it also had the ability to run REXX scripts. REXX was *way* ahead
of its time. It's a shell language but remarkably well suited to
building GUIs and other tools (seriously, can you imagine designing a
GUI entirely in a bash script??). It had features that we'd consider
fairly normal or even primitive by Python's standards, but back then,
Python was extremely new and didn't really have very much mindshare.
REXX offered arbitrary-precision arithmetic, good databasing support,
a solid C API that made it easy to extend, integrations with a variety
of other systems... this was good stuff for its day. (REXX is still
around, but these days, I'd rather use Python.)

I mentioned the Presentation Manager, because it was one of the best
parts of running OS/2. The kernel was decent, but it was the graphical
shell that was the real pleasure to work with. Probably the most
notable feature, by today's standards, was that it had a single input
queue. If you press a series of keys, they'd go into a global queue,
and the application that has focus would get the first one. When that
key has been handled, the application that has focus would get the
next key from the queue. This means that, if the response to a
keystroke is to change focus, then *even in a slow and lagged out
system*, subsequent keys WOULD be sent to the new target window. That
was AWESOME, and I really miss it. Except that I also don't. Because
if a single application is having issues, now your entire keyboard and
mouse is locked up... which kinda slightly sucks. Good luck resolving
that problem. (We had some neat tools like WatchCat that could get
around the single input queue via interrupt signals, and regain
control. But it was still problematic.)

So, yeah. It was spectacular in its day.... but it kinda got left
behind as the world moved on. These days, instead of running REXX code
on OS/2 in a system that uses eight-bit text for most things, I use
Python on Linux and full Unicode. But OS/2 was an important part of
history, both my own personal journey, and the history of the world of
PCs.


Click here to read the complete article
Pages:123
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor