Calling a python function from bash script
python -c’import themodule; themodule.thefunction(“boo!”)’
python -c’import themodule; themodule.thefunction(“boo!”)’
count is the right way to do this. For the common case of checking whether there are any arguments, you can use its exit status: function fcd if count $argv > /dev/null open $argv else open $PWD end end To answer your second question, test -d $argv returns true if $argv is empty, because POSIX … Read more
Define the function on the window object to make it global from within another function scope: $(document).ready(function(){ window.lol = function(){ alert(‘lol’); } });
The Interface Principle by Herb Sutter For a class X, all functions, including free functions, that both (a) “mention” X, and (b) are “supplied with” X are logically part of X, because they form part of the interface of X. For in depth discussion read Namespaces and the Interface Principle by Herb Sutter. EDIT Actually, … Read more
This is fine. The ISO C++11 Standard even gives your situation as an example. First the parameter is in scope: 3.3.3 Block scope [ basic.scope.local ] 2 The potential scope of a function parameter name (including one appearing in a lambda-declarator) or of a function-local predefined variable in a function definition (8.4) begins at its … Read more
It’s worth pointing out that there is a difference in behavior in the implementation of console.log. Under node v0.10.19 you do not get an error; you simply see this: > [1,2,3,4,5].forEach(console.log); 1 0 [ 1, 2, 3, 4, 5 ] 2 1 [ 1, 2, 3, 4, 5 ] 3 2 [ 1, 2, 3, … Read more
How about this: def test(): exec (code, globals()) f()
Those are old K&R style function parameter declarations, declaring the types of the parameters separately: int func(a, b, c) int a; int b; int c; { return a + b + c; } This is the same as the more modern way to declare function parameters: int func(int a, int b, int c) { return … Read more
Use fat arrow function in ES6 (generally called as arrow function) anotherOne = ()=> { … } Call like this onClick={this.anotherOne}; no need to bind in constuctor From the ECMA spec Any reference to arguments, super, this, or new.target within an ArrowFunction must resolve to a binding in a lexically enclosing environment. Typically this will … Read more