[Nolug] Teaching languages

From: Ron Johnson <ron.l.johnson_at_cox.net>
Date: 13 Jul 2003 02:45:12 -0500
Message-Id: <1058082311.18890.224.camel@haggis>

On Sun, 2003-07-13 at 01:27, Brad N Bendily wrote:
> Just out of curiosity, since you guys seem to be very
> knowledgeable of the programming arena...
>
> What do you all think is the best language for a newbie
> to learn? I mean mostly a student going into college
> in his freshmen class.
> If you had the choice, as a seasoned programmer.
> What language would you teach someone?
>
> In my opinion, although I haven't really used
> any language extensively, I would think either
> C or C++. Mostly because those languages seem to
> be a foundation for current languages.

I'd say "Python on 'Unix'", but "Python on Windows" is almost
as good. It has a clear syntax, is either procedural or object
oriented, depending on your own desires, and yet the simplicity
does not limit you, like Pascal does.
http://www.python.org/doc/FAQ.html#1.1
http://www.python.org/doc/FAQ.html#2.12
http://www.python.org/doc/current/tut/node5.html
http://www.python.org/sigs/edu-sig/
http://www.inetarena.com/~pdx4d/ocn/overcome.html

The only thing negative that Python does do, as a consequence
of being an interpreter, is insulate one from the h/w, but then
so does Java, C# and Perl.

As an example, here's a short program that looks through every
file in and under '.' for files with " " in the name, and changes
each " " to "_". Note the non-line-noise use of regular expressions.

<CODE>
import os, re, os.path
def each_dir(arg, dirname, names):
   print dirname
   for file in names:
      file1 = os.path.join(dirname, file)
      if os.path.isfile(file1) and (file.find(' ') != -1):
         new_file = os.path.join(dirname, re.sub(' ', '_', file))
         print file1, '------------', new_file
         os.rename(file1, new_file)
 
os.path.walk('.', each_dir, '')
</CODE>

Here's another snippet that looks at your account on a pop3
server and lets you delete some while still on the server.
It's an example of object orientation and internet accessibility.

<CODE>
import getpass, poplib, string
M = poplib.POP3('pop.east.cox.net')
M.user('ron.l.johnson')
M.pass_(getpass.getpass())
numMessages = len(M.list()[1])
print numMessages
x = M.list(0)
for i in range(1, numMessages):
   print '=============================================='
   x = M.top(i, 0)
   print i
   for y in x[1]:
       z = string.split(y, ' ')
       if z[0] in ('Date:', 'From:', 'To:', 'Subject:'):
           print z
   a = raw_input('Delete this message?')
   if a in ('Y', 'y'):
       M.dele(i)
   if a in ('Q', 'q'):
       break
M.quit()
</CODE>

-- 
+-----------------------------------------------------------+
| Ron Johnson, Jr.     Home: ron.l.johnson@cox.net          |
| Jefferson, LA  USA   http://members.cox.net/ron.l.johnson |
|                                                           |
| 4 degrees from Vladimir Putin
+-----------------------------------------------------------+
___________________
Nolug mailing list
nolug@nolug.org
Received on 07/13/03

This archive was generated by hypermail 2.2.0 : 12/19/08 EST