我想用boost :: python将这个C++类用于python代码
/* creature.h */
class Human {
private:
public:
struct emotion {
/* All emotions are percentages */
char joy;
char trust;
char fear;
char surprise;
char sadness;
char disgust;
char anger;
char anticipation;
char love;
};
};
Run Code Online (Sandbox Code Playgroud)
问题是如何在boost-python中公开这个公共属性
namespace py = boost::python;
BOOST_PYTHON_MODULE(example)
{
py::class_<Human>("Human");
// I have not idea how put the public struct here
}
Run Code Online (Sandbox Code Playgroud) 我已经下载了一个emacs包,用于通过autopep8格式化python代码.
这个包名为py-autopep8
你可以在行号78中找到这个常见的lisp函数
(incf line-offset len)
Run Code Online (Sandbox Code Playgroud)
然后,当我打开emacs24并且我想保存缓冲区时,我在emacs shell中有这个
符号的功能定义是无效的:incf
因此,任何人都知道如何修复此错误,以获得emacs嘴中的常见lisp定义.
我试图基于mpi4py创建一个库,但是我想在串行python代码中使用它。
$ python serial_source.py
Run Code Online (Sandbox Code Playgroud)
但是在serial_source.py内部存在一些称为parallel_bar的函数
from foo import parallel_bar
# Can I to make this with mpi4py like a common python source code?
result = parallel_bar(num_proc = 5)
Run Code Online (Sandbox Code Playgroud)
这个问题的动机是找到正确的方法来使用mpi4py来优化python中的程序,这些程序不一定设计为完全并行运行。
我一直试图创建一个事件,在某些条件下(更一般情况下)被触发,但我没有找到办法,至少在Polymer的官方文档中没有找到处理事件的方法
https://www.polymer-project.org/0.5/articles/communication.html
自定义元素侦听另一个事件,因此他希望满足条件以抛出内部事件.
这是一个小描述性的例子:
的index.html
...
<my-element></my-element>
...
<script>
var ele = document.querySelector("my-element");
ele.addEventListener("myCustomEvent",
function(){
// some action
...
})
</script>
Run Code Online (Sandbox Code Playgroud)
此代码描述了谁将监听事件("myCustomEvent")并引爆了一个动作.
另一方面是自定义元素的实现
<polymer-element name="my-element">
<template>
<other-custom-element id="foo"></other-custom-element>
</template>
<script>
Polymer("my-element", {
ready: function(){
var foo = this.$.foo;
foo.addEventListener("AnotherEvent" , function(){
...
if(condition){
...
// in this part I need to fire the event
// "myCustomEvent"
}
})
}
})
</script>
</polymer-element>
Run Code Online (Sandbox Code Playgroud)
我的问题是在条件完成时触发事件,并在外面侦听该事件(在index.html中)
参考
python ×2
boost-python ×1
c++ ×1
common-lisp ×1
elisp ×1
emacs24 ×1
javascript ×1
mpi4py ×1
pep8 ×1
polymer ×1
wrapper ×1