问题描述
我想检测用户是否正在运行bpython shell。
我环顾四周,但找不到任何有用的东西。例如,尝试导入bpython并依靠它是错误的肯定结果,因为用户可以安装bpython但实际上运行的是完全不同的shell。
有没有很好的方法?
解决方法
以下内容可在我的系统上工作,但我不确定它的可移植性:
const Triangle = ({ position,color }) => {
const mesh = useRef(null);
return (
<mesh castShadow ref={mesh} position={position}>
<tetrahedronGeometry
attach="geometry"
args={[0.6,0]}
applyMatrix={new THREE.Matrix4().makeRotationAxis(
new THREE.Vector3(2,-1).normalize(),Math.atan(Math.sqrt(2))
)}
/>
<meshStandardMaterial attach="material" color={color} />
</mesh>
);
};
请注意,可以通过将非bpython解释器重命名为import sys
from pathlib import Path
executable_name = Path(sys.argv[0]).name
is_bpython = executable_name == 'bpython'
或将bpython
重命名为其他方法来轻易地欺骗该方法。