当我在repl.it网站上的Haskell的交互式shell中键入以下内容时,它完美地运行.
let squareMe x = x * x
let myFruit = ["banana", "apple", "kiwi", "orange"]
Run Code Online (Sandbox Code Playgroud)
但是,当我将其键入源文件并单击"运行"时,我收到错误:
<interactive>:3:1: error:
• Variable not in scope: main
• Perhaps you meant ‘min’ (imported from Prelude)
Run Code Online (Sandbox Code Playgroud)
我一直在努力理解这个错误,并提出了几个小时的解决方案,并且不再寻找解决方案或理解错误意味着什么.
我正在尝试编写一个通用测试脚本来查找新软件版本中的错误。我的想法是迭代窗口中的控件并与每个控件进行交互,记录引起的任何错误,并在软件崩溃时重新启动软件。
我正在寻找一种动态查找控件标识符的方法,有点像print_control_identifiers()但输出是一个列表或类似的结构,我可以对其进行迭代。
在关于控件标识符的GitHub 问题上提到了这一点:
可以通过使用
.children()(仅直接子级)和.descendants()(整个子树作为普通列表)来遍历层次结构
我假设我可以迭代Application对象的descendants()列表并为每个对象调用相关的交互方法,但是我不知道如何获取此列表。我以为我可以做这样的事情,但我没有取得任何成功:
def test(application):
for child in application.descendants():
#interact with child control
software = Application(backend='uia').start(cmd_line=FILE_PATH)
test(software)
Run Code Online (Sandbox Code Playgroud)
AttributeError:既没有找到 GUI 元素(包装器)也没有找到包装器方法“后代”(拼写错误?)
编辑
我通过查看代码找到了print_control_identifiers方法:
class Application(object):
def print_control_identifiers(self, depth=None, filename=None):
"""
Prints the 'identifiers'
Prints identifiers for the control and for its descendants to
a depth of **depth** (the whole subtree if **None**).
.. note:: The identifiers printed by this method have been …Run Code Online (Sandbox Code Playgroud) 我刚刚在这里检查以确保这个问题是允许的,而且似乎就是这样,我走了:
我目前正在将2D物理引擎作为一个小项目.我有一个叫做circle半径,旋转,位置和速度等属性的类:
class circle():
def __init__(self, radius = 10, r = 0.0, x = 0, y = 0, Vr = 0, Vx = 0, Vy = 0):
self.radius = radius
self.r = r
self.x = x
self.y = y
self.Vr = Vr
self.Vx = Vx
self.Vy = Vy
Run Code Online (Sandbox Code Playgroud)
该类有一个名为的方法CheckCollisions(),用于检查其中心与另一个圆的中心之间的距离是否小于其半径的总和:
def CheckCollisions(self):
for c in circles:
distance = math.sqrt((c.x - self.x)*(c.x - self.x) + (c.y - self.y)*(c.y - self.y))
if distance < self.radius + c.radius: …Run Code Online (Sandbox Code Playgroud)