Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76865 > unrolled thread
| Started by | explodeandroid@gmail.com |
|---|---|
| First post | 2014-08-23 06:10 -0700 |
| Last post | 2014-08-24 16:22 +1000 |
| Articles | 6 — 5 participants |
Back to article view | Back to comp.lang.python
Simple question explodeandroid@gmail.com - 2014-08-23 06:10 -0700
Re: Simple question Chris Angelico <rosuav@gmail.com> - 2014-08-23 23:19 +1000
Re: Simple question Peter Otten <__peter__@web.de> - 2014-08-23 15:26 +0200
Re: Simple question "ElChino" <elchino@cnn.cn> - 2014-08-23 15:31 +0200
Re: Simple question John Ladasky <john_ladasky@sbcglobal.net> - 2014-08-23 22:55 -0700
Re: Simple question Chris Angelico <rosuav@gmail.com> - 2014-08-24 16:22 +1000
| From | explodeandroid@gmail.com |
|---|---|
| Date | 2014-08-23 06:10 -0700 |
| Subject | Simple question |
| Message-ID | <ca0167cc-49d3-4e58-9fc0-e80550ee2bcf@googlegroups.com> |
Can some one explain why this happens: True, False = False, True print True, False False True
[toc] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-08-23 23:19 +1000 |
| Message-ID | <mailman.13340.1408800005.18130.python-list@python.org> |
| In reply to | #76865 |
On Sat, Aug 23, 2014 at 11:10 PM, <explodeandroid@gmail.com> wrote: > Can some one explain why this happens: > True, False = False, True > print True, False > False True Well, the first line changes the meanings of the names "True" and "False", but doesn't change the things they point to. Those things describe themselves the same way. Here's another thing you can do that will look the same: a, b = False, True print a, b False True Fortunately, newer versions of Python don't let you reassign True and False. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2014-08-23 15:26 +0200 |
| Message-ID | <mailman.13341.1408800422.18130.python-list@python.org> |
| In reply to | #76865 |
explodeandroid@gmail.com wrote: > Can some one explain why this happens: > True, False = False, True > print True, False > False True You are using Python 2 where True/False are names that can be rebound. This is for backwards compatibility as Python didn't always have booleans and people made their own with True = 1 False = 0 or similar. In Python 3 True and False are keywords: >>> True = False File "<stdin>", line 1 SyntaxError: can't assign to keyword
[toc] | [prev] | [next] | [standalone]
| From | "ElChino" <elchino@cnn.cn> |
|---|---|
| Date | 2014-08-23 15:31 +0200 |
| Message-ID | <lta53d$5hl$1@dont-email.me> |
| In reply to | #76865 |
<explodeandroid@gmail.com> wrote: > Can some one explain why this happens: > True, False = False, True > print True, False > False True I assume the value of True and False can be falsified. Like the 'None' object can be. So swapping their values and printing them is similar to: a = 0 b = 1 a, b = b, a print a, b Except that True/False are initialised built-ins.
[toc] | [prev] | [next] | [standalone]
| From | John Ladasky <john_ladasky@sbcglobal.net> |
|---|---|
| Date | 2014-08-23 22:55 -0700 |
| Message-ID | <d88ee391-69b0-4ada-a9de-376c9f315aa9@googlegroups.com> |
| In reply to | #76865 |
On Saturday, August 23, 2014 6:10:29 AM UTC-7, explode...@gmail.com wrote: > Can some one explain why this happens: > > True, False = False, True > > print True, False > > False True Shush! That's one of Python's most closely-guarded secrets! Every politician on Earth will want to learn to program in Python after seeing that!
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-08-24 16:22 +1000 |
| Message-ID | <mailman.13373.1408861326.18130.python-list@python.org> |
| In reply to | #76922 |
On Sun, Aug 24, 2014 at 3:55 PM, John Ladasky
<john_ladasky@sbcglobal.net> wrote:
> Shush! That's one of Python's most closely-guarded secrets! Every politician on Earth will want to learn to program in Python after seeing that!
>
Not really, the legal profession has known about this for centuries.
(Princess Zara, presenting Sir Bailey Barre, Q.C., M.P.)
A complicated gentleman allow to present,
Of all the arts and faculties the terse embodiment,
He's a great arithmetician who can demonstrate with ease
That two and two are three or five or anything you please;
An eminent Logician who can make it clear to you
That black is white--when looked at from the proper point of view;
A marvelous Philologist who'll undertake to show
That "yes" is but another and a neater form of "no.
>From Gilbert & Sullivan's "Utopia, Ltd", dating back to 1893. Python 2
continues this excellent tradition of permitting truth to be redefined
at will, but Python 3 adopts the view of the narrow-minded pedant who
still believes that two and two makes four. It's an opinionated
language, and that helps you to avoid weirdnesses :)
ChrisA
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web