call

Unicode filename to python subprocess.call() [duplicate]

左心房为你撑大大i 提交于 2019-11-27 23:07:29
This question already has an answer here: Unicode filenames on Windows with Python & subprocess.Popen() 5 answers I'm trying to run subprocess.call() with unicode filename, and here is simplified problem: n = u'c:\\windows\\notepad.exe ' f = u'c:\\temp\\nèw.txt' subprocess.call(n + f) which raises famous error: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' Encoding to utf-8 produces wrong filename, and mbcs passes filename as new.txt without accent I just can't read any more on this confusing subject and spin in circle. I found here lot of answers for many different problems

Python - how do I call external python programs?

谁说我不能喝 提交于 2019-11-27 23:05:25
问题 I'll preface this by saying it's a homework assignment. I don't want code written out for me, just to be pointed in the right direction. We're able to work on a project of our choice so I'm working on a program to be a mini portfolio of everything I've written so far. So I'm going to make a program that the user will input the name of a program (chosen from a given list) and then run the chosen program within the existing shell. However, I can't really find information on how to call upon

How to call a private method from outside a java class

删除回忆录丶 提交于 2019-11-27 18:32:37
I have a Dummy class that has a private method called sayHello . I want to call sayHello from outside Dummy . I think it should be possible with reflection but I get an IllegalAccessException . Any ideas??? Pshemo use setAccessible(true) on your Method object before using its invoke method. import java.lang.reflect.*; class Dummy{ private void foo(){ System.out.println("hello foo()"); } } class Test{ public static void main(String[] args) throws Exception { Dummy d = new Dummy(); Method m = Dummy.class.getDeclaredMethod("foo"); //m.invoke(d);// throws java.lang.IllegalAccessException m

Calling R script from python using rpy2

断了今生、忘了曾经 提交于 2019-11-27 18:02:48
I'm very new to rpy2, as well as R. I basically have a R script, script.R, which contains functions, such as rfunc(folder). It is located in the same directory as my python script. I want to call it from Python, and then launch one of its functions. I do not need any output from this R function. I know it must be very basic, but I cannot find examples of R script-calling python codes. What I am currently doing, in Python: import rpy2.robjects as robjects def pyFunction(folder): #do python stuff r=robjects.r r[r.source("script.R")] r["rfunc(folder)"] #do python stuff pyFunction(folder) I am

Using greater than operator with subprocess.call

若如初见. 提交于 2019-11-27 15:35:48
What I am trying to do is pretty simple. I want to call the following command using python's subprocess module. cat /path/to/file_A > file_B The command simply works and copies the contents of file_A to file_B in current working directory. However when I try to call this command using the subprocess module in a script it errors out. Following is what I am doing: import subprocess subprocess.call(["cat", "/path/to/file_A", ">", "file_B"]) and I get the following error: cat: /path/to/file_A: No such file or directory cat: >: No such file or directory cat: file_B: No such file or directory what

How does 'call' work in javascript?

一个人想着一个人 提交于 2019-11-27 14:47:42
I have a question on 'call' in javascript. var humanWithHand = function(){ this.raiseHand = function(){ alert("raise hand"); } } var humanWithFoot = function(){ this.raiseFoot = function(){ alert("raise foot"); } } var human = function(){ humanWithHand.call( this ); humanWithFoot.call( this ); } var test = new human(); so..when I use 'call' as humanWithHand.call(this), what happens internally? does humanWithHand variable copies (or points?) its properties and members to human variable's prototype? .call() sets the this value and then calls the function with the arguments you passed to .call()

Is there a way to not wait for a system() command to finish? (in c) [duplicate]

馋奶兔 提交于 2019-11-27 14:35:06
Similar to: program not executing anything after a call to system() I am fairly new to using C but basically, I want to execute the following line: int a = system("python -m plotter"); which will launch a python module I developed. However, I want the rest of my c program to keep running instead of waiting for the command to finish executing (the python app is on an infinite loop so it wont close automatically). Is there any way to do this using C/C++? Update: the solution was: int a = system("start python -m plotter &"); system() simply passes its argument to the shell (on Unix-like systems,

Applying a Function to Null in Javascript

老子叫甜甜 提交于 2019-11-27 14:10:59
Why does the following work: function sum(a,b) { return a + b; } var result = sum.call(null,3,4); // 7 Why is result defined? I am invoking sum as a method of null. But null is not an object and cannot have properties! What is going on? jAndy The first argument for Function.prototype.call is the context , which defines the this value for the execution context of the invoked function, nothing else. So basically, you're saying that this is referring to null (at least, in ES5 strict mode), but since you don't access this anyway, it makes no difference. In non-strict mode, this cannot be null , so

Calling C++ functions from C file

落花浮王杯 提交于 2019-11-27 13:59:30
问题 I am quite new to C and C++. But I have some C++ functions which I need to call them from C. I made an example of what I need to do main.c : #include "example.h" #include <stdio.h> int main(){ helloWorld(); return 0; } example.h : #ifndef HEADER_FILE #define HEADER_FILE #ifdef __cplusplus extern "C" { #endif void helloWorld(); #ifdef __cplusplus } #endif #endif example.cpp : #include <iostream.h> void helloWorld(){ printf("hello from CPP"); } It just doesn't work. I still receive the error of

Calling a function within a Class method?

被刻印的时光 ゝ 提交于 2019-11-27 10:21:01
I have been trying to figure out how to go about doing this but I am not quite sure how. Here is an example of what I am trying to do: class test { public newTest(){ function bigTest(){ //Big Test Here } function smallTest(){ //Small Test Here } } public scoreTest(){ //Scoring code here; } } Here is the part I am having problems with, how do I call bigTest()? Try this one: class test { public function newTest(){ $this->bigTest(); $this->smallTest(); } private function bigTest(){ //Big Test Here } private function smallTest(){ //Small Test Here } public function scoreTest(){ //Scoring code here