On 29/07/2019 12.56, Rob Gaddi wrote:
> On 7/29/19 10:44 AM, Michael F. Stemper wrote:
>> On 28/07/2019 19.04, Chris Angelico wrote:
>>> On Mon, Jul 29, 2019 at 9:48 AM Michael Torrie
>>> wrote:
Yet the recommended solution to the problem of wanting a default
argument of an empty list i
On 7/29/19 10:44 AM, Michael F. Stemper wrote:
On 28/07/2019 19.04, Chris Angelico wrote:
On Mon, Jul 29, 2019 at 9:48 AM Michael Torrie wrote:
On 7/28/19 5:55 AM, Jonathan Moules wrote:
But this appears to be explicitly called out as being "Worse" in PEP8:
"""
Don't compare boolean values
On Tue, Jul 30, 2019 at 3:46 AM Michael F. Stemper
wrote:
>
> On 28/07/2019 19.04, Chris Angelico wrote:
> > On Mon, Jul 29, 2019 at 9:48 AM Michael Torrie wrote:
> >>
> >> On 7/28/19 5:55 AM, Jonathan Moules wrote:
> >>> But this appears to be explicitly called out as being "Worse" in PEP8:
> >>
On 28/07/2019 19.04, Chris Angelico wrote:
> On Mon, Jul 29, 2019 at 9:48 AM Michael Torrie wrote:
>>
>> On 7/28/19 5:55 AM, Jonathan Moules wrote:
>>> But this appears to be explicitly called out as being "Worse" in PEP8:
>>>
>>> """
>>> Don't compare boolean values to True or False using ==.
>>>
On Tue, Jul 30, 2019 at 12:04 AM David Raymond wrote:
> if shell:
> #wait, "shell" is not really a statement or an instruction. "If shell"...
> what? "I need to shell"? Is this whether we want to use a shell, or if we
> discovered that we're already in one? Or is "shell" not really a boolean
On 7/29/19 10:02 AM, David Raymond wrote:
> I think the other part of the discussion to be had here is: how do you
> name your booleans?
Yep.
> ... To me the name of a boolean variable should be obvious that it's a
> boolean ...
Well, yeah, maybe. If it's really only a boolean, and its value
On 2019-07-29, Michael Torrie wrote:
> On 7/28/19 6:04 PM, Chris Angelico wrote:
>> This is a fairly unusual case, though. More commonly, the default
>> would be None, not False, and "if bar is None:" is extremely well
>> known and idiomatic.
>
> Ahh yes, true.
No... None.
;)
--
Grant Edwards
I think the other part of the discussion to be had here is: how do you name
your booleans?
As with other things, "x", and "greeting" aren't really the best names.
"greeting" sounds like it should hold what the greeting _is_, not whether or
not there _should be_ a greeting. If it were something
On 7/28/2019 7:55 AM, Jonathan Moules wrote:
Lets say I want to know if the value of `x` is bool(True).
My preferred way to do it is:
if x is True:
pass
If you know that expression x is boolean, and one usually knows or
should know whether is it or is not, '= True' and 'is True' and
si
On 7/28/19 6:04 PM, Chris Angelico wrote:
> This is a fairly unusual case, though. More commonly, the default
> would be None, not False, and "if bar is None:" is extremely well
> known and idiomatic.
Ahh yes, true.
> This analysis is correct, but the situations where you *actually* want
> to kno
On 7/28/19 8:46 PM, Chris Angelico wrote:
> On Mon, Jul 29, 2019 at 10:43 AM Richard Damon
> wrote:
>> On 7/28/19 8:25 PM, Chris Angelico wrote:
>>> Of course, if the third value can be simplified away (eg None means
>>> "use the global default"), then you can still just use "if verbose is
>>> No
On 2019-07-29, Richard Damon wrote:
> On 7/28/19 7:46 PM, Michael Torrie wrote:
>> Yet the recommended solution to the problem of wanting a default
>> argument of an empty list is something like this:
>>
>> def foo(bar=False);
>> if bar is False:
>> bar = []
>>
>>
>
> I thoug
On Mon, Jul 29, 2019 at 10:43 AM Richard Damon wrote:
>
> On 7/28/19 8:25 PM, Chris Angelico wrote:
> > Of course, if the third value can be simplified away (eg None means
> > "use the global default"), then you can still just use "if verbose is
> > None:" and then reassign it. But this is a legit
On 7/28/19 8:25 PM, Chris Angelico wrote:
> On Mon, Jul 29, 2019 at 10:15 AM Richard Damon
> wrote:
>> On 7/28/19 7:46 PM, Michael Torrie wrote:
>>> On 7/28/19 5:55 AM, Jonathan Moules wrote:
But this appears to be explicitly called out as being "Worse" in PEP8:
"""
Don't comp
On Mon, Jul 29, 2019 at 10:15 AM Richard Damon wrote:
>
> On 7/28/19 7:46 PM, Michael Torrie wrote:
> > On 7/28/19 5:55 AM, Jonathan Moules wrote:
> >> But this appears to be explicitly called out as being "Worse" in PEP8:
> >>
> >> """
> >> Don't compare boolean values to True or False using ==.
On 7/28/19 7:46 PM, Michael Torrie wrote:
> On 7/28/19 5:55 AM, Jonathan Moules wrote:
>> But this appears to be explicitly called out as being "Worse" in PEP8:
>>
>> """
>> Don't compare boolean values to True or False using ==.
>>
>> Yes: if greeting:
>> No: if greeting == True:
>> Worse: if
On Mon, Jul 29, 2019 at 9:48 AM Michael Torrie wrote:
>
> On 7/28/19 5:55 AM, Jonathan Moules wrote:
> > But this appears to be explicitly called out as being "Worse" in PEP8:
> >
> > """
> > Don't compare boolean values to True or False using ==.
> >
> > Yes: if greeting:
> > No:if greeting
On 7/28/19 5:55 AM, Jonathan Moules wrote:
> But this appears to be explicitly called out as being "Worse" in PEP8:
>
> """
> Don't compare boolean values to True or False using ==.
>
> Yes: if greeting:
> No: if greeting == True:
> Worse: if greeting is True:
> """
Yet the recommended solu
Jonathan Moules :
> Lets say I want to know if the value of `x` is bool(True).
> My preferred way to do it is:
>
> if x is True:
> [...]
>
> But this appears to be explicitly called out as being "Worse" in PEP8:
>
> [...]
>
> Why?
It has primarily to do with the naturalness of expression. In Engl
19 matches
Mail list logo