[Microbit-Python] Accessor API design on the micro:bit
Michael
sparks.m at gmail.com
Tue Nov 3 03:58:37 EST 2015
On 2 November 2015 at 21:06, Larry Hastings <larry at hastings.org> wrote:
...
> I don't know what the curriculum will look like, but I would be very
> surprised indeed if it permanently skipped variables and only ever taught
> the students functions. Since presumably the students *will* be taught
> about variables, I don't see a need to remove any and all variables (or
> things that merely look like variables!) from our API.
>
Strawman argument. They're taught variables not properties. To them a
variable a value that when you set it, it stays that value until you change
it again.
To you it's "merely look like a variable", but that merely is actually an
extra-ordinary leap.
Python properties are an advanced concept in any python tutorial because
they require understanding of descriptors, and python objects,
getters/setters (since they're there under the hood) and so on.
Also, while I think they're *nice* they are actually far far less used than
people realise.
$ pwd
/usr/lib/python2.7/dist-packages
$ grep @property `find -type f|grep py$`|cut -d: -f1 |uniq |sort|cut -d/
-f2|sort|uniq |wc -l
62
$ ls -p|grep /|wc -l
239
$ find -type f|grep py$|wc -l
7713
$ wc -l `find -type f|grep py$`|tail -1
2164030 total
$ grep @property `find -type f|grep py$`|wc -l
1151
ie the best figure I can find is 1/4 of projects used use python
properties, 3% of files use them, and you'll only see a @property usage in
one out of every 2000 lines of code.
To me that suggests it's niche *except* for people who have been using
python for years - that's much much much more niche than I expected.
Michael.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/microbit/attachments/20151103/f7969688/attachment-0001.html>
More information about the Microbit
mailing list