![](https://img.haomeiwen.com/i1203902/04b1e1d7b26e416e.jpg)
一只猫被关在密闭的盒子内,猫的生死由盒子内的铀元素决定。假如盒子内的铀元素发生了衰变,那么这只猫会因铀元素在衰变过程中产生的某些元素丧命;假如铀元素没有发生衰变,那么这只猫便是活的。
由于无法准确知道猫在某时刻的死活,所以可以认为盒子里的猫是既死又活状态。我大脑说,您有事儿说事儿,别折腾我脑细胞啊!
幸运得是量子力学与编程没啥关系,我一直这么以为,直到接触了许多脚本语言,看到那些朴实无华的多类型用于同一变量,大脑有点空,感觉可能子弹多飞了一会儿,前脑门到后脑勺空出个天井,采光特别好,还跟老师抽我回答不会的问题一样亲切。
俗话说得好,营养都在汤里面,感情都在酒里面,而一切都在代码里面,但是吧,我就觉得有时候,我也在代码里面,不仅在里面,还想起一首诗,不识庐山真面目,只缘身在此山中,好诗就是这样,随着你年龄经历增长,会对它有更多不同见解,可谓历久弥新。
a = 10
a = [a]
a = a + [1]
a = ",".join(map(lambda x: str(x), a))
a = int(a[-1])
...
这段代码,会不会觉得丝滑,如果要在中间加一句判断当前 a 取值是否有效,会不会既丝滑又丰富,再比如这个 a 它儿孙满堂,项目里到处都有它的身影,会不会是丝滑又丰富又多彩,大脑被开发出11维般的壮观也不过尔尔。
(.venv) [brain@heaven code]$ mypy a.py
a.py:2: error: Incompatible types in assignment (expression has type "List[int]", variable has type "int")
a.py:3: error: Unsupported operand types for + ("int" and "List[int]")
a.py:4: error: Incompatible types in assignment (expression has type "str", variable has type "int")
a.py:4: error: No overload variant of "map" matches argument types "Callable[[Any], str]", "int"
a.py:4: note: Possible overload variants:
a.py:4: note: def [_S, _T1] __init__(self, Callable[[_T1], _S], Iterable[_T1]) -> map[_S]
a.py:4: note: def [_S, _T1, _T2] __init__(self, Callable[[_T1, _T2], _S], Iterable[_T1], Iterable[_T2]) -> map[_S]
a.py:4: note: def [_S, _T1, _T2, _T3] __init__(self, Callable[[_T1, _T2, _T3], _S], Iterable[_T1], Iterable[_T2], Iterable[_T3]) -> map[_S]
a.py:4: note: def [_S, _T1, _T2, _T3, _T4] __init__(self, Callable[[_T1, _T2, _T3, _T4], _S], Iterable[_T1], Iterable[_T2], Iterable[_T3], Iterable[_T4]) -> map[_S]
a.py:4: note: def [_S, _T1, _T2, _T3, _T4, _T5] __init__(self, Callable[[_T1, _T2, _T3, _T4, _T5], _S], Iterable[_T1], Iterable[_T2], Iterable[_T3], Iterable[_T4], Iterable[_T5]) -> map[_S]
a.py:4: note: def [_S] __init__(self, Callable[..., _S], Iterable[Any], Iterable[Any], Iterable[Any], Iterable[Any], Iterable[Any], Iterable[Any], *iterables: Iterable[Any]) -> map[_S]
a.py:5: error: Value of type "int" is not indexable
Found 5 errors in 1 file (checked 1 source file)
代码和作者本来就是天作之合,哪里轮到你这个 mypy 出来反对,难道你不觉得,这种无与伦比的大脑竞技可以被称作艺术,当你为此陷入深思,就如同其他脑力游戏一样,这不和迷宫、围棋一样,为啥有人会如此不解风情。
一千个读者眼中就会有一千个哈姆雷特,我总觉得让这一千人住一起有点逼仄,要说宽敞还得是大项目,最起码也得是1000号人一起开发的项目,每个哈姆都住个单间。一般的小项目太适合,在里头不光哈姆雷特憋屈,就连制造哈姆雷特的制造者也会不愉悦。总之,要不是觉得项目开发过于简单,生活单调缺乏调剂,我还是推荐不碰量子物理,毕竟背负着星辰大海,得多上网跟人布道才是,讲究地就是个传承。
以上是患者编号49021的日记,精神病院主治医师齐天圣收录于2020年3月
备注:患者喜欢用别人不太理解的方式记录内心感受,总觉得自己是个作家,暗示隐喻是他的陈述习惯,也凸显其唯唯诺诺地性格,精神上看似没有太大问题,像个社畜,但仔细观察时,我发现他力比多分泌旺盛,不排除有长期服用兴奋类药品,不过也可能只是个天顶星人,此处存疑,有待进一步观察。
网友评论