Where are the python modules stored?

Is there a way to obtain a list of Python modules available (i.e. installed) on a machine? This works for me: help(‘modules’) Where is the module code actually stored on my machine? Usually in /lib/site-packages in your Python folder. (At least, on Windows.) You can use sys.path to find out what directories are searched for … Read more

How to properly export an ES6 class in Node 4?

// person.js ‘use strict’; module.exports = class Person { constructor(firstName, lastName) { this.firstName = firstName; this.lastName = lastName; } display() { console.log(this.firstName + ” ” + this.lastName); } }   // index.js ‘use strict’; var Person = require(‘./person.js’); var someone = new Person(“First name”, “Last name”); someone.display();

ES6 export all values from object

I can’t really recommend this solution work-around but it does function. Rather than exporting an object, you use named exports each member. In another file, import the first module’s named exports into an object and export that object as default. Also export all the named exports from the first module using export * from ‘./file1’; … Read more

Why does Typescript use the keyword “export” to make classes and interfaces public?

The primary reason is that export matches the plans for ECMAScript. You could argue that “they should have used “export” instead of “public”, but asides from “export/private/protected” being a poorly matched set of access modifiers, I believe there is a subtle difference between the two that explains this. In TypeScript, marking a class member as … Read more

How do I call setattr() on the current module?

import sys thismodule = sys.modules[__name__] setattr(thismodule, name, value) or, without using setattr (which breaks the letter of the question but satisfies the same practical purposes;-): globals()[name] = value Note: at module scope, the latter is equivalent to: vars()[name] = value which is a bit more concise, but doesn’t work from within a function (vars() gives … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)