examining an initial, pristine python3 shell session

Alf P. Steinbach alfps at start.no
Wed Jan 20 13:43:23 CET 2010


* Robert P. J. Day:
>   still working my way through "dive into python 3" and i've already
> been asked to give a newbie tutorial on it -- blind leading the blind,
> as it were.  that should be hilarious.
> 
>   i'll be using python 3 and it occurred to me that it would be
> educational (at least for me :-) to display what an initial p3 shell
> session looks like before doing any imports whatsoever.  as in, i run
> "python3" on my fedora box and, at the ">>>" prompt, i want to show
> what's already there for the new user.
> 
>   from what little i know so far, i'd start with:
> 
>>>> __name__
> '__main__'
> 
> to display the name of the current scope(?).  backing up a bit, i
> could run either of:
> 
>>>> dir()
> ['__builtins__', '__doc__', '__name__', '__package__']
>>>> globals()
> {'__builtins__': <module 'builtins' (built-in)>, '__name__':
> '__main__', '__doc__': None, '__package__': None}
> 
>   then i might go a bit further to examine some of *those* objects.  i
> admit it might seem a bit dry, but i think it would be handy to have a
> handle on what a clean shell session looks like before starting to
> import things, then seeing how that importing changes the session
> before getting down to actual programming.
> 
>   what other useful commands might i run immediately after starting a
> session whose output would be informative?  i can certainly poke at
> some of those objects to see them in more detail.  i'm just curious
> what others might recommend.  thanks.

That depends on what you mean by "newbie".

If it's someone who knows a little bit of programming but is new to Python, then 
'help' would definitely be about the first thing I'd show her.

But if it's someone who doesn't even know anything about programming, then I'd 
recommend (blatant plug) <url: http://tinyurl.com/programmingbookP3>  --  its 
first two chapters are constructed around complete, concrete examples. However, 
you would have to adapt just the *sense* of the first chapter, which is only 
about tool usage, to *nix, since it's written for Windows. I'd not dive into 
'help' for the someone who doesn't know anything because it gets technical 
pretty fast, and because she will get back to that on her own when it's time.

Whatever you do, and whatever the background of the newbie, do introduce turtle 
graphics right away.

The ch 2 of the above reference contains some t.g. examples that you might use 
(initial silly figures, graphs of functions, recursive figures). It doesn't go 
into the turtle module objects. But if objects are what you want to show right 
away, then I think the turtle module is great also for that, because those 
objects are simple and can be easily explored.


Cheers & hth.,

- Alf



More information about the Python-list mailing list