[Python-ideas] Re: Optional keyword arguments

2020-05-30 Thread Steven D'Aprano
On Sat, May 30, 2020 at 04:41:58PM +1200, Greg Ewing wrote: > On 30/05/20 2:52 am, Dominik Vilsmeier wrote: > >Indeed locals are special, but why was it designed this way? Why not > >resolve such an unbound local name in the enclosing scopes? > > From experience with other languages I can attest t

[Python-ideas] Re: How to propose a change with tests where the failing test case (current behaviour) is bad or dangerous

2020-05-30 Thread Rob Cliffe via Python-ideas
OK, I didn't want to be guilty of advertising, but it is ImDisk and can, I believe, be downloaded from     https://sourceforge.net/projects/imdisk-toolkit/ and I have used it happily for some years. Disclosure: I have no interest in or connection with, direct or indirect, financial or otherwise

[Python-ideas] Re: Optional keyword arguments

2020-05-30 Thread Greg Ewing
On 30/05/20 4:28 pm, Steven D'Aprano wrote: py> len() TypeError: len() takes exactly one argument (0 given) to be replaced with something like this: UnboundLocalError: local variable referenced before assignment Not in my version of the idea, because a parameter would only be a

[Python-ideas] Re: Optional keyword arguments

2020-05-30 Thread Steven D'Aprano
On Sat, May 30, 2020 at 04:34:49PM +1200, Greg Ewing wrote: > On 30/05/20 12:11 am, Steven D'Aprano wrote: > >I said that the storage mechanism of *how* local variables are stored, > >and hence whether or not writes to `locals()` are reflected in the > >local variables, is an implementation detail.

[Python-ideas] Re: Optional keyword arguments

2020-05-30 Thread Chris Angelico
On Sat, May 30, 2020 at 6:13 PM Steven D'Aprano wrote: > > On Sat, May 30, 2020 at 04:34:49PM +1200, Greg Ewing wrote: > > On 30/05/20 12:11 am, Steven D'Aprano wrote: > > >I said that the storage mechanism of *how* local variables are stored, > > >and hence whether or not writes to `locals()` are

[Python-ideas] Re: Optional keyword arguments

2020-05-30 Thread Greg Ewing
On 30/05/20 7:15 pm, Steven D'Aprano wrote: Out of curiosity, which languages are you thinking of? I know Lua does that, I can't think of any others. You've probably never seen the one I'm thinking of. It's a proprietary, vaguely VB-like language used for scripting a particular application. It

[Python-ideas] Re: Optional keyword arguments

2020-05-30 Thread Greg Ewing
On 30/05/20 8:03 pm, Steven D'Aprano wrote: Is this `?=` idea for a general purpose operator we can use anywhere we like? I introduced it as part of a two-part idea for allowing optional parameters without a default. But there would be nothing to stop you from using it elsewhere. The syntax wa

[Python-ideas] Re: Optional keyword arguments

2020-05-30 Thread Steven D'Aprano
On Thu, May 28, 2020 at 10:37:58PM +1200, Greg Ewing wrote: > I think we need a real example to be able to talk about this > meaningfully. > > But I'm having trouble thinking of one. I can't remember ever > writing a function with a default argument value that *has* to > be mutable and *has* to h

[Python-ideas] Re: Optional keyword arguments

2020-05-30 Thread Alex Hall
On Sat, May 30, 2020 at 6:00 AM Steven D'Aprano wrote: > On Fri, May 29, 2020 at 06:03:30PM +0200, Alex Hall wrote: > > > > I never said that Python's scoping rules were implementation details. > > > > > > I said that the storage mechanism of *how* local variables are stored, > > > and hence whet

[Python-ideas] Re: Python GIL Thoughts

2020-05-30 Thread Antoine Pitrou
On Fri, 29 May 2020 22:18:15 +0300 Paul Sokolovsky wrote: > In all fairness, I don't know if Stackless ever fully waved GIL > goodbye. If not, it shows how much the Python userbase needs to get rid > of GIL. Yes, nevermind that Stackless was designed at a time when multicore computers were an exo

[Python-ideas] Re: Optional keyword arguments

2020-05-30 Thread Steven D'Aprano
On Thu, May 28, 2020 at 10:27:47PM +1200, Greg Ewing wrote: > On 28/05/20 7:31 pm, Chris Angelico wrote: > >Is it an implementation detail that 4 will be used for eggs if it > >isn't passed? > > That feels different to me somehow. I think it has something to do > with declarative vs. procedural st

[Python-ideas] Re: Optional keyword arguments

2020-05-30 Thread Greg Ewing
On 31/05/20 1:31 am, Steven D'Aprano wrote: On Thu, May 28, 2020 at 10:27:47PM +1200, Greg Ewing wrote: On 28/05/20 7:31 pm, Chris Angelico wrote: Is it an implementation detail that 4 will be used for eggs if it isn't passed? The default value of eggs being 4 is a static fact, but creating a

[Python-ideas] Re: Python __main__ function

2020-05-30 Thread Mike Miller
On 2020-05-28 18:02, Greg Ewing wrote: If __name__ == '__main__': sys.exit(main(sys.argv[1:])) It's not clear that exiting with the return value of main() is the most Pythonic thing to do -- it's more of a C idiom that If you'd like a script to be uhh, highly-scriptable, returning one

[Python-ideas] Re: Python __main__ function

2020-05-30 Thread Chris Angelico
On Sun, May 31, 2020 at 6:14 AM Mike Miller wrote: > > > On 2020-05-28 18:02, Greg Ewing wrote: > >> If __name__ == '__main__': > >> sys.exit(main(sys.argv[1:])) > > > > It's not clear that exiting with the return value of main() is > > the most Pythonic thing to do -- it's more of a C idiom

[Python-ideas] Re: Python __main__ function

2020-05-30 Thread Steven D'Aprano
On Sun, May 31, 2020 at 06:45:01AM +1000, Chris Angelico wrote: > On Sun, May 31, 2020 at 6:14 AM Mike Miller wrote: > > > > > > On 2020-05-28 18:02, Greg Ewing wrote: > > >> If __name__ == '__main__': > > >> sys.exit(main(sys.argv[1:])) > > > > > > It's not clear that exiting with the return