More stuff added to ch 2 of my programming intro

  • Thread starter Alf P. Steinbach
  • Start date
A

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!
 
A

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.


Cheers,

- Alf

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

Alf P. Steinbach

* Alf P. Steinbach:
* 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.

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
 
M

Mensanator

* 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?

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

Mensanator

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

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?
 
A

Alf P. Steinbach

* Mensanator:
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?

Learn to read.

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



Cheers & hth.,

- Alf
 
M

Mensanator

* Mensanator:









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.
 
A

Alf P. Steinbach

* Mensanator:
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..



Cheers,

- Alf
 
G

geremy condra

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.


This tells me nothing.



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.

Geremy Condra
 
N

Ned Deily

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.
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.
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."
 
B

Benjamin Kaplan

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.
 
M

Mensanator

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.



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.



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.
 
M

Mensanator

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.

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.
 
M

Mensanator

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.
 
N

Ned Deily

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top