5 ms·
> pattern matching expressions Available in 3.10: https://peps.python.org/pep-0636/ https://peps.python.org/pep-0636/ > syntax for partial application...
by ok_dad 5y ago
> pattern matching expressions
Available in 3.10: https://peps.python.org/pep-0636/ https://peps.python.org/pep-0636/
> syntax for partial application...
from functools import partial
somefunc_arg1_arg2 = partial(somefunc, arg1, arg2)
> ...and composition
A native compositional syntax would be nice.
> a typing system which can express structural types
# mypy will typecheck this code and see `MyString()` has a `.read()` method, so it's a `Readable` even though it doesn't sub-class `Readable`
from typing import Any, Protocol
class Readable(Protocol):
def read(self) -> Any: ...
def read_something(something: Readable) -> Any:
return something.read()
class MyString:
a_string: str = "something"
def read(self) -> str:
return self.a_string
read_something(MyString())
> a generalised list comprehension
I agree this would be nice.
- mjburgess 5y agothey arent expressions, defeating the whole point that isnt syntax for partial appication, and the protocol system for structrural typing is syntactically and practically absurd the question is "why do data processing libs in python look syntactically illegible" and the answer is largely, as youve posted above, that python doesnt support useful syntax