我正在查询模型的ID,并获取(int,)元组列表而不是id列表.有没有办法直接查询属性?
result = session.query(MyModel.id).all()
Run Code Online (Sandbox Code Playgroud)
我意识到这是可能的
results = [r for (r,) in results]
Run Code Online (Sandbox Code Playgroud)
查询是否可以直接返回该表单,而不必自己处理它?
有没有什么方法可以在后代类构造函数的末尾调用超级构造函数?
它适用于Java,但在C#中,关键字base似乎不等同于Java的超级.
例:
class CommonChest : BasicKeyChest
{
public CommonChest()
{
Random rnd = new Random();
int key = rnd.Next(1, 6);
int coins = rnd.Next(70, 121);
super(key, coins, "Common");
}
}
Run Code Online (Sandbox Code Playgroud) 我的 mypy 有问题
我有这样的代码:
func(arg1, arg2, arg3=0.0, arg4=0.0)
# type: (float, float, float, float) -> float
# do something and return float.
dict_with_other_arguments = {arg3: 0.5, arg4: 1.4}
a = func(arg1, arg2, **dict_with_other_arguments)
Run Code Online (Sandbox Code Playgroud)
问题是 mypy 不检查字典中的类型,而是我得到如下错误: error: Argument 3 to "func" has incompatible type "**Dict[str, float]"; 预期的“浮动”
任何想法如何在不更改代码的情况下解决此问题?