examining an initial, pristine python3 shell session
Robert P. J. Day
rpjday at crashcourse.ca
Wed Jan 20 10:02:42 EST 2010
On Wed, 20 Jan 2010, Alf P. Steinbach wrote:
> * Robert P. J. Day:
... snip ...
> > 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.
ah, thank you, i appreciate that reference. i'm expecting the small
audience to be relatively tech-savvy with OO dev experience, and i'm
betting that some of them will be wondering right off the very first
thing *i* was wondering -- when i start that python3 shell and get
dumped into it, what am i looking at? which is why i wanted to
collect a few commands to give the attendees at least a vague idea of
what was already there.
i've collected the following to start with:
>>> dir()
['__builtins__', '__doc__', '__name__', '__package__']
>>> globals()
... stuff ...
then move on to examine *those* things:
>>> type(dir)
<class 'builtin_function_or_method'>
>>> type(globals)
<class 'builtin_function_or_method'>
>>> type(__builtins__)
<class 'module'>
zoom in a bit further and pick on specific examples:
>>> dir(__builtins__)
... lots of output ...
and so on. as i said, i know it looks dry but i figure i can take 5
minutes or so just to lay out the terrain and what a shell session
looks like before you do *anything* with it. and i'm betting most of
my audience will appreciate getting that high-level view before
launching into some programming. they'll just want to know the
initial session setup before they start importing stuff into it.
rday
--
========================================================================
Robert P. J. Day Waterloo, Ontario, CANADA
Linux Consulting, Training and Kernel Pedantry.
Web page: http://crashcourse.ca
Twitter: http://twitter.com/rpjday
========================================================================
More information about the Python-list
mailing list