Skip to content

Fixes #137: test_everything_else_is_treated_as_true - #142

Merged
mpirnat merged 1 commit into
gregmalcolm:masterfrom
kjc:fixes_137_tuple_literal
Sep 30, 2016
Merged

Fixes #137: test_everything_else_is_treated_as_true#142
mpirnat merged 1 commit into
gregmalcolm:masterfrom
kjc:fixes_137_tuple_literal

Conversation

@kjc

@kjc kjc commented Sep 29, 2016

Copy link
Copy Markdown
Collaborator

Fixes #137

In the Python 2 and 3 versions of koans/about_true_and_false.py:

self.truth_value(1,) is an integer argument followed by an optional
comma. It just happened to produce the desired answer, because bool(1)
is True.

self.truth_value((1,)) is a tuple argument. Changed the tuple to (0,)
to demonstrate that its truthiness comes from the presence of any
elements, and not from the truth value of the element itself.

Also, added an easier example before it --- self.truth_value([0]) ---
to introduce the same idea with the simpler list-literal syntax (no
"magic" comma to worry about).

Finally, changed the whitespace and line wrapping so the Python 2 and 3
files are identical.

Reported by: egonluo
https://github.com/egonluo

Issue #137:
#137

In the Python 2 and 3 versions of koans/about_true_and_false.py:

self.truth_value(1,) is an integer argument followed by an optional
comma.  It just happened to produce the desired answer, because bool(1)
is True.

self.truth_value((1,)) is a tuple argument.  Changed the tuple to (0,)
to demonstrate that its truthiness comes from the presence of _any_
elements, and not from the truth value of the element itself.

Also, added an easier example before it --- self.truth_value([0]) ---
to introduce the same idea with the simpler list-literal syntax (no
"magic" comma to worry about).

Finally, changed the whitespace and line wrapping so the Python 2 and 3
files are identical.

Reported by: egonluo
https://github.com/egonluo

Issue gregmalcolm#137:
gregmalcolm#137
@mpirnat

mpirnat commented Sep 29, 2016

Copy link
Copy Markdown
Collaborator

@kjc: Kevin, thanks for all the PRs this week! I hope to check them out in the next day or so and get them landed.

@mpirnat
mpirnat merged commit d44aec5 into gregmalcolm:master Sep 30, 2016
@kjc
kjc deleted the fixes_137_tuple_literal branch September 30, 2016 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants