Python Learning

ROGER GRAYDON CHRISTMAN dvl at psu.edu
Sat Dec 16 13:27:40 EST 2017


On Sat, Dec 16, 2017, Marko Rauhamaa wrote: >
Chris Angelico <rosuav at gmail.com>:
>
>> On Sat, Dec 16, 2017 at 11:41 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
>> ram at zedat.fu-berlin.de (Stefan Ram):
>>   As a start, one should learn:
>>
>>     1.) how to install Python
>>         (if not already installed)
>>
>>     2.) how to start the Python console
>>         (if not already started)
>>
>>     3.) how to type characters into a line of the
>>         console and how to submit the line (using
>>         the Enter key) (if this is not already known)
>>
>> A good list. Even more important, though, is the installation, use and
>> understanding of a text editor. What is the difference of MS Word,
>> Notepad and a Python-aware text editor? What text editors are there?
>> What is a newline? What is whitespace? (Advanced: what is a TAB.) What
>> is the difference between lower case and upper case? What is trailing
>> whitespace? What is an underscore? What is the difference between a
>> parenthesis, bracket and a brace?
>>
>> What is a file? What is a filename? What is a directory/folder? What is
>> a pathname? What is a terminal (emulator)? What is standard input? What
>> is standard output?
>>
>> How do I see the listing of files? How do I erase a file? How do I
>> rename a file? What is the current working directory? How do I change it
>> and why?
>>
>> ... at which point you realize that you're deep in TL;DR territory and
>> none of what you mentioned will be even thought about.
>
>Hm. I don't think you can get away from getting acquainted with all of
>the above before you can write your first "Hello, World!" program in
>Python.
>
>It was simpler when I first learned Basic. There were no files, and your
>REPL was your editor. The ingenious line numbers took the role of the
>text editor.
>
>Unfortunately, Python's indentation mechanism makes the REPL too
>frustrating an environment to type in even the simplest of function
>definitions, let alone a whole class.
>
>
>Marko
>


On the contrary, I think I think you can getaway with a lot of those items:
Let's see:

All the stuff about files, folders, directories, etc:

Running the Python IDLE environment that comes for free along with the
free download, creates its own little folder for all the work, saves the files
in that folder, and makes it easy for you to see what is in there, recover
your previous programs, etc.  I have never had any difficulty in using the
File menu to Open a Recent File, etc.

Of course, I assume the ability to obtain the Python environment, that
requires pointing your browser at the appropriate web site, find the
download page, and so on.   I guess I am assuming that most of my 
students have either used the web before, or have downloaded software
(such as their favorite games or apps).   It has been about twenty years
since I felt a need to teach my students how to find the on/off switch.

MS Word, vs. Notepad, vs. vi, vs. Emacs, vs. vs. vs. vs.
Since Python IDLE has its own development environment,
that is sufficient.   And it even addresses the tab vs. space
indentation issues all by itself, and lets you Indent and Dedent
whole blocks of code cleanly and easily.   

So, Hello World is trivial.  In fact, there are two trivial ways to do it
with Python IDLE.

You get the Shell for free, and just type your print call there.

Or you go to the File Menu, Open a new file, type in one statement,
and activate the Run option on the menu bar.

Now, as far as those other items you think impose an excessive
burden on our poor students:

Difference between parenthesis, bracket, and a brace:
These are simple syntactic punctuation, introduced one item at a time.
They should already know about parentheses from even elementary
arithmetic courses, if not basic algebra.
Brackets can be postponed until you are ready to reach about lists.
Braces can be postponed until you are ready to teach about dictionaries.
Put them in their proper context, and then thinking in the proper context
should make the correct choice of punctuation automatic.

"Python's indentation mechanism ... frustrating ...
even the simplest function definitions, let alone a whole class."
When first reading this, I was wondering why you were even 
considering class definitions in a first course.    If you find
print("Hello, world!"   to be too complicated for this first course,
how can you expect any meaningful coverage of OOP?

But aside from that, indentation can also be postponed.
I went four-five weeks into my course before needing any indentation
whatsoever.   All the code was straight down top to bottom
with no function definitions, conditional statements, or loops.
I did make use of some short lists and dictionaries, since 
those conveniently have many useful methods defined within them,
so could solve several interesting straightforward problems
without introducing too much of the language.

Oh, and when the time comes, as above, the Python IDLE
environment does a perfectly adequate job in handling indentation.

Not so much the case in C++ as a first language, of course.
Well, yes, you could get away with writing a complete C++ program
with no indentation whatsoever, but I haven't yet met a course
that would encourage that.  

I hope you are not one of those instructors I still see that
reason that since all programs in Java, C, and C++ require
a function named main(), then so do all Python programs
require a function named main(), called within 
if __name__ == '__main__':       main()





More information about the Python-list mailing list