[Python-ideas] Re: Have del return a value

2023-09-11 Thread Rob Cliffe via Python-ideas



On 08/09/2023 22:19, Christopher Barker wrote:
On Fri, Sep 8, 2023 at 11:00 AM Barry Scott  
wrote:


I see no need for del to return anything, you already have the
reference in foo.
The times that foo is dropped at module level are rare enough to
not need special syntax.


I agree - using del is very rare in my code. The use case of passing a 
name into a function (or somewhere else?)  and then immediately 
deleting it is rare indeed -- not worth new syntax.


-Chris


+1.  The only time I can remember using del to delete a variable is 
after creating a structure with a large memory footprint that is only 
needed temporarily.

Best wishes
Rob Cliffe___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/RMS3RID2R2NO4V5A3AOKJCUUOCMHXB4Z/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Revise using the colon ( : )

2023-09-11 Thread Dom Grigonis
I don’t think your example depicts the ambiguity well.

1. is the correct parsing of the Original1, 2. is the correct parsing of 
Original2 and 3. is not correct for either of those.

Original1
> while a < b (x := c) - 42
Original2
> while a < b(x := c) - 42

1. In this case, it’s obviously this one
> while a < b:
>(x := c) - 42
2. In here your removed the space, which is not ambiguity, but rather mistype
> Or:
> while a < b(x := c):
>-42
3. Same as in 2. But also, this is not an option, because if there was no 
indent on the next line, then body exists. So this is incorrect.
> Or:
> while a < b(x := c) - 42:
># ???

Having that said, I think readability suffers a lot from not having a colon and 
as you indicated potentially makes parser’s job harder.

Dg.

> On 11 Sep 2023, at 20:11, Celelibi  wrote:
> 
> 2023-09-05 18:26 UTC+02:00, Dom Grigonis  >:
>> I like the idea of eliminating it if it was possible. This is one of my most
>> common syntax errors (although mostly after function signature) and I am not
>> C/C++ programmer. I am not sure about the core technical issues, but
>> readability of code, such as:
>> a = 1
>> while a < 5: a += 1
>> , would suffer:
>> a = 1
>> while a < 5 a += 1
>> So IMO, it does improve readability in certain cases.
>> 
>> Although, removing colon does sound like an idea worth thinking about. I
>> might even dare to suggest disallowing body statement on the same line, but
>> can’t do that for backwards compatibility ofc...
>> 
>> So my point is, if anyone is going to give a thought about this, please add
>> function signature to the list.
>> 
> 
> I just want to mention that without colons, one-liners could become ambiguous:
> while a < b (x := c) - 42
> 
> Is it:
> while a < b:
>(x := c) - 42
> 
> Or:
> while a < b(x := c):
>-42
> 
> Or:
> while a < b(x := c) - 42:
># ???
> 
> If anything, the colon would become optional but would definitely
> remain in the grammar. Kinda like the semi-colon, only used in
> one-liners.
> 
> When teaching python I noticed the usual uselessness of the colon
> regarding the correct parsing of correctly indented code.
> But I've never seen it as a burden and rarely if ever forgot one. It
> also allows code editors to be very simple: you see a line ending with
> a colon, you indent the next line. The keyword at the begining of the
> line doesn't matter.
> 
> Best regards,
> Celelibi
> ___
> Python-ideas mailing list -- python-ideas@python.org 
> 
> To unsubscribe send an email to python-ideas-le...@python.org 
> 
> https://mail.python.org/mailman3/lists/python-ideas.python.org/ 
> 
> Message archived at 
> https://mail.python.org/archives/list/python-ideas@python.org/message/UL3FSZWUKOVUASIPM46IPQIQPJ7GEV7Q/
>  
> 
> Code of Conduct: http://python.org/psf/codeofconduct/ 
> 
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/JQGUO6WQ4Y6H4CYNRG7W6AORWKA2TCAE/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Revise using the colon ( : )

2023-09-11 Thread Stephen J. Turnbull
Celelibi writes:
 > I just want to mention that without colons, one-liners could become
 > ambiguous:

I have no sympathy for optional colons.  No colons, no one-liners.

(Of course optional colons are a great strategy for trying it out, but
in your test programs you should maintain no-colon discipline.)

STeve
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/B46LYKE7W5XHDUDTFA75OI2NIR25ISWI/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Have del return a value

2023-09-11 Thread Rob Cliffe via Python-ideas



On 08/09/2023 22:19, Christopher Barker wrote:
On Fri, Sep 8, 2023 at 11:00 AM Barry Scott  
wrote:


I see no need for del to return anything, you already have the
reference in foo.
The times that foo is dropped at module level are rare enough to
not need special syntax.


I agree - using del is very rare in my code. The use case of passing a 
name into a function (or somewhere else?)  and then immediately 
deleting it is rare indeed -- not worth new syntax.


-Chris


+1.  The only time I can remember using del to delete a variable is 
after creating a structure with a large memory footprint that is only 
needed temporarily.

Best wishes
Rob Cliffe

PS Ooh, not quite true.  I have used it to delete a variable that should 
no longer be needed to detect accidental illegitimate use of said variable.

RC___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/4OOPGTA2AFKYC3SVCAY62ITSLK76AN3N/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Revise using the colon ( : )

2023-09-11 Thread Celelibi
2023-09-05 18:26 UTC+02:00, Dom Grigonis :
> I like the idea of eliminating it if it was possible. This is one of my most
> common syntax errors (although mostly after function signature) and I am not
> C/C++ programmer. I am not sure about the core technical issues, but
> readability of code, such as:
> a = 1
> while a < 5: a += 1
> , would suffer:
> a = 1
> while a < 5 a += 1
> So IMO, it does improve readability in certain cases.
>
> Although, removing colon does sound like an idea worth thinking about. I
> might even dare to suggest disallowing body statement on the same line, but
> can’t do that for backwards compatibility ofc...
>
> So my point is, if anyone is going to give a thought about this, please add
> function signature to the list.
>

I just want to mention that without colons, one-liners could become ambiguous:
while a < b (x := c) - 42

Is it:
while a < b:
(x := c) - 42

Or:
while a < b(x := c):
-42

Or:
while a < b(x := c) - 42:
# ???

If anything, the colon would become optional but would definitely
remain in the grammar. Kinda like the semi-colon, only used in
one-liners.

When teaching python I noticed the usual uselessness of the colon
regarding the correct parsing of correctly indented code.
But I've never seen it as a burden and rarely if ever forgot one. It
also allows code editors to be very simple: you see a line ending with
a colon, you indent the next line. The keyword at the begining of the
line doesn't matter.

Best regards,
Celelibi
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/UL3FSZWUKOVUASIPM46IPQIQPJ7GEV7Q/
Code of Conduct: http://python.org/psf/codeofconduct/