[Python-ideas] Re: PEP8 mandatory-is rule

2021-09-02 Thread Chris Angelico
On Fri, Sep 3, 2021 at 3:24 PM Steven D'Aprano wrote: > > On Thu, Sep 02, 2021 at 04:54:45PM +0900, Stephen J. Turnbull wrote: > > Steven D'Aprano writes: > > > On Thu, Sep 02, 2021 at 04:04:40PM +0900, Stephen J. Turnbull wrote: > > > > > > > You may not need to teach them about singletons, th

[Python-ideas] Re: PEP8 mandatory-is rule

2021-09-02 Thread Steven D'Aprano
On Thu, Sep 02, 2021 at 04:54:45PM +0900, Stephen J. Turnbull wrote: > Steven D'Aprano writes: > > On Thu, Sep 02, 2021 at 04:04:40PM +0900, Stephen J. Turnbull wrote: > > > > > You may not need to teach them about singletons, though. > > > > It's hard to teach why `is` works with None, > >

[Python-ideas] Re: Allow starred expressions to be used as subscripts for nested lookups for getitem and setitem

2021-09-02 Thread Steven D'Aprano
Kevin Mills suggested: > > > d = {1: {2: {3: 4}}} > > > keys= 1,2,3 > > > print(d[*keys]) > > > d[*keys] = None > > > print(d) > > > > > > Hopefully it's clear from that example what I'm suggesting. MRAB replied: > > Would that be equivalent to d[keys[0], keys[1], keys[2]]? > > > > If so, it wo

[Python-ideas] Re: Remove a single warning from the warnings filter list

2021-09-02 Thread Chris Angelico
On Fri, Sep 3, 2021 at 12:45 AM Peter Otten <__pete...@web.de> wrote: > > On 02/09/2021 11:41, Chris Angelico wrote: > > On Thu, Sep 2, 2021 at 7:36 PM Peter Otten <__pete...@web.de> wrote: > >> > >> On 02/09/2021 04:32, Steven D'Aprano wrote: > >>> On Wed, Sep 01, 2021 at 03:40:37PM +0200, Peter O

[Python-ideas] Re: Remove a single warning from the warnings filter list

2021-09-02 Thread Peter Otten
On 02/09/2021 11:41, Chris Angelico wrote: On Thu, Sep 2, 2021 at 7:36 PM Peter Otten <__pete...@web.de> wrote: On 02/09/2021 04:32, Steven D'Aprano wrote: On Wed, Sep 01, 2021 at 03:40:37PM +0200, Peter Otten wrote: Instead of removing it you might add a filter to get a similar effect: [.

[Python-ideas] Re: Additional Unpacking Generalizations for assignment

2021-09-02 Thread Matsuoka Takuo
Dear 笹原康央, This sounds interesting. The assignment could be done e.g., like this. ```python def assign(variables): return f''' for _variable, _value in (lambda {variables}: locals())( *_values, **_assignments ).items(): exec(f'{{_variable}} = _value') ''' def name_update(_nam

[Python-ideas] Re: Remove a single warning from the warnings filter list

2021-09-02 Thread Chris Angelico
On Thu, Sep 2, 2021 at 7:36 PM Peter Otten <__pete...@web.de> wrote: > > On 02/09/2021 04:32, Steven D'Aprano wrote: > > On Wed, Sep 01, 2021 at 03:40:37PM +0200, Peter Otten wrote: > > > >> Instead of removing it you might add a filter to get a similar effect: > > > > [...] > > > > warnings.fi

[Python-ideas] Re: Remove a single warning from the warnings filter list

2021-09-02 Thread Peter Otten
On 02/09/2021 04:32, Steven D'Aprano wrote: On Wed, Sep 01, 2021 at 03:40:37PM +0200, Peter Otten wrote: Instead of removing it you might add a filter to get a similar effect: [...] warnings.filterwarnings("always", "woof!") Unfortunately that's too aggressive. In my use-case, `bark` will

[Python-ideas] Re: PEP8 mandatory-is rule

2021-09-02 Thread Chris Angelico
On Thu, Sep 2, 2021 at 5:56 PM Stephen J. Turnbull wrote: > > Steven D'Aprano writes: > > On Thu, Sep 02, 2021 at 04:04:40PM +0900, Stephen J. Turnbull wrote: > > > > > You may not need to teach them about singletons, though. > > > > It's hard to teach why `is` works with None, > > For defini

[Python-ideas] Re: PEP8 mandatory-is rule

2021-09-02 Thread Stephen J. Turnbull
Steven D'Aprano writes: > On Thu, Sep 02, 2021 at 04:04:40PM +0900, Stephen J. Turnbull wrote: > > > You may not need to teach them about singletons, though. > > It's hard to teach why `is` works with None, For definitions of "works" that comes down to "agrees with Nick that 'is' is just a

[Python-ideas] Re: PEP8 mandatory-is rule

2021-09-02 Thread Steven D'Aprano
On Thu, Sep 02, 2021 at 04:04:40PM +0900, Stephen J. Turnbull wrote: > You may not need to teach them about singletons, though. It's hard to teach why `is` works with None, but not with 1.234 or [], without talking about the object model and singletons. To say nothing of why it works with 0 and

[Python-ideas] Re: PEP8 mandatory-is rule

2021-09-02 Thread Stephen J. Turnbull
Michael Lee writes: > None is primarily useful for representing the absence of some > value, and I'm not sure if that's something beginners actually need > to write interesting and useful code. In Python, we generally think of writing code as a subordinate skill. :-) In reading code, beginner