[Python-ideas] Re: Should Python enforce Type-checking in the future?

2021-12-10 Thread Steven D'Aprano
Some additional comments. On Thu, Dec 09, 2021 at 08:32:43PM +, deavid wrote: > 1) On really big codebases and complex projects, it's very easy to lose > track of what things do. Types help detecting bugs early. Static types help detecting *some* kinds of bugs early. Python doesn't stop you

[Python-ideas] Re: Python standard library TOML module

2021-12-10 Thread Valentin Berlier
Yes. This is desperately needed. Usually I'm not a big fan of adding new standard library modules but in this case since toml is becoming such a critical part of packaging it seems like a no-brainer. ___ Python-ideas mailing list -- python-ideas@python.

[Python-ideas] Re: [issue32683] isinstance is calling ob.__getattribute__ as a fallback instead of object.__class__.__get__

2021-12-10 Thread Steven D'Aprano
On Fri, Dec 10, 2021 at 12:03:15AM +, Gabriele N Tornetta wrote: > class Side(object): > def __getattribute__(self, name): > ValueError(name) You forgot to actually *raise* the exception. That will just instantiate the ValueError instance, and then immediately garbage collect it.

[Python-ideas] Re: Should Python enforce Type-checking in the future?

2021-12-10 Thread Carl Meyer
Hi David, I think there's an important distinction to be made between "enforcing types" as in "type annotations that are present are checked for consistency at compile time and enforced at runtime, instead of only being checked by a linter and possibly totally wrong at runtime" vs "enforcing types

[Python-ideas] Re: Should Python enforce Type-checking in the future?

2021-12-10 Thread Carl Meyer
Another project you may want to look at is MyPyC [1], which is similar in concept but takes a different approach; it compiles type-annotated Python to CPython C extension code. MyPyC is much more mature and something you could easily try out today. Carl [1] https://github.com/mypyc/mypyc

[Python-ideas] Re: Runtime-accessible attribute docstrings – take 2

2021-12-10 Thread Simão Afonso
On 2021-12-09 12:47:28, Paul Bryan wrote: > On Thu, 2021-12-09 at 19:01 +, Simão Afonso wrote: > > I'm using docstrings bellow the attributes (analogous to functions > > and > > classes), I think it works well. > > It helps with distinguishing the class docstring from the arguments. > > I thin

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-10 Thread Eric V. Smith
On 12/6/2021 1:24 AM, Christopher Barker wrote: On Sun, Dec 5, 2021 at 10:38 AM David Mertz, Ph.D. wrote: I first discussed the idea of a "generalized deferred object/type" on this list at least two years ago, probably more than three (I haven't looked through archives lately to

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-10 Thread Christopher Barker
I’m still not clear if this is a disagreement about something more than terminology, but as I understand it, other languages that have non-constant defaults use late binding, and call them “defaults”. It seems to be a well accepted term. -CHB On Thu, Dec 9, 2021 at 12:45 AM Brendan Barnwell

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-10 Thread Christopher Barker
On Thu, Dec 9, 2021 at 2:31 AM Paul Moore wrote > Your email client is doing "white on white" again. You should try to > get that fixed :-( Aarrgg— it was iPhone “dark mode” — white on black for me. Why the heck it preserves the text color (and not the background) is beyond me. I hope this work

[Python-ideas] Re: Runtime-accessible attribute docstrings – take 2

2021-12-10 Thread Ricky Teachey
On Fri, Dec 10, 2021, 6:08 AM Simão Afonso wrote: > On 2021-12-09 12:47:28, Paul Bryan wrote: > > On Thu, 2021-12-09 at 19:01 +, Simão Afonso wrote: > > > I'm using docstrings bellow the attributes (analogous to functions > > > and > > > classes), I think it works well. > > > It helps with di

[Python-ideas] Re: Python standard library TOML module

2021-12-10 Thread Christopher Barker
Yes please! It always seemed very odd to me that the standard packaging system would require a non-standard library. Surely TOML is stable enough by now? -CHB On Fri, Dec 10, 2021 at 4:06 AM Valentin Berlier wrote: > Yes. This is desperately needed. Usually I'm not a big fan of adding new > s

[Python-ideas] Re: Should Python enforce Type-checking in the future?

2021-12-10 Thread Christopher Barker
On Fri, Dec 10, 2021 at 4:10 AM Carl Meyer wrote: > Another project you may want to look at is MyPyC [1], Or Cython, which has used a non-standard typing system for years, and is currently working on adopting the new types. It’s a very tricky business though, because Cython is generating C cod

[Python-ideas] Re: Runtime-accessible attribute docstrings – take 2

2021-12-10 Thread Simão Afonso
On 2021-12-10 08:20:25, Ricky Teachey wrote: > Very very interesting that Sphinx already treats a bare string under the > parameter as documentation! I had no idea. Does it do the same thing at the > module level? Yes. > $ cat module.py > """This is the module docs""" > > class CLS: > """CL

[Python-ideas] Re: Python standard library TOML module

2021-12-10 Thread Sebastian Koslowski
There is already some info/discussion over on the bug tracker: https://bugs.python.org/issue40059 Sebastian ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/ma

[Python-ideas] Re: Should Python enforce Type-checking in the future?

2021-12-10 Thread Steven D'Aprano
On Fri, Dec 10, 2021 at 08:32:27AM -0800, Christopher Barker wrote: > On Fri, Dec 10, 2021 at 4:07 AM Steven D'Aprano wrote: > > > > 1) On really big codebases and complex projects, it's very easy to lose > > > track of what things do. Types help detecting bugs early. > > > > Static types help de

[Python-ideas] Re: Runtime-accessible attribute docstrings – take 2

2021-12-10 Thread Ricky Teachey
On Fri, Dec 10, 2021 at 11:46 AM Simão Afonso < simao.afo...@powertools-tech.com> wrote: > On 2021-12-10 08:20:25, Ricky Teachey wrote: > > Very very interesting that Sphinx already treats a bare string under the > > parameter as documentation! I had no idea. Does it do the same thing at > the > >

[Python-ideas] Re: Should Python enforce Type-checking in the future?

2021-12-10 Thread Peter Ludemann
Steven D'Aprano wrote: > > That seems to be close to the opinion of Robert C Martin: > http://blog.cleancoder.com/uncle-bob/2016/05/01/TypeWars.html > He also has some comments on languages like Koitlin and Swift that have > gone down that path of mandatory static typing: > http://blog.cleancoder

[Python-ideas] Re: Runtime-accessible attribute docstrings – take 2

2021-12-10 Thread Simão Afonso
On 2021-12-10 12:20:44, Ricky Teachey wrote: > I meant to ask about a (global) module member, not the module docstring > itself. Like MY_GLOBAL below: > > """This is the module docs""" > > MY_GLOBAL = None > """MY_GLOBAL docs""" > > class CLS: >"""CLS docs""" > >attr: int >

[Python-ideas] Re: Should Python enforce Type-checking in the future?

2021-12-10 Thread Joao S. O. Bueno
On Thu, 9 Dec 2021 at 17:54, deavid wrote: > Hi, I would like to hear the opinion of Python's community on enforcing > types in the future for the language. > here goes opinion: "no"! strong no. while _using_ tooling that have correct typing is a bit easier, it can make it hard to write code,

[Python-ideas] Re: Should Python enforce Type-checking in the future?

2021-12-10 Thread deavid
Well, this has a lot of strong opinions already! I didn't expect less :-) I'm not sure how to answer so many thoughts without making this super-long. I'll try to reply in general. I agree that a compile-time python makes no sense, it would be a different language and we would lose 90% of what Pyt

[Python-ideas] Re: Should Python enforce Type-checking in the future?

2021-12-10 Thread Chris Angelico
On Sat, Dec 11, 2021 at 7:44 AM deavid wrote: > When I said earlier in "compile time", I was just trying to refer to the > parsing step, or pre-parsing step. Or maybe means that "python a.py" => "mypy > a.py && python a.py". > I'm being very ambiguous here on purpose because there are tons of wa

[Python-ideas] Re: Should Python enforce Type-checking in the future?

2021-12-10 Thread 2QdxY4RzWzUUiLuE
On 2021-12-10 at 20:20:05 +, deavid wrote: > A lot of you are referring to scripting, learning, and other ways of > using Python that would be badly impacted. I already acknowledged that > these exist (or at least I didn't notice here any other that I wasn't > aware), and that's why I mention

[Python-ideas] Re: Should Python enforce Type-checking in the future?

2021-12-10 Thread Jean Abou Samra
Hi, (NB: I'm just a lurker here, posting for almost the first time. I may say silly things.) Le 09/12/2021 à 21:32, deavid a écrit : Hi, I would like to hear the opinion of Python's community on enforcing types in the future for the language. I've been using Python as my main language for ever

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-10 Thread Eric V. Smith
On 12/9/2021 10:32 AM, Eric V. Smith wrote: On 12/6/2021 1:24 AM, Christopher Barker wrote: But I honestly don’t get it. My idea of a deferred object would be quite different that this, would not be a great replacement for this, and could quite happily co-exist with this idea. Clearly I’m mi

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-10 Thread Chris Angelico
On Sat, Dec 11, 2021 at 9:26 AM Eric V. Smith wrote: > > On 12/9/2021 10:32 AM, Eric V. Smith wrote: > > On 12/6/2021 1:24 AM, Christopher Barker wrote: > > > > But I honestly don’t get it. My idea of a deferred object would be quite > different that this, would not be a great replacement for thi

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-10 Thread 2QdxY4RzWzUUiLuE
On 2021-12-10 at 17:24:22 -0500, "Eric V. Smith" wrote: > [0]: Or arguments, I can never remember which is which: someone needs > to invent a memorable mnemonic device. Pass Arguments Accept Parameters (I don't know. I just made that up. For some reason, the fact that functions have "formal p

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-10 Thread Chris Angelico
On Sat, Dec 11, 2021 at 9:43 AM <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2021-12-10 at 17:24:22 -0500, > "Eric V. Smith" wrote: > > > [0]: Or arguments, I can never remember which is which: someone needs > > to invent a memorable mnemonic device. > > Pass Arguments > Accept Parameters >

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-10 Thread Christopher Barker
>> a memorable mnemonic device. > Pass Arguments > Accept Parameters Darn — the P and A are swapped there. But that’s the paradox with mnemonics — that may help me remember it :-) -CHB > > > (I don't know. I just made that up. For some reason, the fact that > functions have "formal parameter

[Python-ideas] Re: inline Python functions and methods

2021-12-10 Thread TobiasHT
So I went back and revised my idea for inline functions in python, and I realized that it would be harder to implement them in python the way I had originally thought about them, due to Python’s dynamic nature. However, the idea itself doesn’t seem so original, as Cinder already implements inlin

[Python-ideas] Re: Runtime-accessible attribute docstrings – take 2

2021-12-10 Thread Stephen J. Turnbull
Simão Afonso writes: > On 2021-12-10 12:20:44, Ricky Teachey wrote: > > I meant to ask about a (global) module member, not the module docstring > > itself. Like MY_GLOBAL below: > > > > """This is the module docs""" > > > > MY_GLOBAL = None > > """MY_GLOBAL docs""" > > > > Is this "

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-10 Thread Stephen J. Turnbull
Eric V. Smith writes: > That's why I think we should have a larger concept that just late-bound > parameters: I think there's a general concept here that can be extended > beyond parameters. One advantage of Chris's preferred syntax is that as a default in a function's parameter list it coul

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-10 Thread Chris Angelico
On Sat, Dec 11, 2021 at 5:35 PM Stephen J. Turnbull wrote: > > Eric V. Smith writes: > > > That's why I think we should have a larger concept that just late-bound > > parameters: I think there's a general concept here that can be extended > > beyond parameters. > > One advantage of Chris's pref