On Mon, Mar 11, 2019 at 10:28 PM James Lu <jam...@gmail.com> wrote:
>
> 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.

A future directive is appropriate only if the language is planned to
be changed. Is that what you're actually asking for? If so, ask for
that (and then the future directive becomes a transition tool).

As an alternative, consider tagging the specific function, not the
whole module (future directives always apply to the entire module).
The best way to tag a function would probably be a decorator.

ChrisA
_______________________________________________
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