[Edu-sig] comments on a Python expert Youtube / Python2 vs Python3

kirby urner kirby.urner at gmail.com
Fri Aug 11 23:40:27 EDT 2017


I just listened to the first 18 minutes, 7 seconds of this PyData talk:

https://youtu.be/7lmCu8wz8ro

What Does It Take To Be An Expert At Python?

The speaker, James Powell. has an excellent and engaging style.
However, two things:

* the degree of the polynomials he's showing is 2 in both cases, not 3

* __call__ makes perfect sense with a polynomial:  feed in a value for x,
get the result.

On another topic:

In my inhouse memos (Coding with Kids) I encourage Python2 and Python3, for
2.x series and 3.x series respectively.

We have the precedent of CPython (a prefix) so could say CPython2
unambiguously.

Django3 etc. is also suggested.

Codesters.com works to emulate Python3.  The turtle is in trouble at the
moment, unable to draw a circle reliably, especially when moving backwards.

Regarding "dunder methods" (special names), calling them "data model"
methods is not a bad idea.  I still like to call them __ribs__ thinking of
snakes (pythons) being hollow __rib__ cages.  We're talking about how we
give our classes a backbone of neural arc behaviors.

Kirby

PS:  one of my polynomial classes from ages ago:

"""
Really simple Poly (polynomial class)

Example usage:
>>> from simppoly import Poly
>>> p = Poly([1,2,0,0,3,-4])
>>> p
(1 * (x**0))+(2 * (x**1))+(3 * (x**4))+(-4 * (x**5))
>>> p(10)
-369979
"""

class Poly(object):

    def __init__(self, coeffs):
        """
        Coefficients in order of increasing degree, 0 where necessary
        """
        self.coeffs = coeffs

    def __call__(self, x):
        """
        Triggers evaluation of string representation for 'x' = x
        """
        return eval(repr(self), {'x':x})

    def __repr__(self):
        """
        Build a string representation, low to high degree, skipping 0
coefficients
        """
        monomials = [ '(%s * (x**%s))' % (c,e)
        for c,e in zip(self.coeffs, range(len(self.coeffs))) if c<>0]
        return ' + '.join(monomials)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edu-sig/attachments/20170811/54714775/attachment.html>


More information about the Edu-sig mailing list