parameter-passing

Python and Java parameter passing [duplicate]

守給你的承諾、 提交于 2019-12-01 01:44:29
问题 This question already has answers here : How do I pass a variable by reference? (26 answers) Closed 4 years ago . I've seen in several places, including the Python documentation that Python uses pass by "assignment" semantics. Coming from a Java background, where the common mistake of saying "Java passes primitives by value, and objects by reference" is as a result of having objects references passed by value, I can't help but wonder if Python is really doing the same thing. To me, the

How can I pass a parameter to a time-based Google App Script trigger?

泪湿孤枕 提交于 2019-12-01 01:34:05
问题 In my script, I am reading data from a Spreadsheet and creating a time based trigger to make a POST request with some of that data at a specific time. The problem is, I can't find any way to pass the data to the function that is called by the trigger. All that the Google App Script doc offers is the ability to name the function to call, but no way to pass it parameters. var triggerDay = new Date(2012, 11, 1); ScriptApp.newTrigger("makePostRequest") .timeBased() .at(triggerDay) .create(); Does

Can you pass more parameters than a function expects?

拈花ヽ惹草 提交于 2019-11-30 23:44:23
问题 If you have two classes extending the same base class, and need to make one of them override a function to take an additional parameter. Is it okay to always pass the additional parameter when calling the function on either class? A bit of pseudo-code to help demonstrate... If we have the 3 classes and functions foo::doSomething() foo_subclass_one::doSomething() foo_subclass_two::doSomething($input) And I have an instance of one of these three, can I call $instance.doSomething($input) I

Numeric argument passed with jq --arg not matching data with ==

点点圈 提交于 2019-11-30 21:39:44
Here is a sample JSON response from my curl: { "success": true, "message": "jobStatus", "jobStatus": [ { "ID": 9, "status": "Successful" }, { "ID": 2, "status": "Successful" }, { "ID": 99, "status": "Failed" } ] } I want to check the status of ID=2. Here is the command I tried: cat test.txt|jq --arg v "2" '.jobStatus[]|select(.ID == $v)|.status' response: there is none I tried value 2 without quotes and still no result. By contrast, if I try the command with a literal 2 , it works: cat test.txt | jq '.jobStatus[]|select(.ID == 2)|.status' response: "Successful" I'm stuck. Can anyone help me

How to use User.Identity.Name as a parameter for SqlDataSource in ASP.NET?

两盒软妹~` 提交于 2019-11-30 18:34:25
For SqlDataSource I can configure the external source for the incoming paramater. For example it might be a QueryString, Session, Profile and so on. However I do not have an option to use User as a source. I know that I could provide value for the parameter in Inserting,Selecting,Updating,Deleting events. But I do not think that this is an ellegant solution because I have some parameteres already definied in aspx file. I do not want to have parameters defined in two separate places. It makes mess. So can I somehow define this parameter in .aspx file? <SelectParameters> <asp

How to Pass Parameters from QSub to Bash Script?

社会主义新天地 提交于 2019-11-30 18:05:55
I'm having an issue passing variables to a Bash script using QSub. Assume I have a Bash script named example. The format of example is the following: #!/bin/bash # (assume other variables have been set) echo $1 $2 $3 $4 So, executing "bash example.sh this is a test" on Terminal (I am using Ubuntu 12.04.3 LTS, if that helps) produces the output "this is a test". However, when I enter "qsub -v this,is,a,test example.sh", I get no output. I checked the output file that QSub produces, but the line "this is a test" is nowhere to be found. Any help would be appreciated. Thank you. Using PBSPro or

Should I add a trailing comma after the last argument in a function call?

試著忘記壹切 提交于 2019-11-30 17:07:50
What is better to do? self.call(1, True, "hi") or self.call(1, True, "hi",) And what in the following cases: self.call( 1, True, "hi" ) or self.call( 1, True, "hi", ) ? Reasons for adding a trailing comma in data structures are familiar to me, but what about function calls? Jacob Wan I think there's no technical reason to avoid trailing commas in function calls, but some people probably do find them distracting. Some may stop and say: "Hmmm, I wonder if that's really supposed to be there?" I hesitate to call this a benefit, but one effect of using trailing commas in conjunction with an

How to use User.Identity.Name as a parameter for SqlDataSource in ASP.NET?

旧城冷巷雨未停 提交于 2019-11-30 16:51:34
问题 For SqlDataSource I can configure the external source for the incoming paramater. For example it might be a QueryString, Session, Profile and so on. However I do not have an option to use User as a source. I know that I could provide value for the parameter in Inserting,Selecting,Updating,Deleting events. But I do not think that this is an ellegant solution because I have some parameteres already definied in aspx file. I do not want to have parameters defined in two separate places. It makes

When to use missing versus NULL values for passing undefined function arguments in R, and why?

♀尐吖头ヾ 提交于 2019-11-30 15:23:04
问题 To date when writing R functions I've passed undefined arguments as NULL values and then tested whether they are NULL i.e. f1 <- function (x = NULL) { if(is.null(x)) ... } However I recently discovered the possibility of passing undefined arguments as missing i.e. f2 <- function (x) { if(missing(x)) ... } The R documentation states that Currently missing can only be used in the immediate body of the function that defines the argument, not in the body of a nested function or a local call. This

Want to use a vector as parameter to a function, without having to separate its elements

*爱你&永不变心* 提交于 2019-11-30 15:17:08
If I call a matlab function with: func(1,2,3,4,5) it works perfectly. But if I do: a=[1,2,3,4,5] %(a[1;2;3;4;5] gives same result) then: func(a) gives me: ??? Error ==> func at 11 Not enough input arguments. Line 11 in func.m is: error(nargchk(5, 6, nargin)); I notice that this works perfectly: func(a(1),a(2),a(3),a(4),a(5)) How can I use the vector 'a' as a parameter to a function? I have another function otherfunc(b) which returns a, and would like to use its output as a paramater like this func(otherfunc(b)) . Comma-seperated lists (CSL) can be passed to functions as parameter list, so what