[Edu-sig] interactive vs compiled from file

Andre Roberge andre.roberge at gmail.com
Fri Aug 3 23:02:13 CEST 2007


On 8/3/07, Andre Roberge <andre.roberge at gmail.com> wrote:
>
>
>
> On 8/3/07, Michael Tobis <mtobis at gmail.com> wrote:
> >
> > One problem I have consistently had with beginners is in explaining
> > the difference between how the interpreter produces output without an
> > explicit 'print' statement (producing the str() of the last evaluated
> > expression) and how python run from a file does not.
> >
> > This is perfectly natural and useful for an experienced user, but it
> > is awkward and confusing for the beginner, who has enough of a
> > cognitive load just trying to track all the pieces.
> >
> > This leads to two (well, four) questions:
> >
> > 1) How have you folks addressed this problem in your beginning
> > classes? Do you find it causes difficulties?
> >
> > 2) Would it be difficult to provide an alternative interpreter that
> > produced nothing unless you asked it to print?
>
>
If you want to give it a try, here's what you need to do.

Find the code.py module in the standard library.  Replace 'single' by 'exec'
in runsource() i.e.

    def runsource(self, source, filename="<input>", symbol="single"):
by
    def runsource(self, source, filename="<input>", symbol="exec"):

To run it:
import code
code.interact()

Unless I am missing something, this should do the trick.

Ideally, one would change the prompt too so as to distinguish it from the
regular interpreter.

André

Would this be a good
> > idea?
>
>
>
> I'll reserve judgement as to whether or not this is a good idea, but it's
> possible to do - at least, according to a quick implementation I tried with
> Crunchy.
>
> *If* this is a desirable feature, and assuming my quick test is correct, I
> could include it as yet another type of interpreter available within
> Crunchy.  :-)
>
> André
>
> P.S. it would need a name to distinguish it from the normal interpreter.
> (un-parrot?)
>
> thanks
> > mt
> > _______________________________________________
> > Edu-sig mailing list
> > Edu-sig at python.org
> > http://mail.python.org/mailman/listinfo/edu-sig
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/edu-sig/attachments/20070803/5bee4999/attachment.htm 


More information about the Edu-sig mailing list