When

from __future__ import runtime_default_kwargs


Is run, 

def a(b=1, c=b+2, d=[]):
    pass

behaves as (if the peephole optimizer didn’t exist)

def a(b=None, c=None):
    if b is None:
        b = 1
    if c is None:
        c = b + 2
    if d is None:
        d = []

i.e. the keyword expression is evaluated at runtime.

Perhaps a restriction on “literals only” can be made so people don’t abuse this.
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to