小编Dou*_*oug的帖子

你如何透明地将参数传递给python中的函数?

具体来说,当你有一个函数调用另一个函数,但第二个函数的签名是未知的.

我知道你可以使用*args和**kwargs来做类似的事情,但我似乎无法以一种始终有效的方式得到它.

例如,像这样的东西几乎可以工作:

class Invoker():
  def __init__(self, call):
    self._call = call
  def call(self, *args, **kwargs):
    self._call(*args, **kwargs)
Run Code Online (Sandbox Code Playgroud)

..但如果我为它编写一些测试,我得到这个输出:

1 -> 2  ('Hello')
1 -> 2  ((3, 'Hello'))
1 -> 2  ('Hello'), ({'left': 'right'})
1 -> 2  ((3,)), ({'value': 'Hello'})
call5() got multiple values for keyword argument 'value'
call5() got multiple values for keyword argument 'value'
Run Code Online (Sandbox Code Playgroud)

从这段代码:

# Known argument list: works fine
def call(x, y, value=None):
  print("%d -> %d  (%r)" % (x, y, value))

invoker = Invoker(call)
invoker.call(1, 2, value="Hello") …
Run Code Online (Sandbox Code Playgroud)

python

0
推荐指数
1
解决办法
194
查看次数

你如何与飞镖的js互动?

不,这与同名的其他问题不同.

有看似相同的包似乎这样做,但有不同的apis.

为什么有两个?

我们应该使用哪一个?

互操作看起来更新,并且有更好的api,但实际上并不起作用.根据文档,您应该能够转换此JavaScript:

var stage = new PIXI.Stage(0xFFFFFF);;
renderer = PIXI.autoDetectRenderer(800, 600);
document.body.appendChild(renderer.view);
Run Code Online (Sandbox Code Playgroud)

成:

var pixi = new js.Proxy(js.context.PIXI.Stage, 0xffffff);
var renderer = js.context.PIXI.autoDetectRenderer(400, 400);
document.body.append(renderer.view);
Run Code Online (Sandbox Code Playgroud)

但是当你尝试编译它时会出现错误:

dart2js
Error occured:/Users/doug/megac/client/public/dart/index.dart:7:27:
Warning: No member named 'PIXI' in class 'Proxy'.
var pixi = new js.Proxy(js.context.PIXI.Stage, 0xffffff);
^^^^^^^^^^^^^^^
Run Code Online (Sandbox Code Playgroud)

那么... js:dart?这是你应该使用的吗?

编辑:顺便说一句,对于任何偶然发现这一点的人来说,还有一个开放的错误http://code.google.com/p/dart/issues/detail?id=15795&thanks=15795&ts=1388068177关于如何缩小dart-js互操作桥操作当前不起作用.最初的问题是在2013年5月报道的,从那时起就没有采取任何行动,所以不要屏住呼吸.

dart dart-js-interop

0
推荐指数
1
解决办法
1417
查看次数

如何以跨平台方式获取文件的修改时间?

稳定MetadataExt特性为此提供了一些基本功能,但它在Windows上不起作用.

我也看到了关于I/O改革主题的RFC,但现在我完全糊涂了.由于对Rust的I/O故事的绝对史诗反馈,我们花了这么长时间才获得1.0稳定的原因不是吗?

当没有相同功能的跨平台故事时,为什么实验 std::os::unix::fs::MetadataExt性状稳定?

有没有为此目的找到的标准箱子?这个问题涉及Rust 1.3.0.

rust

0
推荐指数
1
解决办法
644
查看次数

`git merge origin` 有什么作用?

今天有人问我做什么git merge origin

我说:你是说,git merge origin/branch

他们:不,只是git merge origin

所以我试了一下,我不知道它有什么作用。

让我们比较一下git pull origin获取当前分支的尝试:

$ git pull origin
You asked to pull from the remote 'origin', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.
Run Code Online (Sandbox Code Playgroud)

公平,那么呢git merge origin

$ git merge origin
Auto-merging ...
Merge made by the 'recursive' strategy.
 ...
 1 file …
Run Code Online (Sandbox Code Playgroud)

git

0
推荐指数
1
解决办法
78
查看次数

如何在不创建实际网络连接的情况下测试依赖于net.Conn的代码?

如果我的代码与a一起使用net.Conn,如何在不实际创建与localhost的网络连接的情况下为其编写测试?

我在网上看不到任何解决方案; 人们似乎要么忽略它(没有测试),编写不能并行运行的测试(即使用实际的网络连接,使用up端口),要么使用io.Pipe.

但是,net.Conn定义SetReadDeadline,SetWriteDeadline; 和io.Pipe没有.net.Pipe 没有,尽管表面上声称实现了界面,但它只是用以下方式实现:

func (p *pipe) SetDeadline(t time.Time) error {
    return &OpError{Op: "set", Net: "pipe", Source: nil, Addr: nil, Err: errors.New("deadline not supported")}
}

func (p *pipe) SetReadDeadline(t time.Time) error {
    return &OpError{Op: "set", Net: "pipe", Source: nil, Addr: nil, Err: errors.New("deadline not supported")}
}

func (p *pipe) SetWriteDeadline(t time.Time) error {
    return &OpError{Op: "set", Net: "pipe", Source: nil, Addr: nil, Err: errors.New("deadline not supported")}
}
Run Code Online (Sandbox Code Playgroud)

(见:https …

unit-testing go

-1
推荐指数
1
解决办法
735
查看次数

标签 统计

dart ×1

dart-js-interop ×1

git ×1

go ×1

python ×1

rust ×1

unit-testing ×1