Ethan Furman added the comment:

Apologies, my wording was poor -- the last item evaluated is the one returned, 
but all items may not be evaluated.  As soon as the answer is known Python 
stops evaluating any remaining items.

So in the example:

  --> string1, string2, string3 = '', 'Trondheim', 'Hammer Dance'
  --> string1 or string2 or string3
  'Trondheim'

string2 is returned because it satifies the `or` conditions, and string3 is not 
evaluated.


Re: John

I appreciate you have many years of programming experience, but there are going 
to be differences between what is good practice in those languages and what is 
good practice in Python.  IMO, the big three differences are:

  - white space indentation
  - everything is an object (variables, functions, classes, instances,
    any piece of data...)
  - everything has a truthy of falsey value -- e.g.

    --> string1, string2, string3 = '', 'Trondheim', 'Hammer Dance'
    --> if string2:
    ...    print('string2 has a value!  It is %s' % string2)
    ...
    'string2 has a value!  It is Trondheim'

    notice there is no `if bool(string2)` or `if string2 == False` (which would 
be False).

As far as finding that bit of the tutorial confusing, there is no way to have a 
single document that is crystal clear to everyone who reads it.  This section 
is correct, as is section 4.1 -- `or` is being used, so the operand is 
returned, not True or False.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23153>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to