通用问题:
我有一个装饰器@some_package.decorator
期望函数包装为返回类型T
。
### runs
@some_package.decorator
def my_func(param) -> int:
return len(param)
### I also want to be able to wrap an async function
@some_package.decorator
async def my_func(param):
await asyncio.sleep(1)
return len(param)
Run Code Online (Sandbox Code Playgroud)
然而,该函数可以是sync
or async
,因此可能返回coroutine[Any]
。
我怎样才能使装饰器await
具有功能
我的具体用例:我有一些代码在以下情况下运行良好sync=True
import uplink
class MyAPI(Consumer):
def __init__(
self,
password: str,
sync: bool = True,
auto_auth: bool = True,
**kwargs
):
self.sync = sync
self.client = None
if not self.sync:
self.client = AiohttpClient()
# initialise …
Run Code Online (Sandbox Code Playgroud) 谁能给我一个方法在Seaborn 做一个qq情节作为数据正常性的测试?或者失败,至少在matplotlib中.
提前致谢
因此,我计划使用 Jupyter notbook (Python 3) 进行一些数据分析,出于协作原因,我想将数据存储在 github 存储库中,但是数据集很敏感。
因此,我想将数据(当前为 .csv)作为加密文件存储在 repo 上,然后在运行时对其进行解密(我猜是密码提示)。
执行此操作的最佳方法是什么?
python-3.x ×2
api ×1
async-await ×1
csv ×1
encryption ×1
git ×1
matplotlib ×1
python ×1
scipy ×1
seaborn ×1