[Python-ideas] Re: Variadic generics PEP draft

2020-11-28 Thread David Foster
the same thing.) I was thinking "TypeVarList" originally, but I also like "TypeListVar". -- David Foster | Seattle, WA, USA Contributor to TypedDict support for mypy ___ Python-ideas mailing list -- python-ideas@python.org To unsubscr

[Python-ideas] Re: async types?

2020-11-28 Thread David Foster
`AsyncType`, the __new__ and __init__ methods must be async methods (returning coroutines). I like the idea in principle but I don't currently use any async libraries so my opinion may not count much here. ;) -- David Foster | Seattle, WA, USA ___ P

[Python-ideas] Re: Alternative to Callable Annotation

2020-11-28 Thread David Foster
20 10:02 AM, Abdulla Al Kathiri wrote: > Regardless of how it’s done, the less we depend on the typing module for > annotations, the better I think because it encourages python users to > annotate their functions. Indeed. (+1) -- David Foster | Seattle, WA, USA __

[Python-ideas] Re: Matching TypedDicts and other values in JSON

2020-11-23 Thread David Foster
a `type`, otherwise None.""" raise NotImplementedError() Now, I'm not sure if mypy can handle that kind of recursive TypedDict definition :), but it *will* work at runtime. I'll see about implementing a function like try_cast() as a separate package. This should be f

[Python-ideas] Matching TypedDicts and other values in JSON

2020-11-21 Thread David Foster
work if isinstance() was defined for: * Union[T1, T2], Optional[T] * T extends TypedDict * Literal['foo'] For arbitrary JSON beyond the example, we'd also want to support isinstance() for: * List[T] We already support isinstance() for the other JSON primitive types:

[Python-ideas] Re: PEP 634-636: Mapping patterns and extra keys

2020-11-21 Thread David Foster
On 11/19/20 10:08 PM, David Foster wrote: I've completed my survey of how other languages use pattern matching to match Mapping-like and dict-like types, especially focusing on whether they ignore (𝔸) or disallow (𝔹) extra keys by default. [...] To close the loop on this thread: * Bas

[Python-ideas] Re: PEP 634-636: Mapping patterns and extra keys

2020-11-19 Thread David Foster
t) 𝔸† * PHP βœ–οΈ * Lua βœ–οΈ * Python (current draft of PEP 634-636) 𝔸† Statically-typed languages: * OCaml πŸ€·β€β™€οΈ * Scala πŸ€·β€β™€οΈ * Swift πŸ€·β€β™€οΈ * Rust πŸ€·β€β™€οΈ * Haskell πŸ€·β€β™€οΈ * C++ πŸ€·β€β™€οΈ

[Python-ideas] Re: PEP 634-636: Mapping patterns and extra keys

2020-11-17 Thread David Foster
hoice? - which languages ignore extra keys? do users of those languages consider this feature a bug, a wart, or a feature? If useful I can volunteer to conduct such a survey. I expect to have some cycles this coming weekend. -- David Foster | Seattle, WA, USA Contributor to TypedDict support for

[Python-ideas] Re: PEP 634-636: Mapping patterns and extra keys

2020-11-14 Thread David Foster
ing tends to default to stricter matching. :) -- David Foster | Seattle, WA, USA Contributor to TypedDict support for mypy ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.

[Python-ideas] PEP 634-636: Mapping patterns and extra keys

2020-11-14 Thread David Foster
#x27;TodoItem_ReadWrite', {'title': str, 'completed': bool, 'extra': Dict[str, Any]}) def parse_todo_item(todo_item_json: Dict) -> TodoItem_ReadWrite: match todo_item_json: case {'title

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-04 Thread David Foster
proposed to accept such a broader second argument.) David Foster | Seattle, WA, USA On 3/1/19 8:26 AM, Steven D'Aprano wrote: Attached is a draft PEP on adding + and - operators to dict for discussion. This should probably go here: https://github.com/python/peps but due to technical difficu

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-08-02 Thread David Foster
t from "or". Reads the same out loud despite being a different operator. * -1 for "||" with none-aware semantics. This differs from the semantics in every C-derived language I can think of, which will be confusing to several other developers. David Foster | Seattle, WA, USA

Re: [Python-ideas] The future of Python parallelism. The GIL. Subinterpreters. Actors.

2018-07-10 Thread David Foster
st is: https://mail.python.org/pipermail/python-ideas/2015-September/035725.html David Foster | Seattle, WA, USA On 7/9/18 9:17 AM, Trent Nelson wrote: On Sun, Jul 08, 2018 at 11:27:08AM -0700, David Foster wrote: I'd like to solicit some feedback on what might be the most efficient way to

[Python-ideas] The future of Python parallelism. The GIL. Subinterpreters. Actors.

2018-07-08 Thread David Foster
I could do this by using an existing library like Pykka or Thespian and extending it where necessary. Thoughts? [PEP 554]: https://www.python.org/dev/peps/pep-0554/ -- David Foster | Seattle, WA, USA ___ Python-ideas mailing list Python-ideas@python.org

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

2018-03-17 Thread David Foster
the expression_list is a slice expression, which would be even more bizarre code. Best to make bizarre cases into errors. Cheers, -- David Foster | Seattle, WA, USA On Sat, Mar 17, 2018 at 12:13 AM, Chris Angelico wrote: > On Sat, Mar 17, 2018 at 5:49 PM, David Foster wrote: > > (3a)

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

2018-03-16 Thread David Foster
eliminate unintentional errors. (3b) With a local scope (in proposal #2 above), a named expression simply replaces any preexisting local with the same name. (Or it would replace the global/nonlocal if a global/nonlocal statement was in use.) There is no shadowing per-se. Cheers, -- David Foster | Sea

Re: [Python-ideas] Coming up with an alternative to PEP 505's None-aware operators

2018-02-19 Thread David Foster
r than (?it=) since I find it reads nicer. Also is consistent with existing syntax (with expr as var). Cheers, David -- David Foster | Seattle, WA, USA On 2/15/18 6:06 PM, Nick Coghlan wrote: The recent thread on variable assignment in comprehensions has prompted me to finally sha