Regarding @property and covarying the dimensions of geometric shapes
(Circle an example), I mentioned wanting to have a Triangle type for my
middle school kids.

The cloud-base Web browser based Codesters implementation of Python 3 is a
dialect.  No yield nor could I get @property to work, so made edges be
method calls.

https://www.codesters.com/preview/aaae86e39e61413b938ce3e5350515ca/

https://flic.kr/p/S86M6F  (input console, triangle edges, area printed)

https://flic.kr/p/S86Mfi  (turtle graphics also drawn, behind the console)

This Codesters version is a pared down full-blown 3.5 implementation on
Github.

https://github.com/4dsolutions/Python5/blob/master/triangles.py

I'm not yet being as ambitious as I could be, defining rules for letting
the user vary dimensions arbitrarily e.g.

(1) change in area:  resize to a similar triangle keeping all angles
unchanged
(2) change in edge: keep other two edges same length varying only opposite
angle unless not possible, raise exception
(3) change in angle: change opposite edge

Given assignment to attributes (properties), the expectation is more "state
change" of an object, versus obtaining a new immutable, as with strings.

We're not calling, we're setting, the antithesis of the functional
programming ideal, surrendering to objects with hidden state.

In this implementation, I'm going with more of a read-only triangle.

The initializer passes in vertexes A, B and C as (x,y) pairs and everything
from then on is read-only. [2]

The emphasis might be on learning about triangles, leveraging prior
knowledge of Python syntax, or on leveraging prior knowledge about
triangles to learn more about how to program in Python.  I think it's a two
way street. [3]

Kirby

PS: This thread over on math-teach is perking along....
http://mathforum.org/kb/thread.jspa?threadID=2838432
(expressing skepticism we can build competence through robot schools)

[1] I first learned of Gattegno from Ian Benson at Pycon / Chicago the last
year it was there, with connections to Stanford, including to Terry
Winograd who knows Fernando Flores whom we had a Pycon 2016 keynote about
as some might recall:

https://youtu.be/ckW1xuGVpug?t=32m17s
https://en.wikipedia.org/wiki/Terry_Winograd
https://en.wikipedia.org/wiki/Fernando_Flores

[2]  Using __mul__ to implement scaling, returning a new Triangle, would
make sense. That wouldn't be a state changer.

[3]  recycling my math teacher's lament (not quite the same as Lockhart's,
though overlapping):

https://medium.com/@kirbyurner/the-plight-of-high-school-math-teachers-c0faf0a6efe6

http://www.maa.org/external_archive/devlin/LockhartsLament.pdf
_______________________________________________
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig

Reply via email to