Any only works as an annotation:
In [3]: def fn(*argv: Any) -> Any: ...: return argv[0] ...:
From: Paul Bryan pbryan@anode.ca Sent: 30 November 2020 05:55 To: Inada Naoki songofacandy@gmail.com; Abdulla Al Kathiri alkathiri.abdulla@gmail.com Cc: python-ideas python-ideas@python.org Subject: [Python-ideas] Re: Making "Any" a builtin
pbryan@dynamomailto:pbryan@dynamo:~$ python3
Python 3.8.6 (default, Sep 30 2020, 04:00:38)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
from __future__ import annotations
Any
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'Any' is not defined
On Mon, 2020-11-30 at 14:43 +0900, Inada Naoki wrote: Since Python 3.10, you can use "Any" without "from typing import Any". You can do it in Python 3.7 by "from __future__ import annotations" too.
See https://www.python.org/dev/peps/pep-0563/https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.python.org%2Fdev%2Fpeps%2Fpep-0563%2F&data=04%7C01%7C%7Cf27001db4fda41a8422008d894f63854%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637423132705057013%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=QKqmO0f%2BLE040QGySslUfYKGGjyVPIbqVndWLwLHEe4%3D&reserved=0
Regards,
On Mon, Nov 30, 2020 at 12:29 AM Abdulla Al Kathiri <alkathiri.abdulla@gmail.commailto:alkathiri.abdulla@gmail.com> wrote:
Instead of importing “Any" from the typing module, we can annotate our functions with “Any" right away without the extra step. What do you think? We have the builtin function “any” which some Python users could mistakingly use, but static type checkers should catch that. _______________________________________________ Python-ideas mailing list -- python-ideas@python.orgmailto:python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.orgmailto:python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman3%2Flists%2Fpython-ideas.python.org%2F&data=04%7C01%7C%7Cf27001db4fda41a8422008d894f63854%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637423132705057013%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=H%2BrsVsj%2BgLzD0JEROxT8tZb%2Bgn6zua0Hc%2BBCsm%2Fo%2FE4%3D&reserved=0 Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/ELI474...https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Farchives%2Flist%2Fpython-ideas%40python.org%2Fmessage%2FELI474TKP2OKHP4NW5HOVUPKDPLYE2JP%2F&data=04%7C01%7C%7Cf27001db4fda41a8422008d894f63854%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637423132705057013%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=fTeCdpijNUBREFSHnA%2FYqD0dkEUq0g48xVHjiYCUMHc%3D&reserved=0 Code of Conduct: http://python.org/psf/codeofconduct/https://eur05.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpython.org%2Fpsf%2Fcodeofconduct%2F&data=04%7C01%7C%7Cf27001db4fda41a8422008d894f63854%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637423132705067008%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=FHpZxOJuTA6gUkhUqwkbtZP05jBTrRliCDAG%2BfOzwyo%3D&reserved=0
-- Inada Naoki <songofacandy@gmail.commailto:songofacandy@gmail.com> _______________________________________________ Python-ideas mailing list -- python-ideas@python.orgmailto:python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.orgmailto:python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman3%2Flists%2Fpython-ideas.python.org%2F&data=04%7C01%7C%7Cf27001db4fda41a8422008d894f63854%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637423132705067008%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=gBFYebL5JU%2BF0R1xo4c1Ynn6WbX0CiJtgFsomRFkLcg%3D&reserved=0 Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/VENGRL...https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Farchives%2Flist%2Fpython-ideas%40python.org%2Fmessage%2FVENGRL6T54XQUYDXONZRZE7LUCO6MKWI%2F&data=04%7C01%7C%7Cf27001db4fda41a8422008d894f63854%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637423132705077002%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=iCFcrLAsqsph9RfW%2BcybewCKo76feAs6Y0haKRmi6%2FY%3D&reserved=0 Code of Conduct: http://python.org/psf/codeofconduct/https://eur05.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpython.org%2Fpsf%2Fcodeofconduct%2F&data=04%7C01%7C%7Cf27001db4fda41a8422008d894f63854%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637423132705077002%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=%2F7zbYkgPIZg1rpyFnSbRjyk5%2Fxyv0ByZPD6MUstQ6EM%3D&reserved=0