[sf-lug] [PYCLASS] Still on exercise 2.1

Christian Einfeldt einfeldt at gmail.com
Sun Oct 5 21:44:56 PDT 2008


On Sat, Oct 4, 2008 at 1:02 AM, Jeffrey Malone <ieatlint at tehinterweb.com>wrote:

> /* Set some constants */

This was wonderfully enlighting to see this problem solved this way.  It is
elegant, because once the constants have been set, it is possible to throw
many scenarios at those constants.  Never in a million years would I have
thought of this myself.  This is excellent instruction, thanks.

It would seem that it would probably be a good idea to create constants in
almost every problem, is that correct?

Also, it is surprising to me that one would need to define minutes.  You
would think that the Python programmers would anticipate that people are
going to need those values and compute with them frequently.

Also, it would seem that there would need to be a library or a config file
that one could edit to permanently reflect set values for MIN and HOUR.  Are
there such files?  Or, to put it another way, where are the values for MIN
and HOUR stored? In /tmp?  I am assuming those values go away when you exit
python, is that correct?

> MIN = 60
> HOUR = MIN*60
> easy_pace = 8*MIN+15
> tempo_pace = 7*MIN+12
> start_time = 6*HOUR+52*MIN

Coincidentally, in the law, we have to assign values to works as well in the
course of written discovery, and there are constantly fights over those
kinds of things in cases where discovery is hotly disputed, which is almost
every large civil case.

> secs = easy_pace * 1 + tempo_pace * 3 + easy_pace * 1
> print "%d:%02d" % ( (secs/ MIN), (secs%MIN) )

Since I am still on chapter 2 of the book, we have not covered this kind of
syntax, which is taken from the print statement above:

%d:%02d" % ( (secs/ MIN), (secs%MIN) )

What does the colon denote above there, please?  And is there a name for
this structure:


And what does the % mean, please?  I am guessing we are going to cover that
in Chapter 3, so if that is the case, my apologies.  I wanted to get my
questions out there while I had them in mind.

Also, I note that there is a comma between these two structures, and I am
wondering if there is a name for that construction, or why you did it:

% ( (secs/ MIN), (secs%MIN) )

Thanks for this info.  I ran all of these statements and they performed
beautifully.  Experiencing this was highly inspiring and motivating for me.

c u
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://linuxmafia.com/pipermail/sf-lug/attachments/20081005/51831f6c/attachment.html>

More information about the sf-lug mailing list