Hello,
$ python
Python 2.7.4 (default, Sep 26 2013, 03:20:26)
[GCC 4.7.3] on linux2
Type help, copyright, credits or license for more information.
1 0 == True
False
(1 0) == True
True
1 (0 == True)
True
What am I missing here ?
T.
--
https://mail.python.org/mailman/listinfo/python-list
Thibault Langlois schrieb:
1 0 == True
False
What am I missing here ?
This, perhaps:
http://www.primozic.net/nl/chaining-comparison-operators-in-python/
Greetings,
Thomas
--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
--
https://mail.python.org/mailman
Thibault Langlois writes:
Hello,
$ python
Python 2.7.4 (default, Sep 26 2013, 03:20:26)
[GCC 4.7.3] on linux2
Type help, copyright, credits or license for more information.
1 0 == True
False
(1 0) == True
True
1 (0 == True)
True
What am I missing here ?
One or both
Jussi Piitulainen wrote:
Thibault Langlois writes:
Hello,
$ python
Python 2.7.4 (default, Sep 26 2013, 03:20:26)
[GCC 4.7.3] on linux2
Type help, copyright, credits or license for more information.
1 0 == True
False
(1 0) == True
True
1 (0 == True)
True
What am I
Peter Otten writes:
Jussi Piitulainen wrote:
Thibault Langlois writes:
Hello,
$ python
Python 2.7.4 (default, Sep 26 2013, 03:20:26)
[GCC 4.7.3] on linux2
Type help, copyright, credits or license for more information.
1 0 == True
False
(1 0) == True
True
1 (0
Thibault Langlois thibault.langl...@gmail.com Wrote in message:
Hello,
$ python
Python 2.7.4 (default, Sep 26 2013, 03:20:26)
[GCC 4.7.3] on linux2
Type help, copyright, credits or license for more information.
1 0 == True
False
(1 0) == True
True
1 (0 == True)
True
What am I
information.
1 0 == True
False
(1 0) == True
True
1 (0 == True)
True
What am I missing here ?
T.
You tell us. You supply only half the question, what it does,
without saying what you expected or needed.
I expect you're either confused
On Fri, Jan 31, 2014 at 12:40 AM, Thibault Langlois
thibault.langl...@gmail.com wrote:
The recommendations to student are 1) do not assume True == 1 and do not use
operator chaining.
Not do not use, but do not misuse. Python's operator chaining is
awesome for bounds checking:
if 3 x 20:
In article 3dcdc95d-5e30-46d3-b558-afedf9723...@googlegroups.com,
Thibault Langlois thibault.langl...@gmail.com wrote:
You are right. I should have given some context.
I am looking at this from the perspective of the teacher that has to explain
idiosyncrasies of the language to inexperienced
On Fri, Jan 31, 2014 at 1:08 AM, Roy Smith r...@panix.com wrote:
Better than that, do what I do.
1) Assume that you don't have the full operator precedence table
memorized and just parenthesize everything.
Or:
1a) Assume that you don't have the full operator precedence table
memorized and
On Thu, Jan 30, 2014 at 6:08 AM, Roy Smith r...@panix.com wrote:
1) Assume that you don't have the full operator precedence table
memorized and just parenthesize everything.
2) In cases where the expression is so simple, you couldn't possibly be
wrong, see rule #1.
Also, assume you don't
On Thursday, January 30, 2014 2:08:58 PM UTC, Roy Smith wrote:
In article 3dcdc95d-5e30-46d3-b558-afedf9723...@googlegroups.com,
Thibault Langlois thibault.langl...@gmail.com wrote:
You are right. I should have given some context.
I am looking at this from the perspective of the
In article mailman.6143.1391091519.18130.python-l...@python.org,
Chris Angelico ros...@gmail.com wrote:
On Fri, Jan 31, 2014 at 1:08 AM, Roy Smith r...@panix.com wrote:
Better than that, do what I do.
1) Assume that you don't have the full operator precedence table
memorized and just
Roy Smith writes:
In article 3dcdc95d-5e30-46d3-b558-afedf9723...@googlegroups.com,
Thibault Langlois wrote:
You are right. I should have given some context. I am looking at
this from the perspective of the teacher that has to explain
idiosyncrasies of the language to inexperienced
On Fri, Jan 31, 2014 at 1:49 AM, Roy Smith r...@panix.com wrote:
In article mailman.6143.1391091519.18130.python-l...@python.org,
Chris Angelico ros...@gmail.com wrote:
On Fri, Jan 31, 2014 at 1:08 AM, Roy Smith r...@panix.com wrote:
Better than that, do what I do.
1) Assume that you
On Thu, 30 Jan 2014 09:08:58 -0500, Roy Smith wrote:
1) Assume that you don't have the full operator precedence table
memorized and just parenthesize everything.
Oh really? Do you actually write stuff like this?
b = ((2*a) + 1)
if (b = (-1)):
...
I would hope not.
2) In cases where
On Thursday, January 30, 2014 8:39:03 PM UTC+5:30, Steven D'Aprano wrote:
On Thu, 30 Jan 2014 09:08:58 -0500, Roy Smith wrote:
1) Assume that you don't have the full operator precedence table
memorized and just parenthesize everything.
Oh really? Do you actually write stuff like this?
b
On 30/01/2014 14:46, Thibault Langlois wrote:
On Thursday, January 30, 2014 2:08:58 PM UTC, Roy Smith wrote:
In article 3dcdc95d-5e30-46d3-b558-afedf9723...@googlegroups.com,
Thibault Langlois thibault.langl...@gmail.com wrote:
You are right. I should have given some context.
I am
On Thursday, January 30, 2014 9:56:19 AM UTC-5, Jussi Piitulainen wrote:
There's nothing to parenthesize in x = y z = w
Hmm
x = y z = w
File stdin, line 1
SyntaxError: can't assign to comparison
I don't think any number of parentheses will help that :-)
--
On Thursday, January 30, 2014 10:09:03 AM UTC-5, Steven D'Aprano wrote:
On Thu, 30 Jan 2014 09:08:58 -0500, Roy Smith wrote:
1) Assume that you don't have the full operator precedence table
memorized and just parenthesize everything.
Oh really? Do you actually write stuff like this?
b
On Thursday, January 30, 2014 10:09:03 AM UTC-5, Steven D'Aprano wrote:
E.g. `x+1 0 and y = 5` is potentially as many as 9 distinct
items to keep in short-term memory. But bracketing some terms
as in `(x+1 0) and (y = 5)` can reduce that down to as few
as two items.
Yes,
On Fri, Jan 31, 2014 at 5:56 AM, Roy Smith r...@panix.com wrote:
On Thursday, January 30, 2014 10:09:03 AM UTC-5, Steven D'Aprano wrote:
E.g. `x+1 0 and y = 5` is potentially as many as 9 distinct
items to keep in short-term memory. But bracketing some terms
as in `(x+1 0) and
On 30/01/2014 12:49, Dave Angel wrote:
[...]
For hysterical reasons, True and False are instances of class
bool, which is derived from int. So for comparison purposes
False==0 and True==1. But in my opinion, you should never take
advantage of this, except when entering obfuscation
On 01/30/2014 11:03 AM, Chris Angelico wrote:
On Fri, Jan 31, 2014 at 5:56 AM, Roy Smith wrote:
Yes, that's probably how I would write that, although, this is even simpler:
(x -1) and (y = 5)
Be careful; that's not the same thing.
How so?
--
~Ethan~
--
Fri, Jan 31, 2014 at 6:22 AM, Ethan Furman et...@stoneleaf.us wrote:
On 01/30/2014 11:03 AM, Chris Angelico wrote:
On Fri, Jan 31, 2014 at 5:56 AM, Roy Smith wrote:
Yes, that's probably how I would write that, although, this is even
simpler:
(x -1) and (y = 5)
Be careful; that's not
Rotwang sg...@hotmail.co.uk Wrote in message:
On 30/01/2014 12:49, Dave Angel wrote:
[...]
For hysterical reasons, True and False are instances of class
bool, which is derived from int. So for comparison purposes
False==0 and True==1. But in my opinion, you should never take
On Fri, Jan 31, 2014 at 7:08 AM, Dave Angel da...@davea.name wrote:
'You have scored %i point%s' % (score, 's'*(score != 1))
Here I'd probably do something like
'You have scored {} {}' .format (score, 'point' if score==1 else
'points')
Bah, what's the fun in that?
'You have scored %i
Roy Smith writes:
On Thursday, January 30, 2014 9:56:19 AM UTC-5, Jussi Piitulainen wrote:
There's nothing to parenthesize in x = y z = w
Hmm
x = y z = w
File stdin, line 1
SyntaxError: can't assign to comparison
I don't think any number of parentheses will help that :-)
On Fri, Jan 31, 2014 at 7:14 AM, Jussi Piitulainen
jpiit...@ling.helsinki.fi wrote:
I don't think any number of parentheses will help that :-)
Er, sorry about that. Here:
x = y z == w
Traceback (most recent call last):
File stdin, line 1, in module
NameError: name 'x' is not defined
On Thu, Jan 30, 2014 at 1:08 PM, Dave Angel da...@davea.name wrote:
Rotwang sg...@hotmail.co.uk Wrote in message:
Really? I take advantage of it quite a lot. For example, I do things
like this:
'You have scored %i point%s' % (score, 's'*(score != 1))
I also did that kind of thing when
On Fri, Jan 31, 2014 at 7:28 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
Of course if you're at all concerned about i18n then the proper way to
do it would be:
ngettext(You have scored %d point, You have scored %d points, score) %
score
Ugh, so much duplication! We can totally do better than
On Jan 30, 2014 1:40 PM, Chris Angelico ros...@gmail.com wrote:
On Fri, Jan 31, 2014 at 7:28 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
Of course if you're at all concerned about i18n then the proper way to
do it would be:
ngettext(You have scored %d point, You have scored %d points,
On Fri, Jan 31, 2014 at 8:17 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
Why is tuple unpacking limited to the last argument? Is it just for
the parallel with the function definition, where anything following it
is keyword-only?
Lack of a convincing use case, and the position of the following
On Thursday, January 30, 2014 10:09:03 AM UTC-5, Steven D'Aprano wrote:
`(x+1 0) and (y = 5)`
Me:
this is even simpler:
(x -1) and (y = 5)
On Thursday, January 30, 2014 2:03:42 PM UTC-5, Chris Angelico wrote:
Be careful; that's not the same thing.
In what way? I'm assuming x is some
On Fri, Jan 31, 2014 at 9:09 AM, Roy Smith r...@panix.com wrote:
On Thursday, January 30, 2014 10:09:03 AM UTC-5, Steven D'Aprano wrote:
`(x+1 0) and (y = 5)`
Me:
this is even simpler:
(x -1) and (y = 5)
On Thursday, January 30, 2014 2:03:42 PM UTC-5, Chris Angelico wrote:
Be careful;
On 30 January 2014 20:38, Chris Angelico ros...@gmail.com wrote:
Why is tuple unpacking limited to the last argument? Is it just for
the parallel with the function definition, where anything following it
is keyword-only?
You're not the first person to ask that:
On Fri, Jan 31, 2014 at 10:36 AM, Joshua Landau jos...@landau.ws wrote:
On 30 January 2014 20:38, Chris Angelico ros...@gmail.com wrote:
Why is tuple unpacking limited to the last argument? Is it just for
the parallel with the function definition, where anything following it
is keyword-only?
On 30/01/2014 23:36, Joshua Landau wrote:
On 30 January 2014 20:38, Chris Angelico ros...@gmail.com wrote:
Why is tuple unpacking limited to the last argument? Is it just for
the parallel with the function definition, where anything following it
is keyword-only?
You're not the first person
Rotwang sg...@hotmail.co.uk writes:
On a vaguely-related note, does anyone know why iterable unpacking in
calls was removed in Python 3?
This is explained in the PEP which described its removal
URL:http://www.python.org/dev/peps/pep-3113/, especially
On 31 January 2014 00:10, Rotwang sg...@hotmail.co.uk wrote:
On a vaguely-related note, does anyone know why iterable unpacking in calls
was removed in Python 3? I mean things like
def f(x, (y, z)):
return (x, y), z
I don't have a use case in mind, I was just wondering.
On Friday, January 31, 2014 12:23:42 AM UTC+5:30, Roy Smith wrote:
On Thursday, January 30, 2014 10:09:03 AM UTC-5, Steven D'Aprano wrote:
On Thu, 30 Jan 2014 09:08:58 -0500, Roy Smith wrote:
1) Assume that you don't have the full operator precedence table
memorized and just parenthesize
41 matches
Mail list logo