Module error when running JavaFx media application

TL;DR: You need to make sure javafx.media is resolved as a module from the module-path. You can do this by either: Including it in the VM arguments: –add-modules javafx.controls,javafx.media Or making your own code modular, adding an appropriate requires javafx.media; directive to your module descriptor, and using –module to launch your application. If you’re not … Read more

__getattr__ on a module

There are two basic problems you are running into here: __xxx__ methods are only looked up on the class TypeError: can’t set attributes of built-in/extension type ‘module’ (1) means any solution would have to also keep track of which module was being examined, otherwise every module would then have the instance-substitution behavior; and (2) means … Read more

Nodejs cannot find installed module on Windows

Add an environment variable called NODE_PATH and set it to %USERPROFILE%\Application Data\npm\node_modules (Windows XP), %AppData%\npm\node_modules (Windows 7/8/10), or wherever npm ends up installing the modules on your Windows flavor. To be done with it once and for all, add this as a System variable in the Advanced tab of the System Properties dialog (run control.exe … Read more

Node.js plans to support import/export ES6 (ECMAScript 2015) modules

Node.js 13.2.0 & Above Node.js 13.2.0 now supports ES Modules without a flag 🎉. However, the implementation is still marked as experimental so use in production with caution. To enable ECMAScript module (ESM) support in 13.2.0, add the following to your package.json: { “type”: “module” } All .js, .mjs (or files without an extension) will … Read more

Generate random numbers with a given (numerical) distribution

scipy.stats.rv_discrete might be what you want. You can supply your probabilities via the values parameter. You can then use the rvs() method of the distribution object to generate random numbers. As pointed out by Eugene Pakhomov in the comments, you can also pass a p keyword parameter to numpy.random.choice(), e.g. numpy.random.choice(numpy.arange(1, 7), p=[0.1, 0.05, 0.05, … Read more

ES6 modules: Export single class of static methods OR multiple individual methods

A class of just static methods feels like a bit of a ‘code smell’ Yes indeed. You don’t need a class structure here! Just export a normal “module” object: //—— myMethods.js —— export default { myMethod1() { console.log(‘foo’); }, myMethod2(args…) { console.log(‘bar’); } }; I do recommend your second approach with multiple exports, though. exporting … Read more