[Python-ideas] Framework for Python for CS101

Wes Turner wes.turner at gmail.com
Mon May 25 20:33:41 CEST 2015


On Mon, May 25, 2015 at 7:11 AM, Rustom Mody <rustompmody at gmail.com> wrote:

>
> On Monday, May 25, 2015 at 1:31:58 PM UTC+5:30, Andrew Barnert via
> Python-ideas wrote:
>>
>> On May 24, 2015, at 22:06, Rustom Mody <rusto... at gmail.com> wrote:
>>
>> Context:  A bunch of my students will be working with me (if all goes
>> according to plan!!)to hack on/in CPython sources.
>>
>> One of the things we would like to try is a framework for CS101 [Intro to
>> programming]
>>
>> So for example beginners get knocked out by None 'disappearing' from the
>> prompt
>> Correctable by
>>
>> >>> import sys
>> >>> sys.displayhook = print
>>
>> Now of course one can say: "If you want that behavior, set it as you
>> choose"
>> However at the stage that beginners are knocked down by such, setting up
>> a pythonstartup file is a little premature.
>>
>> So the idea (inspired by Scheme's racket) is to have a sequence of
>> 'teachpacks'.
>> They are like concentric rings, the innermost one being the noob ring,
>> the outermost one being standard python.
>>
>>
>> How exactly does this work? Is it basically just a custom pythonstartup
>> file that teachers can give to their students? Maybe with some menu- or
>> wizard-based configuration to help create the file? Or is this some
>> different mechanism? If so, what does setting it up, and distributing it to
>> students, look like?
>>
>
> Frankly Ive not thought through these details in detail(!)
>
>
>> I realize that below you talk about doing things that are currently not
>> easy to do in a pythonstartup, like hiding all mutating sequence methods,
>> but presumably the patches to the interpreter core would be something like
>> adding hide_mutating_sequence_methods() and similar functions that teachers
>> could then choose to include in the pythonstartup file or whatever they
>> give out.
>>
>>
> I personally would wish for other minor surgeries eg a different keyword
> from 'def' for generators.
> From the pov of an experienced programmer the mental load of one keyword
> for two disparate purposes is easy enough to handle and the language
> clutter from an extra keyword is probably just not worth it.
> However from having taught python for 10+ years I can say this
> 'overloading' causes endless grief and slowdown of beginners.
>

* https://docs.python.org/2/library/tokenize.html
* https://hg.python.org/cpython/file/2.7/Lib/tokenize.py
* https://hg.python.org/cpython/file/tip/Grammar/Grammar
*
https://www.youtube.com/watch?v=R31NRWgoIWM&index=9&list=PLt_DvKGJ_QLZd6Gpug-6x4eYoHPy4q_kb

* https://docs.python.org/devguide/compiler.html
* https://docs.python.org/2/library/compiler.html

I identify functions that are generators by the 'yield' (and 'yield from')
tokens.

I document functions that yield:

def generating_function(n):
    """Generate a sequence
    # numpy style
    :returns: (1,2,..,n)
    :rtype: generator (int)

    # google-style
    Yields:
        int: (1,2,n)

    """
    returns (x for x in range(n))




> Then there is even more wishful thinking changes -- distinguishing
> procedure from function.
> After 30 years of Lisp and ML and ... and Haskell and
> square-peg-into-round-holing these into python, Ive come to the conclusion
> that Pascal got this distinction more right than all these.  However I
> expect this surgery to be more invasive and pervasive than I can handle
> with my (current) resources.
>

@staticmethod, @classmethod, @property decorators


> etc
> etc
> In short I am talking of a language that is morally equivalent to python
> but cosmetically different and is designed to be conducive to learning
> programming
>

I suppose you could fork to teach; but [...].

You might check out http://pythontutor.com/ and/or http://www.brython.info/
(Python, JS, and compilation).


>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150525/c0c16899/attachment-0001.html>


More information about the Python-ideas mailing list