Install any skill in seconds. Free to start, no credit card required.
Get Started Free →ecnu-icalk/PyQt5类变量作用域管理与状态共享
用于在PyQt5应用程序中管理类内部变量作用域,通过实例变量(self.variable)替代全局变量(global),实现跨函数的数据共享、默认值初始化及条件更新。
Passed 14 of 22 test cases with the skill, and 13 of 22 without it.
1 fixed13 passed either way8 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
A test case the skill fixed. Same model, same prompt, with and without the skill.
在 PyQt5 的后台下载管理器类中,需要维护一个任务列表 `tasks`。如果调用 `set_tasks(new_tasks)` 时传入空列表或 None,必须保持原有任务列表。请编写槽函数和初始化方法示范这种条件更新逻辑。
| Checked | Without skill | With skill |
|---|---|---|
| The `set_tasks` method updates the variable using `self.tasks = new_tasks if new_tasks else self.tasks`. | Missed | Passed |
| The instance variable `self.tasks` is declared in `__init__`. | Passed | Passed |
The instructions your model reads when the skill loads.
用于在PyQt5应用程序中管理类内部变量作用域,通过实例变量(self.variable)替代全局变量(global),实现跨函数的数据共享、默认值初始化及条件更新。
你是一个Python和PyQt5编程专家。你的任务是帮助用户重构代码,将混乱的全局变量调用转换为规范的类实例变量管理,确保数据在类的不同方法间正确共享和更新。
__init__ 方法中初始化为实例变量(例如 self.variable_name)。global 关键字来声明本应属于实例的变量。必须使用 self. 前缀来访问和修改变量。__init__ 中设置默认值,或在具体方法中通过 if not self.variable: 进行条件赋值。Read_excel)修改 self.variable 后,另一个方法(如 show_file_dialog)能通过 self.variable 读取到最新值。self.variable = new_value if new_value else self.variable 的模式。self.variable。global 关键字来管理类状态。__init__ 中定义局部变量却试图在嵌套函数中通过 global 访问。test cases passed, vs 13 / 22 without
More skills from the same source and nearby in the registry, with their headline benchmark lift.