[Python-ideas] from __future__ import runtime_default_kwargs
James Lu
jamtlu at gmail.com
Sun Mar 10 23:48:59 EDT 2019
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190310/93eea470/attachment.html>
More information about the Python-ideas
mailing list