From ce93353c7b91a1d5c40cde877b5483a4c389ff1f Mon Sep 17 00:00:00 2001 From: Goodenough <2381642961@qq.com> Date: Sun, 16 Jul 2023 06:11:55 +0000 Subject: [PATCH 1/2] add python/typehint.py. Signed-off-by: Goodenough <2381642961@qq.com> --- python/typehint.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 python/typehint.py diff --git a/python/typehint.py b/python/typehint.py new file mode 100644 index 0000000..1e54bc1 --- /dev/null +++ b/python/typehint.py @@ -0,0 +1,17 @@ +""" +这是以前碰到的一个神奇的问题抽象出来的demo,现在也不是很清楚为什么 +下面给出来的代码是可以跑的 +然而一旦把a=1换为注释的那段代码就会报SyntaxError +仅仅只是加了一个type hint而已啊 +离谱 +""" + +a = None + +def global_init(): + global a + a = 1 + #a:int = 1 + +global_init() +print(a) \ No newline at end of file -- Gitee From 5a13997f33d20bb647e51b028748eccc5a3c2eab Mon Sep 17 00:00:00 2001 From: Goodenough <2381642961@qq.com> Date: Sun, 16 Jul 2023 06:14:06 +0000 Subject: [PATCH 2/2] update python/typehint.py. Signed-off-by: Goodenough <2381642961@qq.com> --- python/typehint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/typehint.py b/python/typehint.py index 1e54bc1..d34ad98 100644 --- a/python/typehint.py +++ b/python/typehint.py @@ -9,7 +9,7 @@ a = None def global_init(): - global a + global a a = 1 #a:int = 1 -- Gitee