Python版本:3.11
通过安装应用程序的依赖项pip install -r requirements.txt会出现以下错误:
socket.c -o build/temp.linux-armv8l-cpython-311/aiohttp/_websocket.o
aiohttp/_websocket.c:198:12: fatal error: 'longintrepr.h' file not found
#include "longintrepr.h"
^~~~~~~ 1 error generated.
error: command '/data/data/com.termux/files/usr/bin/arm-linux-androideabi-clang'
failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for aiohttp
Failed to build aiohttp
ERROR: Could not build wheels for aiohttp, which is required to install
pyproject.toml-based projects
Run Code Online (Sandbox Code Playgroud)
此错误特定于 Python3.11版本。在 Python 上,3.10.6 …
我想限制可以作为参数传递给另一个函数的函数的范围。例如,将函数限制为仅两个指定的函数之一,或来自特定模块,或通过签名。我尝试了下面的代码,但其中现在有限制:因为参数可以传递任何函数。
这在Python中可能吗?
def func_as_param():
print("func_as_param called")
def other_func():
print("other_func called")
def func_with_func_arg(func: func_as_param): # this is not giving restrictions
# def func_with_func_arg(func: type(func_as_param)): # this is also not giving restrictions
print("func_with_func_arg called")
func()
def test_func_with_func_arg():
print("test_func_with_func_arg")
func_with_func_arg(func_as_param)
func_with_func_arg(other_func) # <- here IDE must complain that only func_as_param is expected
Run Code Online (Sandbox Code Playgroud)