Following on from PEP 634, it would be good to be able to have Erlang /
Elixir-style pattern matching in function headers.

(I don't know what the technical term is for this language feature, but
hopefully the examples will clarify.)

Here's the obligatory fibonacci example:

```
def fib(0):
    return 0

def fib(1):
    return 1

def fib(n):
    return fib(n-1) + fib(n-2)
```

Or, another example:

```
def allow_entry({"name": "Bob"}):
    return "Bob is not allowed in ever!"

def allow_entry({"name": "Charles", "day": "Tuesday"}):
    return "It's a Tuesday, so Charles is allowed in."

def allow_entry({"name": "Charles", "day": _}):
    return "Charles is only allowed in on a Tuesday."

def allow_entry({"name": name}):
    return f"Come in {name}, make yourself at home!"
```

Thanks for considering my idea.

Kind regards

Sam Frances
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/OPLBLWJPCN66QRUQNHBQSQOBNBFZRRBF/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to