我有一个元组x = (2,),我想添加一个变量y.我事先并不知道究竟是什么样的变量y.
y 可能:
x+y,或者x+(y,).采用一种策略会在一半的时间内给我一个TypeError,而采用另一种策略会(2, (3, 4))在我想要的时候给我(2, 3, 4).
处理这个问题的最佳方法是什么?
我正在实现一个事件结构,以将信息从View传递给Presenter.在视图中,单击按钮时会调用以下代码:
private void alterCmpd1()
{
EventHandler AlterEvent = AlterCompound1_Action;
if (AlterEvent != null) AlterEvent(this, EventArgs.Empty);
}
public event EventHandler AlterCompound1_Action;
Run Code Online (Sandbox Code Playgroud)
出于某种原因,NotImplementedException总是出现在:
AlertEvent(this, EventArgs.Empty);
Run Code Online (Sandbox Code Playgroud)
有人可以帮我找出原因吗?
来自Presenter类的代码:
public MainPresenter(IMainView view, IModel model)
{
this.view = view;
this.view.AlterCompound1_Action += new EventHandler(view_AlterCompound1);
this.model = model;
view.Show();
}
void view_AlterCompound1(object sender, EventArgs e)
{
// I commented out this code, on the off
// chance that it was affecting things. Still no luck.
}
Run Code Online (Sandbox Code Playgroud) Python 中的评估有多懒惰?如果我的代码看起来像
logging.debug('My very long list: %s' % list(x for x in long_generator))
并且日志记录有效级别使得调试消息被忽略,我是否会因使用此行而导致性能损失?