我正在尝试使用该inspect
模块,但似乎我不能在内置(本机?)类中使用它,否则我误解了.
我正在使用Python 2.7并尝试使用Python 3.2.
这是有效的:
>>> import inspect
>>> class C:
... def __init__(self,a,b=4):
... self.sum = a + b
...
>>> inspect.getargspec(C.__init__)
ArgSpec(args=['self','a', 'b'], varargs=None, keywords=None, defaults=(4,))
Run Code Online (Sandbox Code Playgroud)
这不起作用:
>>> import inspect
>>> import ast
>>> inspect.getargspec(ast.If.__init__)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 813, in getargspec
raise TypeError('{!r} is not a Python function'.format(func))
TypeError: <slot wrapper '__init__' of '_ast.AST' objects> is not a Python function
Run Code Online (Sandbox Code Playgroud)
我想知道是否有另一种技术可以自动获取这些参数?
(在我的例子中,我想到了一个解析Python语法的替代方案,ASDL文件解释了如何使用我在PyPy Project的源代码中看到的代码来初始化AST节点,但我想知道是否还有其他方法)
基本上我正在升级我的应用程序,从r52到r55.这个应用程序使用动画(Tweens)来更新行,但也使用粒子系统.在r52中,一切都运行得很好,缩放,移动和改变不透明度.
我使用了这些WebGLRenderer构造函数设置:
clearColor: 0x1f1f1f
clearAlpha: 1
antialias: true
sortObjects: false
Run Code Online (Sandbox Code Playgroud)
我从例子中得到了一个简单的着色器:
<script type="x-shader/x-vertex" id="vertexshader">
attribute float size;
attribute vec3 customColor;
attribute float customOpacity;
varying vec3 vColor;
varying float vOpacity;
void main() {
vColor = customColor;
vOpacity = customOpacity;
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
gl_PointSize = size * ( 300.0 / length( mvPosition.xyz ) );
gl_Position = projectionMatrix * mvPosition;
}
</script>
<script type="x-shader/x-fragment" id="fragmentshader">
uniform vec3 color;
uniform sampler2D texture;
varying vec3 vColor;
varying float vOpacity; …
Run Code Online (Sandbox Code Playgroud)