Spyke
jlai.lu

This is the way you're supposed to write it in Python.

It is something you get used to, yet I think it's sad.

4
m_‮freply
discuss.online

You can use mutable default arguments now with a new syntax:

https://peps.python.org/pep-0671/

def bisect_right(a, x, lo=0, hi=>len(a), *, key=None):
def connect(timeout=>default_timeout):
def add_item(item, target=>[]):
def format_time(fmt, time_t=>time.time()):
5

Oh wow! This would be great I really hope it's accepted and implemented, makes a lot of sense!

4
Narannreply
jlai.lu

Does not seems to work on 3.12:

Python 3.12.11 (main, Jun 29 2025, 16:18:35) [MSC v.1944 64 bit (AMD64)] on win32
>>> def toto(tata=>[]):
  File "<stdin>", line 1
    def toto(tata=>[]):
                  ^
SyntaxError: invalid syntax
3

Upvote for the sanity check.

As the OP mentioned, this is a proposed/draft feature that may or may not ever happen.

With these kinda posts, should start a betting pool. To put money down on whether this feature sees the light of day within an agreed upon fixed time frame.

2

You reached the end

Avoiding boilerplate by using immutable default arguments | Spyke