On Mon, Nov 18, 2019, at 13:00, Andrew Barnert via Python-ideas wrote: > def f(a, b): return a**(b+1) > g = partial(f, b==2) > h = lambda x: f(x, 2) > > Python can’t tell the difference between f, g, and h; they’re all > variables. An IDE could keep track of the fact that f was bound by a > def statement, and g and h by assignment. But I’m not sure why you’d > want it to. After all, they’re all variables with callable values. Why > should f(2,3) be colored differently from g(4)?
I think, more or less, "a function" can be regarded as "a *constant* whose value is callable and is not type-like" [where type-like includes types, abstract base classes, and type hint objects], regardless of how it was obtained. Opinions may differ on whether "real variables" [either locals, or globals whose values actually do vary] and/or parameters of callable types (or type-like types) should or should not be highlighted the same way as a typical non-callable variable. Highlighting these would in any case require an editor with a deep understanding of the language (far beyond the typical regex-based syntax highlighters) and probably type annotated code, but that doesn't mean it wouldn't be useful. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/Z7RXQVAZZLTEWJUW7XRX4OC6WH2NDP7A/ Code of Conduct: http://python.org/psf/codeofconduct/