Hi,

On 1 March 2017 at 01:12, 语言破碎处 <mlet_it_...@126.com> wrote:
>
> How a function refer itself?
>     def f():
>         f() # fine... really???

I understand your question as the following: "Should functions be
allowed to point to themselves/the as of construction time unbound
variable in the function body, as they are not yet bound to a variable
at construction time"

I think they should be allowed, as only when the function is executed
the variable lookups (and therefore function lookups) should happen.
Object.function() would have, well, interesting behaviour if you were
to pre-insert all function calls in the code:

  d = {'hello': 'world'}
  def f():
    d.keys = lambda: {}
    print(d.keys())

would result in "['keys']" being printed, while you explicitly said
that the keys method on variable d has to return an empty dict.

I hope this helps you with your question.

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