Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

More stuff added to ch 2 of my programming intro

1 view
Skip to first unread message

Alf P. Steinbach

unread,
Dec 9, 2009, 10:38:41 AM12/9/09
to
Format: PDF
<url: http://preview.tinyurl.com/ProgrammingBookP3>

The new stuff, section 2.7, is about programs as simulations and handling data,
focusing on modeling things. It includes some Python GUI programming. The plan
is to discuss containers like lists and dictionaries in perhaps two more
subsections of 2.7, but I'm not quite sure about how to approach that or exactly
how much to cover, since the intent of ch 2 is to introduce mostly general
concepts and enable the reader to try out (more or less) interesting things.


Cheers,

- Alf

PS: comments welcome!

Alf P. Steinbach

unread,
Dec 14, 2009, 2:23:00 AM12/14/09
to
* Alf P. Steinbach:

Well, I posted the current doc. It has a not yet quite complete section 2.7.7
about arrays, and that will be the last subsection of the chapter. I thought
using the Josephus circle problem as example was pretty neat... :-)

But anyway, comments welcome, even if that last section's not yet finished.


Cheers,

- Alf

PS: Oh, I changed the manuscript title to "Intelligent Person's Intro to
Programming" -- is that good?

Alf P. Steinbach

unread,
Dec 16, 2009, 4:31:00 PM12/16/09
to
* Alf P. Steinbach:

> * Alf P. Steinbach:
>> Format: PDF
>> <url: http://preview.tinyurl.com/ProgrammingBookP3>
>>
>> The new stuff, section 2.7, is about programs as simulations and
>> handling data, focusing on modeling things. It includes some Python
>> GUI programming. The plan is to discuss containers like lists and
>> dictionaries in perhaps two more subsections of 2.7, but I'm not quite
>> sure about how to approach that or exactly how much to cover, since
>> the intent of ch 2 is to introduce mostly general concepts and enable
>> the reader to try out (more or less) interesting things.
>>
>>
>> Cheers,
>>
>> - Alf
>>
>> PS: comments welcome!
>
> Well, I posted the current doc. It has a not yet quite complete section
> 2.7.7 about arrays, and that will be the last subsection of the
> chapter. I thought using the Josephus circle problem as example was
> pretty neat... :-)
>
> But anyway, comments welcome, even if that last section's not yet finished.

Well, what's a programming introduction without Lena S�derberg and Blaise Pascal
-- the beauty & the beast? :-)

So I added them. Examples with some Sierpinsky triangles (from Pascal's
triangle) and simple photo processing (of Lena). With Lena, Josephus and Blaise
in the examples it's almost like the Good, the Bad and the Ugly...

Comments very welcome.

Especially, from the Python community, I'm pretty sure that there must be more
Pythonic ways of copying things like my Matrix in section 2.7.7, or conventions
established for that. Although Python details aren't essential -- since this
is about programming and so far only about concepts, notwithstanding the photo
processing not yet delving into actually technical stuff -- it would be Bad to
teach very inferior ways of using the language. So, Better Ways (considering
that I've endavoured to introduce only a minimal subset of the language in order
to teach concepts cleanly!) would be good!

Current contents listing below (it's now also as PDF on Google Docs).


Cheers,

- Alf

Contents:

1 Getting started ... 1
1.1 Python variants, implementations and distributions. 1
1.2 Download and install a Python implementation. 2
1.3 Test-drive the Python interpreter. 2
1.4 Create and run a Python console program. 4
1.5 Syntax highlighting and programmers� editors. 6
1.6 Create and run a Python GUI program. 7
1.7 About compilation. 9
1.8 About standalone Windows programs & other kinds. 10
1.9 Browse the local documentation. 11
� EOT � ... 12

2 Basic concepts ... 1
2.1 Super-basic concept: why programming is not DWIM. 1
2.2 Reported errors. 4
2.2.1 Case-sensitivity. 4
2.2.2 Syntax / compilation errors. 4
2.2.3 Runtime errors / crashes. 5
2.3 A programming exploration tool: turtle graphics. 6
2.4 Naming things. 8
2.4.1 Naming actions: routines. 8
2.4.2 Naming data part I: variables. 11
2.4.3 Naming data part II: routine arguments. 13
2.5 Controlling the flow of execution. 14
2.5.1 Repeating actions automatically: loops. 14
2.5.2 Basic comparisions & boolean values. 16
2.5.3 Interlude I: a function graph program / about types. 17
2.5.4 Automated action choices. 21
2.5.5 Value-producing (function-like) routines. 23
2.5.6 Interlude II: a graph with zeroes marked / about program structure. 26
2.5.7 Dynamically nested actions: recursive routines. 28
2.6 Basic data. 36
2.6.1 Basic fundamental types / strings & concatenation. 36
2.6.2 Indexing and single characters (+ vaguely about sequences in general). 39
2.6.3 Interlude III: a ROT-13 encryption/decryption program, refactoring. 40
2.6.4 Attributes, methods, objects. 43
2.6.5 Doc strings. 44
2.6.6 Interlude IV: attribute names as strings, listing str attributes. 45
2.6.7 References & automatic garbage collection. 46
2.7 Programs as simulations / handling data. 51
2.7.1 Real system, model, user illusion. 51
2.7.2 Scopes � global versus local variables. 53
2.7.3 Attribute collections & models with accessor and modifier routines. 57
2.7.4 Defining your own data types: classes. 63
2.7.5 Using optional and named actual arguments (Python �keyword� arguments). 68
2.7.6 Interlude V: a GUI light switch simulation (+ about delegates and MVC). 71
2.7.7 Indexable collections (arrays). 84
� EOT � ... 98

Mensanator

unread,
Dec 16, 2009, 5:41:30 PM12/16/09
to

Sure. After all, "Idiot's Guide to Programming" and "Programming for
Dummies" are probably already taken, albeit more appropriate.

Mensanator

unread,
Dec 16, 2009, 6:07:23 PM12/16/09
to

Oh, and about Chapter 1.

If you're going to use version 3.1.1 as your standard, shouldn't
you also point out that 3.1.1 is NOT bundled with Mac OS X?

How about devoting a section on downloading the source files
and compiling it on a Mac?

Alf P. Steinbach

unread,
Dec 16, 2009, 6:45:18 PM12/16/09
to
* Mensanator:

Learn to read.

At the top of every second page it tells you that this is an introduction based
on Windows.

Cheers & hth.,

- Alf

Mensanator

unread,
Dec 16, 2009, 8:02:07 PM12/16/09
to

Still, no excuse for giving out mis-information. It's just as easy
to get these things right.

>
> Cheers & hth.,
>
> - Alf- Hide quoted text -
>
> - Show quoted text -

Ned Deily

unread,
Dec 16, 2009, 9:45:31 PM12/16/09
to pytho...@python.org
In article
<88bab2c0-d27c-4081...@9g2000yqa.googlegroups.com>,

Mensanator <mensa...@aol.com> wrote:
> Oh, and about Chapter 1.
>
> If you're going to use version 3.1.1 as your standard, shouldn't
> you also point out that 3.1.1 is NOT bundled with Mac OS X?
>
> How about devoting a section on downloading the source files
> and compiling it on a Mac?

Why would you do that?

http://www.python.org/download/releases/3.1.1/
http://www.python.org/ftp/python/3.1.1/python-3.1.1.dmg

or (for MacPorts fans):

$ sudo port install python31

--
Ned Deily,
n...@acm.org

Alf P. Steinbach

unread,
Dec 17, 2009, 12:17:37 AM12/17/09
to

Why are you not concrete?

I'd be glad to hear of any concrete mis-information or inaccuracy; that's much
of the point of asking for public feedback (did you even think about that?).

Unfortunately one then also get responses from trolls, small kids, idiots, etc..

Cheers,

- Alf

Richard Heathfield

unread,
Dec 17, 2009, 2:10:48 AM12/17/09
to
In <hgcf1d$5gu$1...@news.eternal-september.org>, Alf P. Steinbach wrote:

> * Mensanator:
>> On Dec 16, 5:45 pm, "Alf P. Steinbach" <al...@start.no> wrote:

<snip>

>>> Learn to read.
>>>
>>> At the top of every second page it tells you that this is an
>>> introduction based on Windows.
>>
>> Still, no excuse for giving out mis-information. It's just as easy
>> to get these things right.
>
> Why are you not concrete?
>
> I'd be glad to hear of any concrete mis-information or inaccuracy;
> that's much of the point of asking for public feedback (did you even
> think about that?).
>
> Unfortunately one then also get responses from trolls, small kids,
> idiots, etc..

In my experience, mensanator doesn't usually behave trollishly.
Perhaps he's just rubbing you up the wrong way accidentally. It might
be worth it for both you guys to chill a little, and cut each other
some slack.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within

Mensanator

unread,
Dec 17, 2009, 2:25:24 AM12/17/09
to
On Dec 16, 8:45�pm, Ned Deily <n...@acm.org> wrote:
> In article
> <88bab2c0-d27c-4081-a703-26b353b9e...@9g2000yqa.googlegroups.com>,

>
> �Mensanator <mensana...@aol.com> wrote:
> > Oh, and about Chapter 1.
>
> > If you're going to use version 3.1.1 as your standard, shouldn't
> > you also point out that 3.1.1 is NOT bundled with Mac OS X?
>
> > How about devoting a section on downloading the source files
> > and compiling it on a Mac?
>
> Why would you do that?

Oh, I don't know, maybe because I'm thinking about
buying one and seeing 2.3, 2.4 and 2.5 directories
on the model in the store made me wary.

>
> http://www.python.org/download/releases/3.1.1/http://www.python.org/ftp/python/3.1.1/python-3.1.1.dmg

This tells me nothing.

>
> or (for MacPorts fans):
>
> $ sudo port install python31


And since I haven't got one, this also tells me nothing.

>
> --
> �Ned Deily,
> �n...@acm.org

geremy condra

unread,
Dec 17, 2009, 2:40:24 AM12/17/09
to Mensanator, pytho...@python.org

He just told you what it meant, as if it weren't already obvious.

Geremy Condra

Ned Deily

unread,
Dec 17, 2009, 5:33:32 AM12/17/09
to pytho...@python.org
In article
<183af5d2-e157-4cd6...@d21g2000yqn.googlegroups.com>,

Mensanator <mensa...@aol.com> wrote:
> Oh, I don't know, maybe because I'm thinking about
> buying one and seeing 2.3, 2.4 and 2.5 directories
> on the model in the store made me wary.

That's odd since, AFAIK, Apple has never released an OS X with Python
2.4.

Current Apple systems ship with OS X 10.6, aka Snow Leopard. 10.6
includes a Python 2.6.1 (64-bit/32-bit) and a Python 2.5.4 (32-bit
only). The previous release, 10.5, shipped with 2.5 and 2.3. But, not
to worry, if you need other versions, you can download OS X installers
from python.org.

> > http://www.python.org/download/releases/3.1.1/http://www.python.org/ftp/pyth
> > on/3.1.1/python-3.1.1.dmg
>
> This tells me nothing.

That's the disk image for the OS X Python 3.1.1 installer. Official
binary installers for OS X are provided on python.org for every final
Python release.

> > or (for MacPorts fans):
> >
> > $ sudo port install python31
>
>
> And since I haven't got one, this also tells me nothing.

http://www.macports.org/

"The MacPorts Project is an open-source community initiative to design
an easy-to-use system for compiling, installing, and upgrading either
command-line, X11 or Aqua based open-source software on the Mac OS X
operating system."

--
Ned Deily,
n...@acm.org

Benjamin Kaplan

unread,
Dec 17, 2009, 11:12:37 AM12/17/09
to pytho...@python.org
On Thu, Dec 17, 2009 at 5:33 AM, Ned Deily <n...@acm.org> wrote:
>
>> > or (for MacPorts fans):
>> >
>> > $ sudo port install python31
>>
>>
>> And since I haven't got one, this also tells me nothing.
>
> http://www.macports.org/
>
> "The MacPorts Project is an open-source community initiative to design
> an easy-to-use system for compiling, installing, and upgrading either
> command-line, X11 or Aqua based open-source software on the Mac OS X
> operating system."

Description sans marketing fluff: It's a Mac package manager. It's
basically the same as Gentoo's portage if you've ever used that. It
downloads source tarballs and patches and then compiles them locally.
There are built-in lists of "variants", basically sets of configure
args, to compile each package.

Mensanator

unread,
Dec 17, 2009, 1:18:04 PM12/17/09
to
On Dec 17, 4:33 am, Ned Deily <n...@acm.org> wrote:
> In article
> <183af5d2-e157-4cd6-bec6-8997809e1...@d21g2000yqn.googlegroups.com>,

>
>  Mensanator <mensana...@aol.com> wrote:
> > Oh, I don't know, maybe because I'm thinking about
> > buying one and seeing 2.3, 2.4 and 2.5 directories
> > on the model in the store made me wary.
>
> That's odd since, AFAIK, Apple has never released an OS X with Python
> 2.4.

Hmm...I was poking around in the finder on a display of new
iMacs at Best Buy last saturday. I searched for "python" and
it took me to a directory listing with three items:
Python 2.3
Python 2.4
Python 2.5

It's possible that Python 2.6 is located somewhere else. I assume
that Snow Leopard was installed, but I didn't actually check that.

>
> Current Apple systems ship with OS X 10.6, aka Snow Leopard.   10.6
> includes a Python 2.6.1 (64-bit/32-bit) and a Python 2.5.4 (32-bit
> only).  The previous release, 10.5, shipped with 2.5 and 2.3.  But, not
> to worry, if you need other versions, you can download OS X installers
> from python.org.
>

> > >http://www.python.org/download/releases/3.1.1/http://www.python.org/f...


> > > on/3.1.1/python-3.1.1.dmg
>
> > This tells me nothing.
>
> That's the disk image for the OS X Python 3.1.1 installer.  

But it doesn't say whether that disk image is compatible with
Snow Leopard and I don't take such things for granted.

> Official
> binary installers for OS X are provided on python.org for every final
> Python release.
>
> > > or (for MacPorts fans):
>
> > > $ sudo port install python31
>
> > And since I haven't got one, this also tells me nothing.
>
> http://www.macports.org/
>
> "The MacPorts Project is an open-source community initiative to design
> an easy-to-use system for compiling, installing, and upgrading either
> command-line, X11 or Aqua based open-source software on the Mac OS X
> operating system."

Ok, now I know. Thanks for the information.

>
> --
>  Ned Deily,
>  n...@acm.org

Mensanator

unread,
Dec 17, 2009, 1:20:56 PM12/17/09
to

That's the kind of thing I want to hear.

Looks like I can go ahead and get a Mac and not worry about getting
3.1.1 installed.

Thanks.

Mensanator

unread,
Dec 17, 2009, 1:35:40 PM12/17/09
to
On Dec 17, 1:40 am, geremy condra <debat...@gmail.com> wrote:

> On Thu, Dec 17, 2009 at 2:25 AM, Mensanator <mensana...@aol.com> wrote:
> > On Dec 16, 8:45 pm, Ned Deily <n...@acm.org> wrote:
> >> In article
> >> <88bab2c0-d27c-4081-a703-26b353b9e...@9g2000yqa.googlegroups.com>,
>
> >> Mensanator <mensana...@aol.com> wrote:
> >> > Oh, and about Chapter 1.
>
> >> > If you're going to use version 3.1.1 as your standard, shouldn't
> >> > you also point out that 3.1.1 is NOT bundled with Mac OS X?
>
> >> > How about devoting a section on downloading the source files
> >> > and compiling it on a Mac?
>
> >> Why would you do that?
>
> > Oh, I don't know, maybe because I'm thinking about
> > buying one and seeing 2.3, 2.4 and 2.5 directories
> > on the model in the store made me wary.
>
> >>http://www.python.org/download/releases/3.1.1/http://www.python.org/f...

>
> > This tells me nothing.
>
> >> or (for MacPorts fans):
>
> >> $ sudo port install python31
>
> > And since I haven't got one, this also tells me nothing.
>
> He just told you what it meant, as if it weren't already obvious.

Why would it be obvious? I use a PC, for which


$ sudo port install python31

is meaningless. Is MacPorts bundled with Snow Leopard?

Or do I have to do this first:

MacPorts version 1.8.1 is available in various formats for download
and installation (note, if you are upgrading your Mac OS X to a new
major release, see the migration info page):

“dmg” disk images for Snow Leopard, Leopard and Tiger as a legacy
platform, containing pkg installers for use with the Mac OS X
Installer. By far the simplest installation procedure that most users
should follow after meeting the requirements listed below.

In source form as either a tar.bz2 package or a tar.gz one for manual
compilation, if you intend to customize your installation in any way.

SVN checkout of the unpackaged sources, if you wish to follow MacPorts
development.

The selfupdate target of the port(1) command, for users who already
have MacPorts installed and wish to upgrade to a newer release.

Checksums for our packaged downloads are contained in the
corresponding checksums file.

Please note that in order to install and run MacPorts on Mac OS X,
your system must have installations of the following components:

Apple's Xcode Developer Tools (version 3.2.1 or later for Snow
Leopard, 3.1.4 or later for Leopard, or 2.5 for Tiger), found at the
Apple Developer Connection site or on your Mac OS X installation CDs/
DVD.

Ensure that the optional components for command line development are
installed ("Unix Development" in the Xcode 3.x installer).

The X11 windowing environment (A.K.A. “X11 User”) for ports that
depend on the functionality it provides to run.

The “X11 User” package is an optional installation on your system CDs/
DVD for Tiger, enabled through the “Customize” button of the
installer, whereas it is included by default on Leopard and Snow
Leopard.

You can use the xorg-server port instead of Apple's X11.app if you
wish.

>
> Geremy Condra

Ned Deily

unread,
Dec 17, 2009, 9:25:54 PM12/17/09
to pytho...@python.org
In article
<b0b60848-9a66-4f84...@a21g2000yqc.googlegroups.com>,

Mensanator <mensa...@aol.com> wrote:
> > That's the disk image for the OS X Python 3.1.1 installer. �
>
> But it doesn't say whether that disk image is compatible with
> Snow Leopard and I don't take such things for granted.

That's a good point. There should be stated there somewhere about which
operating systems are supported. For the record, 3.1.1 has been tested
on 10.4, 10.5, and 10.6 and should work on 10.3.9.

--
Ned Deily,
n...@acm.org

0 new messages