[Tutor] dictionary swittching
dman
dman@dman.ddts.net
Tue, 14 May 2002 07:20:07 -0500
--+g7M9IMkV8truYOl
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Tue, May 14, 2002 at 01:47:00PM +0200, Sharriff Aina wrote:
| ..Thanks Raymond! that did the trick,
Yeah, if you say "else" it means "else". In more detail :
if <cond1> :
<branch1>
elif <cond2> :
<branch2> :
else :
<branch3>
This is the complete structure of an "if" statement. The elif and
else sections are optional, the elif section can be repeated as
desired. "elif" is short for "else-if". Here's how it evaluates :
1) is <cond1> true?
if yes then goto 2
if no then goto 3
2) execute code in <branch1>
goto 6
3) is <cond2> true (AND <cond1> is false)?
if yes then goto 4
if no then goto 5
4) execute code in <branch2>
goto 6
5) (<cond1> and <cond2> were false)
execute <branch3>
6) done (don't do anything more)
This is basically how non-structured code is written (BASIC, M68K
assembly). I'm sure you appreciate structure after trying to follow
it :-).
Hmm, maybe the on-line doc will do a better job of explaining the
specific semantics of an "if" statement and the meaning of 'elif' and
'else'.
| would it be advisable to upgrade to python 2.2?
Yes. That has nothing to do with the problem you had, though.
HTH,
-D
--=20
Better a little with righteousness
than much gain with injustice.
Proverbs 16:8
=20
GnuPG key : http://dman.ddts.net/~dman/public_key.gpg
--+g7M9IMkV8truYOl
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAjzhAPcACgkQO8l8XBKTpRRArACgleKrtvGHlEjK+ICNIex4XpoD
RXYAnjUZCfB8/9x0cykFtHViat6uoM+Z
=z1Yp
-----END PGP SIGNATURE-----
--+g7M9IMkV8truYOl--