On 18Mar2019 08:10, Eric Fahlgren wrote:
On Mon, Mar 18, 2019 at 7:04 AM Rhodri James wrote:
On 18/03/2019 12:19, Richard Damon wrote:
> On 3/18/19 7:27 AM, Greg Ewing wrote:
>> Juancarlo Añez wrote:
>>
>>> if settings[MY_KEY] is True:
>>> ...
>>
>> If I saw code like this, it woul
18.03.19 22:52, Wes Turner пише:
>>> True = 1
File "", line 1
SyntaxError: can't assign to keyword
The error message will be changed in 3.8.
>>> True = 1
File "", line 1
SyntaxError: cannot assign to True
___
Python-ideas mailing list
Python-i
18.03.19 22:58, Greg Ewing пише:
Oleg Broytman wrote:
Three-way (tri state) checkbox. You have to distinguish False and
None if the possible valuse are None, False and True.
In that case the conventional way to write it would be
if settings[MY_KEY] == True:
...
It's not a ma
On Tue, Mar 19, 2019 at 11:32:56AM +1300, Greg Ewing wrote:
> Tim Delaney wrote:
> >I would argue the opposite - the use of "is" shows a clear knowledge
> >that True and False are each a singleton and the author explicitly
> >intended to use them that way.
>
> I don't think you can infer that. I
On Mon, Mar 18, 2019 at 3:42 PM Greg Ewing
wrote:
> Tim Delaney wrote:
> > I would argue the opposite - the use of "is" shows a clear knowledge
> > that True and False are each a singleton and the author explicitly
> > intended to use them that way.
>
> I don't think you can infer that. It could
On Mon, Mar 18, 2019 at 10:32:38PM +1100, Chris Angelico wrote:
> "Singleton" technically means that there is only one such object.
True, but it is common to abuse the term to mean only a fixed, small
number of such objects, since "duoton" (for two) and "tripleton" (for
three) have never caught
Tim Delaney wrote:
I would argue the opposite - the use of "is" shows a clear knowledge
that True and False are each a singleton and the author explicitly
intended to use them that way.
I don't think you can infer that. It could equally well be someone who's
*not* familiar with Python truth ru
On Tue, Mar 19, 2019 at 09:58:55AM +1300, Greg Ewing wrote:
> Oleg Broytman wrote:
> > Three-way (tri state) checkbox. You have to distinguish False and
> >None if the possible valuse are None, False and True.
>
> In that case the conventional way to write it would be
>
> if settings[MY_KEY
On Tue, 19 Mar 2019 at 08:42, Greg Ewing
wrote:
> Oleg Broytman wrote:
> >Three-way (tri state) checkbox. You have to distinguish False and
> > None if the possible valuse are None, False and True.
>
> In that case the conventional way to write it would be
>
> if settings[MY_KEY] == True
There are few cases where I would approve of 'if x is True'. However, the
names used in the example suggest it could be one of those rare cases.
Settings of True/False/None (i.e. not set) seem like a reasonable pattern.
In fact, in code like that, merely "truthy" values are probably a bug that
shou
It was a VERY long time ago when True and False were not singletons. I
don't think we should still try to write code based on rules that stopped
applying more than a decade ago.
On Mon, Mar 18, 2019, 5:42 PM Greg Ewing
wrote:
> Oleg Broytman wrote:
> >Three-way (tri state) checkbox. You have
Richard Damon wrote:
On 3/18/19 7:27 AM, Greg Ewing wrote:
if settings[MY_KEY]:
...
>
That means something VERY different.
Yes, but there needs to be justification for why the difference
matters and why this particular way is the best way to deal
with it.
Whenever you write 'x is
Oleg Broytman wrote:
Three-way (tri state) checkbox. You have to distinguish False and
None if the possible valuse are None, False and True.
In that case the conventional way to write it would be
if settings[MY_KEY] == True:
...
It's not a major issue, but I get nervous when I
On Tue, Mar 19, 2019 at 7:53 AM Wes Turner wrote:
>
> 'True' is a keyword. (Which is now immutable in Python 3.X?)
>
> >>> True = 1
> File "", line 1
> SyntaxError: can't assign to keyword
In Python 3, the source code token "True" is a keyword literal that
always represents the bool value True.
'True' is a keyword. (Which is now immutable in Python 3.X?)
>>> True = 1
File "", line 1
SyntaxError: can't assign to keyword
https://docs.python.org/3/reference/datamodel.html#the-standard-type-hierarchy
https://docs.python.org/3/search.html?q=singleton
- "Since None is a singleton, testing
On 18/03/2019 15:10, Eric Fahlgren wrote:
On Mon, Mar 18, 2019 at 7:04 AM Rhodri James wrote:
On 18/03/2019 12:19, Richard Damon wrote:
On 3/18/19 7:27 AM, Greg Ewing wrote:
Juancarlo Añez wrote:
if settings[MY_KEY] is True:
...
If I saw code like this, it would take a real
On Mon, Mar 18, 2019 at 7:04 AM Rhodri James wrote:
> On 18/03/2019 12:19, Richard Damon wrote:
> > On 3/18/19 7:27 AM, Greg Ewing wrote:
> >> Juancarlo Añez wrote:
> >>
> >>> if settings[MY_KEY] is True:
> >>> ...
> >>
> >> If I saw code like this, it would take a really good argumen
On 18/03/2019 12:19, Richard Damon wrote:
On 3/18/19 7:27 AM, Greg Ewing wrote:
Juancarlo Añez wrote:
if settings[MY_KEY] is True:
...
If I saw code like this, it would take a really good argument to
convince me that it shouldn't be just
if settings[MY_KEY]:
...
On Tue, Mar 19, 2019 at 12:27:04AM +1300, Greg Ewing
wrote:
> Juancarlo A?ez wrote:
>
> >if settings[MY_KEY] is True:
> >...
>
> If I saw code like this, it would take a really good argument to
> convince me that it shouldn't be just
>
> if settings[MY_KEY]:
> ...
T
On 3/18/19 7:27 AM, Greg Ewing wrote:
> Juancarlo Añez wrote:
>
>> if settings[MY_KEY] is True:
>> ...
>
> If I saw code like this, it would take a really good argument to
> convince me that it shouldn't be just
>
> if settings[MY_KEY]:
> ...
>
That means something VERY differ
On 3/18/19 7:32 AM, Chris Angelico wrote:
> On Mon, Mar 18, 2019 at 10:14 PM Juancarlo Añez wrote:
>> It came to my attention that:
>>
>> In the original PEP True and False are said to be singletons
>> https://www.python.org/dev/peps/pep-0285/, but it's not in the Data Model
>> https://docs.pyth
Juancarlo Añez wrote:
if settings[MY_KEY] is True:
...
If I saw code like this, it would take a really good argument to
convince me that it shouldn't be just
if settings[MY_KEY]:
...
--
Greg
___
Python-ideas mailing list
Pytho
On Mon, Mar 18, 2019 at 10:14 PM Juancarlo Añez wrote:
>
> It came to my attention that:
>
> In the original PEP True and False are said to be singletons
> https://www.python.org/dev/peps/pep-0285/, but it's not in the Data Model
> https://docs.python.org/3/reference/datamodel.html
>
>
> This ca
Le 18 mars 2019 à 12:15:05, Juancarlo Añez
(apal...@gmail.com(mailto:apal...@gmail.com)) a écrit:
> It came to my attention that:
>
> > In the original PEP True and False are said to be singletons
> > https://www.python.org/dev/peps/pep-0285/, but it's not in the Data Model
> > https://docs.pyth
It came to my attention that:
In the original PEP True and False are said to be singletons
https://www.python.org/dev/peps/pep-0285/, but it's not in the Data Model
https://docs.python.org/3/reference/datamodel.html
This came to my attention by code wanting to own the valid values in a
dict's ke
25 matches
Mail list logo