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 paren
On 31 January 2014 00:10, Rotwang 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.
http://www.python.org/dev/
Rotwang 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
http://www.python.org/dev/peps/pep-3113/>, especially
http://www.python.org/dev/peps/pep-3113/#why-they-should-go>.
-
On 30/01/2014 23:36, Joshua Landau wrote:
On 30 January 2014 20:38, Chris Angelico 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:
http:
On Fri, Jan 31, 2014 at 10:36 AM, Joshua Landau wrote:
> On 30 January 2014 20:38, Chris Angelico 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
On 30 January 2014 20:38, Chris Angelico 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:
http://www.python.org/dev/peps/pep-0448/
If
On Fri, Jan 31, 2014 at 9:09 AM, Roy Smith 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 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 so
On Fri, Jan 31, 2014 at 8:17 AM, Ian Kelly 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 arguments
> wo
On Jan 30, 2014 1:40 PM, "Chris Angelico" wrote:
>
> On Fri, Jan 31, 2014 at 7:28 AM, Ian Kelly 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, s
On Fri, Jan 31, 2014 at 7:28 AM, Ian Kelly 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 that.
ngett
On Thu, Jan 30, 2014 at 1:08 PM, Dave Angel wrote:
> Rotwang 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 computer resources
> were
On Fri, Jan 31, 2014 at 7:14 AM, Jussi Piitulainen
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 "", line 1, in
> NameError: name 'x' is not defined
>
> Much better :)
See,
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 "", line 1
> SyntaxError: can't assign to comparison
>
> I don't think any number of parentheses will
On Fri, Jan 31, 2014 at 7:08 AM, Dave Angel 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 point%.*s'
Rotwang 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
>> advantage of
Fri, Jan 31, 2014 at 6:22 AM, Ethan Furman 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;
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~
--
https://mail.python.org/mailman/l
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
cont
On Fri, Jan 31, 2014 at 5:56 AM, Roy Smith 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 (y >=
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.
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 thi
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 "", line 1
SyntaxError: can't assign to comparison
I don't think any number of parentheses will help that :-)
--
https://mail.python.or
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 wrote:
You are right. I should have given some context.
I am looking at this from the pers
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?
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 wher
On Fri, Jan 31, 2014 at 1:49 AM, Roy Smith wrote:
> In article ,
> Chris Angelico wrote:
>
>> On Fri, Jan 31, 2014 at 1:08 AM, Roy Smith wrote:
>> > Better than that, do what I do.
>> >
>> > 1) Assume that you don't have the full operator precedence table
>> > memorized and just parenthesize ev
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 inexpe
In article ,
Chris Angelico wrote:
> On Fri, Jan 31, 2014 at 1:08 AM, Roy Smith 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 fu
On Thursday, January 30, 2014 2:08:58 PM UTC, Roy Smith wrote:
> 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
On Thu, Jan 30, 2014 at 6:08 AM, Roy Smith 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 have the func
On Fri, Jan 31, 2014 at 1:08 AM, Roy Smith 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 just look it
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 students.
> There are
On Fri, Jan 31, 2014 at 12:40 AM, Thibault Langlois
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:
print("x is between 3
Type "help", "copyright", "credits" or "license" for more information.
>
> >>>> 1 > 0 == True
>
> > False
>
> >>>> (1 > 0) == True
>
> > True
>
> >>>> 1 > (0 == True)
>
> &g
Thibault Langlois 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 >
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"
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"
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
> Fal
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
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
41 matches
Mail list logo