[Python-ideas] Re: [dataclasses] add a NON_FIELDS sentinel after which all attributes are ignored.

2023-06-22 Thread Jelle Zijlstra
El jue, 22 jun 2023 a las 8:22, Randolf Scholz () escribió: > Dataclasses should provide a way to ignore a type hinted attributes, and > not consider them as fields. > > For example, some attributes might be derived during `__post_init__` from > the values of the fields or other variables. > > If

[Python-ideas] Re: Keyword argument support for exec/eval?

2023-06-07 Thread Jelle Zijlstra
I would support allowing the globals and locals arguments to exec() to be passed as keyword arguments. Open an issue on https://github.com/python/cpython and if no other core devs object, we can fix this in 3.13. The actual code change would be very small thanks to Argument Clinic. El mié, 7 jun

[Python-ideas] Re: Protocols Subclassing Normal Classes

2023-04-24 Thread Jelle Zijlstra
The formal term for that is intersection types. There is a long-standing thread about that at https://github.com/python/typing/issues/213; there are some uses but the feature would greatly complicate the type system, so it's not clear that it's worth adding. At this point, what Intersection needs

[Python-ideas] Re: new PEP: implementation independent native code invocation and data exchange ABI standard (not sure if accurate)

2023-04-23 Thread Jelle Zijlstra
At the Language Summit a few days ago we discussed this problem. I wasn't involved in this discussion, but it's a hard one to solve. You may be interested in HPy (https://hpyproject.org/), which aims to provide what you are looking for. El dom, 23 abr 2023 a las 6:18, Evan Greenup via

[Python-ideas] Re: Confusing naming of Optional type should be changed

2022-07-01 Thread Jelle Zijlstra
El jue, 30 jun 2022 a las 22:19, Stephen J. Turnbull (< stephenjturnb...@gmail.com>) escribió: > nveric...@gmail.com writes: > > > I accidentally created another thread in python-dev as I mentioned > > above, but ideally Optional and Union should both be deprecated and > > phased out for the

[Python-ideas] Re: Confusing naming of Optional type should be changed

2022-06-30 Thread Jelle Zijlstra
El jue, 30 jun 2022 a las 10:46, escribió: > (I apologize in advance if I've posted anything incorrectly before, I > believe I might have sent this in python-dev instead but not sure as it's > not appearing in the posts for my account). > > I am aware this is clarified in the Python

[Python-ideas] Re: Generalized deferred computation in Python

2022-06-26 Thread Jelle Zijlstra
El sáb, 25 jun 2022 a las 13:44, Chris Angelico () escribió: > On Sun, 26 Jun 2022 at 04:41, Brendan Barnwell > wrote: > > In contrast, what I would want out of deferred evaluation is > precisely > > the ability to evaluate the deferred expression in the *evaluating* > > scope (not the

[Python-ideas] Re: Expand type coverage in cpython implementation

2022-03-16 Thread Jelle Zijlstra
El mié, 16 mar 2022 a las 3:58, Jared Crawford () escribió: > Hi all, > > I recently noticed that stdlib functions often don't have type hints. Is > there a technical reason why typing isn't more widespread in the cpython > implementation? Mostly there hasn't been agreement to add them. See

[Python-ideas] Re: Syntax proposal of for..in..if in regular for loops

2022-03-07 Thread Jelle Zijlstra
El lun, 7 mar 2022 a las 19:57, Christopher Barker () escribió: > On Mon, Mar 7, 2022 at 3:43 PM Chris Angelico wrote: > >> On Tue, 8 Mar 2022 at 10:39, Jelle Zijlstra >> wrote: >> > >> > >> > >> > El lun, 7 mar 2022 a las 15:35, Chri

[Python-ideas] Re: Syntax proposal of for..in..if in regular for loops

2022-03-07 Thread Jelle Zijlstra
El lun, 7 mar 2022 a las 15:35, Chris Angelico () escribió: > On Tue, 8 Mar 2022 at 10:20, Brendan Barnwell > wrote: > > > > On 2022-03-06 14:43, Chris Angelico wrote: > > > This keeps happening. All the successful ideas seem to happen > > > elsewhere, notably on typing-sig. > > > > You

[Python-ideas] Re: Creating a class template file generator inside Python language

2022-02-16 Thread Jelle Zijlstra
Are you aware of https://docs.python.org/3.10/library/dataclasses.html? That essentially provides a way to generate the boilerplate without having to put it all in your code. El mié, 16 feb 2022 a las 5:20, Avanish Gupta () escribió: > Thanks for the previous mail. > I would like to highlight

[Python-ideas] Re: mimetypes.guess_type should not return deprecated mimetype application/x-javascript

2022-01-18 Thread Jelle Zijlstra
Perhaps there should be a guess_all_types() function in addition to guess_type() that returns all possible types, so that the user can select the type they want using any criterion. This would be nicely symmetrical with the existing guess_extension and guess_all_extensions functions.

[Python-ideas] Re: Revisiting a frozenset display literal

2022-01-17 Thread Jelle Zijlstra
El lun, 17 ene 2022 a las 7:11, Steven D'Aprano () escribió: > On Mon, Jan 17, 2022 at 11:18:13PM +0900, Inada Naoki wrote: > > On Mon, Jan 17, 2022 at 8:49 PM Steven D'Aprano > wrote: > > > > > > On Mon, Jan 17, 2022 at 08:04:50PM +0900, Inada Naoki wrote: > > > > > > > Name lookup is faster

[Python-ideas] Re: PEP Idea: Better return type annotation syntax

2022-01-06 Thread Jelle Zijlstra
On Thu, Jan 6, 2022 at 10:44 PM Tushar Sadhwani < tushar.sadhwani...@gmail.com> wrote: > With the recent submission of [PEP 677][1], I was reminded of an idea I > had with function annotation syntax since the very beginning: > > why not let me write: > > ```python > def f() -> tuple[int, str]: >

[Python-ideas] Re: extending ast.parse with some lib2to3.pytree features

2021-11-22 Thread Jelle Zijlstra
El dom, 21 nov 2021 a las 14:35, Peter Ludemann () escribió: > Neil Girdhar wrote: > > I wish this had gotten more attention! :) > > I wonder what the various projects are doing to handle the latest version > of Python, if they need a parse tree with whitespace information. (The > projects I know

[Python-ideas] Re: Adding pep8-casing-compliant aliases for the entire stdlib

2021-11-11 Thread Jelle Zijlstra
El jue, 11 nov 2021 a las 5:41, Matt del Valle () escribió: > So I was reading the docs for the `threading` module and I stumbled upon > this little note: > > Note: > > In the Python 2.x series, this module contained camelCase names for some > methods and functions. These are deprecated as of

[Python-ideas] Re: Syntax for late-bound arguments

2021-10-23 Thread Jelle Zijlstra
El sáb, 23 oct 2021 a las 12:57, Guido van Rossum () escribió: > I like that you're trying to fix this wart! I think that using a different > syntax may be the only way out. My own bikeshed color to try would be `=>`, > assuming we'll introduce `(x) => x+1` as the new lambda syntax, but I can >

[Python-ideas] Re: Structure Pattern for annotation

2021-10-15 Thread Jelle Zijlstra
El vie, 15 oct 2021 a las 14:42, Abdulla Al Kathiri (< alkathiri.abdu...@gmail.com>) escribió: > I don’t understand why tuple structure is not supported already. It makes > reading the function signature a breeze and very natural. You can also do > it without parentheses which mimics the return

[Python-ideas] Re: Implementing string unary operators

2021-10-12 Thread Jelle Zijlstra
El mar, 12 oct 2021 a las 16:51, Jeremiah Vivian (< nohackingofkrow...@gmail.com>) escribió: > I posted a previous thread about overloading the unary `+` operator in > strings with `ord`, and that expanded to more than just the unary `+` > operator. So I'm saying now, there should be these

[Python-ideas] Re: More natural type hints for built-in containers

2021-07-28 Thread Jelle Zijlstra
I suggested this before in some typing meetup, but there are a few problems with it. One is that annotating arguments as "list" or "dict" is often the wrong thing to do: instead, people should use broader, immutable types like Iterable, Sequence, or Mapping, to avoid variance problems (

[Python-ideas] Re: Deprecate sum of lists

2021-06-17 Thread Jelle Zijlstra
El jue, 17 jun 2021 a las 15:26, Steven D'Aprano () escribió: > On Thu, Jun 17, 2021 at 02:51:44PM -0700, Jelle Zijlstra wrote: > > El jue, 17 jun 2021 a las 14:45, David Mertz () > escribió: > > > > > On Thu, Jun 17, 2021, 5:24 PM Ben Rudiak-Gould > > > >

[Python-ideas] Re: Deprecate sum of lists

2021-06-17 Thread Jelle Zijlstra
El jue, 17 jun 2021 a las 14:45, David Mertz () escribió: > On Thu, Jun 17, 2021, 5:24 PM Ben Rudiak-Gould > >> Okay, slightly off-topic, but can we *please* allow >> >> [*chunk for chunk in list_of_lists] >> > > It is completely non-obvious to me what that would even MEAN. I cannot > derive

[Python-ideas] Re: Define functions without parentheses (if no parameters given)

2021-06-11 Thread Jelle Zijlstra
El jue, 10 jun 2021 a las 19:30, Cameron Simpson () escribió: > On 11Jun2021 10:01, Cameron Simpson wrote: > >So your idea does not suck. But it may not motivate anyone to implement > >it, or even to agreed that it should be implemented. > > It also struck me: functions with _no_ parameters are

[Python-ideas] Re: The Pattern Matching Wildcard Is A Bad Idea

2021-06-02 Thread Jelle Zijlstra
El mié, 2 jun 2021 a las 8:34, Alexis Masson () escribió: > Yeah, that's it exactly. > > I see these two features - `_` as a joker in `match` statements and `_`as > the last value produced by a shell - as incompatible, because you have to > account for interferences between them, or face

[Python-ideas] Re: The name Ellipsis should be a constant

2021-05-31 Thread Jelle Zijlstra
El lun, 31 may 2021 a las 12:40, David Mertz () escribió: > I think making 'Ellipsis' a reserved word is too much. The analogy with > non-reserved words like `int`, `str`, `map`, `print`, and so on, illustrate > this, I think. I.e. redefining those is likely to cause bad things to > happen, but

[Python-ideas] Re: dataclasses: position-only and keyword-only fields

2021-03-13 Thread Jelle Zijlstra
Another option is something like this (building on Ricky Teachey's suggestion): from dataclasses import ArgumentMarker, dataclass @dataclass class C: a: Any # positional-only __pos__: ArgumentMarker b: Any # normal __kw_only__: ArgumentMarker c: Any # keyword-only The

[Python-ideas] Re: add !p to pprint.pformat() in str.format() an f-strings

2020-07-24 Thread Jelle Zijlstra
El mar., 21 jul. 2020 a las 17:27, Guido van Rossum () escribió: > A philosophical problem with this is proposal is that it takes a notation > that is processed by the bytecode compiler and makes it dependent on user > code to be imported from the stdlib. We only do that in rare cases — IIRC >

Re: [Python-ideas] Backward-incompatible changes for Python 4

2019-04-01 Thread Jelle Zijlstra
El lun., 1 abr. 2019 a las 7:28, Antoine Pietri () escribió: > While the switch to Python 3 did an excellent job in removing some of > the old inconsistencies we had in the language, pretty much everyone > agrees that some other backwards-incompatible changes could be made to > remove some old

Re: [Python-ideas] function annotation enhancement

2019-03-19 Thread Jelle Zijlstra
Your proposed syntax is hard to implement, because it would require invasive syntax changes to the language itself. That's probably not worth it. However, there are other ways to achieve what you're looking for that don't require changing the language itself. This issue has some proposals:

Re: [Python-ideas] anyone need a frozenset or bytearray literal?

2018-07-11 Thread Jelle Zijlstra
2018-07-11 16:25 GMT-07:00 Gregory P. Smith : > Completely obvious what it does, but it irritates my aesthetic > sensibilities every time I see: > frozenset({spam, eggs}) > > Why? Because I assume under the hood that creates a set of spam and eggs > before calling frozenset to copy it into a

Re: [Python-ideas] Fwd: Replacing Infinite while Loops with an Iterator: async edition

2018-06-24 Thread Jelle Zijlstra
2018-06-24 12:30 GMT-07:00 : > On Jun 23, 2018, at 21:11, Nathaniel Smith wrote: > >> He's asking for an async version of the 'iter' builtin, presumably >> something like: >> async def aiter(async_callable, sentinel): >>while True: >>value = await async_callable() >>if value

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-17 Thread Jelle Zijlstra
2018-06-17 13:09 GMT-07:00 Chris Angelico : > > kwargs.pop("some_key") could plausibly be spelled del > kwargs["some_key"] if del were (like yield) upgraded to expression. > Whether that is an improvement or not, I don't know, but at least it's > logical. > That already works. It calls the

Re: [Python-ideas] A "within" keyword

2018-06-08 Thread Jelle Zijlstra
2018-06-08 20:27 GMT-07:00 Alex Walters : > Why not... > > cool_namespace = SomeNamespaceContextManager() > > with cool_namespace: > def foo(): > pass > > advantage being it introduces no new keyword. The 'disadvantage' is it > would change semantics of the with statement (as would

[Python-ideas] Fwd: Pattern Matching Syntax

2018-05-11 Thread Jelle Zijlstra
2018-05-11 22:01 GMT-04:00 Robert Roskam : > Hey Steven, > > I'm also at PyCon. Shall we take this off list and attempt to meet up and > discuss? > > I'm also at PyCon and interested in meeting about this. I just wrote up a basic and incomplete implementation for

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Jelle Zijlstra
2018-03-02 7:03 GMT-08:00 Robert Vanden Eynde : > +1 on extracting the big win for "if" and "while" (the regex case is > wonderul). It would be see as an "extended if/while" rather than a general > statement assignation. > > I wonder if we could have a more limited change to

Re: [Python-ideas] Ternary operators in list comprehensions

2017-10-05 Thread Jelle Zijlstra
[x if x & 1 else 'even' for x in a] An `if` at the end of the comprehension means a condition on whether to include the value. Also, this question would have been better asked on python-list. 2017-10-05 8:40 GMT-07:00 Jason H : > >>> a = [1,2,3] > >>> [ x for x in a if x & 1] >

Re: [Python-ideas] PEP 563 and expensive backwards compatibility

2017-09-13 Thread Jelle Zijlstra
2017-09-13 13:01 GMT-07:00 Jim J. Jewett : > On Wed, Sep 13, 2017 at 3:12 PM, Lukasz Langa wrote: > > On Sep 13, 2017, at 2:56 PM, Jim J. Jewett wrote: > > >> I am generally supportive of leaving the type annotations > >> unprocessed

Re: [Python-ideas] PEP 561: Distributing and Packaging Type Information

2017-09-10 Thread Jelle Zijlstra
2017-09-10 18:10 GMT-07:00 Ethan Smith <et...@ethanhs.me>: > > > On Sun, Sep 10, 2017 at 5:39 PM, Jelle Zijlstra <jelle.zijls...@gmail.com> > wrote: > >> Congratulations on your first PEP! This is solving an important problem >> for typing in Python, so I'

Re: [Python-ideas] PEP 561: Distributing and Packaging Type Information

2017-09-10 Thread Jelle Zijlstra
Congratulations on your first PEP! This is solving an important problem for typing in Python, so I'm glad we're tackling it. 2017-09-10 16:05 GMT-07:00 Ethan Smith : > Hello, > > I have just published my first PEP, on packaging type information. I would > appreciate comments

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Jelle Zijlstra
2017-08-16 10:37 GMT+02:00 Nathaniel Smith <n...@pobox.com>: > On Tue, Aug 15, 2017 at 11:53 PM, Jelle Zijlstra > <jelle.zijls...@gmail.com> wrote: > > Minor suggestion: Could we allow something like > > `sys.set_new_context_item(description='mylib.context', > >

Re: [Python-ideas] PEP 550 v2

2017-08-16 Thread Jelle Zijlstra
2017-08-16 1:55 GMT+02:00 Yury Selivanov : > Hi, > > Here's the PEP 550 version 2. Thanks to a very active and insightful > discussion here on Python-ideas, we've discovered a number of > problems with the first version of the PEP. This version is a complete > rewrite

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-11 Thread Jelle Zijlstra
This is exciting and I'm happy that you're addressing this problem. We've solved a similar problem in our asynchronous programming framework, asynq. Our solution (implemented at https://github.com/quora/asynq/blob/master/asynq/contexts.py) is similar to that in PEP 521: we enhance the context

Re: [Python-ideas] Idea : for smarter assignment?

2017-07-21 Thread Jelle Zijlstra
2017-07-21 10:07 GMT-07:00 Jason H : > I experimented with Python in college and I've been for close to 20 years > now. (Coming and going as needed) I love the language. But there is one > annoyance that I continually run into. > > There are basically two assignment operators,

Re: [Python-ideas] Exploiting type-homogeneity in list.sort() (again!)

2017-03-05 Thread Jelle Zijlstra
2017-03-05 22:08 GMT-08:00 Elliot Gorokhovsky : > Another solution: check if there is more than one thread; if there is, then > disable optimization. Is sorting in multithreaded programs common enough to > warrant adding the complexity to deal with it? > I think

Re: [Python-ideas] add __contains__ into the "type" object

2017-02-28 Thread Jelle Zijlstra
2017-02-28 15:12 GMT-08:00 Steven D'Aprano : > On Wed, Mar 01, 2017 at 07:02:23AM +0800, 语言破碎处 wrote: >> >> where we use types? >> almost: >> isinstance(obj, T); >> # issubclass(S, T); >> >> Note that TYPE is SET; > > What does that mean? I don't

Re: [Python-ideas] Python dependancies

2017-01-15 Thread Jelle Zijlstra
2017-01-14 21:24 GMT-08:00 Mathieu TORTUYAUX : > Hello everyone, > > I'm used to work with python and contribute to open-source projects. And > now, many projects need to run with dependancies. So I wondering, if it > could be a good idea to integrate a sniffer into

[Python-ideas] api suggestions for the cProfile module

2017-01-10 Thread Jelle Zijlstra
2017-01-10 8:57 GMT-08:00 Ethan Furman : > On 01/10/2017 08:36 AM, Thane Brimhall wrote: > > Does anyone have thoughts on this topic? I assume the silence is because >> this suggestion is too trivial to matter. >> > > Sometimes it's just a matter of timing. :) > > I use

Re: [Python-ideas] Add optional defaults to namedtuple

2016-12-01 Thread Jelle Zijlstra
2016-11-30 8:11 GMT-08:00 Guido van Rossum : > On Wed, Nov 30, 2016 at 7:09 AM, Ethan Furman wrote: > >> On 11/30/2016 02:32 AM, Jelte Fennema wrote: >> >> It would be nice to have a supported way to add defaults to namedtuple, >>> so the slightly hacky