parameter-passing

What is the difference in *args, **kwargs vs calling with tuple and dict? [duplicate]

空扰寡人 提交于 2019-12-14 00:01:42
问题 This question already has answers here : What does ** (double star/asterisk) and * (star/asterisk) do for parameters? (20 answers) Closed 3 years ago . This is a basic question. Is there a difference in doing def foo(*args, **kwargs): """standard function that accepts variable length.""" # do something foo(v1...vn, nv1=nv1...nvn=nvn) def foo(arg, kwargs): """convention, call with tuple and dict.""" # do something mytuple = (v1, ..vn) mydict = {nv1=nv1, ...nvn=nvn} foo(mytuple, mydict) I could

R function '…' argument scope

橙三吉。 提交于 2019-12-13 21:49:23
问题 Tried this code via source() f1 <- function(x, ...){ print(y) } f1(x = 1, y = 2) or this code via source() f1 <- function(x, ...){ y <- 2 f2(x, y = y, ...) } f2 <- function(x, ...){ print(y) } f1(x = 1) Got this Error Error in print(y) : object 'y' not found I guess the '...' argument takes from the global environment? 回答1: you should call y in your function as correct like this f1 <- function(x, ...){ l <- list(...) if(!is.null(l$y)) print(l$y) } f1(x = 1, y=2) 来源: https://stackoverflow.com

Passing Windows User Id as parameter to SQLDataSource gives databinding exception

女生的网名这么多〃 提交于 2019-12-13 21:32:59
问题 First question is, Am I on the right path?.ıs there a better way to pass it as parameter? If I am on the right path, please show me how can I solve the below error. The following solution does not help me with this problem: HTTPContext.Current.User.Identity.Name not working inside a control? My code: <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MyDbConn %>" SelectCommand="SELECT id, Bookname, RequestType, Requestor, RequestDate FROM Requests

Passing and using Class in a method in Java

走远了吗. 提交于 2019-12-13 21:18:15
问题 void methodA() { methodB(ClassA.class) } void methodB(Class classname) { classname a; //not correct HashMap<String, classname> hash = new HashMap<>(); //not correct } IDE is complaining it to be not correct. I want to do something like what is being commented as //not correct. Why is it not correct and how can I do it? 回答1: You cannot use a variable name as a type name, so methodB won't compile. You can however use a type parameter for the method. Try <T> void methodB(Class<T> clazz) { T a;

Stored Procedure/Parameterized Query in Access And Pass Parameter

无人久伴 提交于 2019-12-13 18:27:15
问题 I've created a query in Access that looks like this... SELECT project_master.ProjectID, project_master.OracleNum, project_master.BudgetYear, project_master.ProjectNum, project_master.Description, project_master.Description, project_master.Location, project_master.Region, project_master.ContactOwner, project_master.ContactDesigner, project_master.ProjectPriority, project_master.StartDate, project_master.InitialCloseDate, project_master.CurrentBonus, project_master.CurrentQty, project_master

“std::string” or “const std::string&” argument? (the argument is internally copied and modified)

会有一股神秘感。 提交于 2019-12-13 18:23:31
问题 Consider this code: void doSomethingWithString(string& mString) { // mString gets modified in here } string getCopy1(const string& mString) { string result{mString}; doSomethingWithString(result); return result; } string getCopy2(string mString) { doSomethingWithString(mString); return mString; } Between getCopy1 and getCopy2 , what one: Clearly shows that the passed string isn't going to get modified Clearly shows that the user will get a new string returned Is faster / can be better

Passing an associative array as a parameter between packages

纵饮孤独 提交于 2019-12-13 16:06:55
问题 I've got two separate Oracle (v9.2) PL/SQL packages and I'm trying to pass an associative array (ie, index-by table) from a procedure in package1, as a parameter to a procedure in package2. Is this possible? I keep getting PLS-00306: wrong number or types of arguments in call to 'ROLLUP_TO_15' when I compile package1. The array is defined as: type list_tab is table of number(10) index by binary_integer; in both package's spec. In the procedure in package1, I'm calling the second package as

Returning result via Output-parameter, c++ coding standard [duplicate]

﹥>﹥吖頭↗ 提交于 2019-12-13 15:21:08
问题 This question already has answers here : best practice for parameters? (5 answers) Closed 6 years ago . I have a member function in my class like this: int MyClass::m_Func(int& val); in which, I do some operation and put the result in val . And depending upon the result of the operation, I returned different values from the function. Like, if it is successful, I return 0 or other values if any error occurs. One of my friend told me that it is not a good practice to pass a reference of a

Passing List<int> as Query Parameter to SQL Server

左心房为你撑大大i 提交于 2019-12-13 15:16:18
问题 I have to pass a list to a SQL Server query using C#. My code is here: using (SqlDataReader _myReader_2 = _myCommand_3.ExecuteReader()) { _Node_Neighbor.Clear(); while (_myReader_2.Read()) { _Node_Neighbor.Add(Convert.ToInt32(_myReader_2["Target_Node"])); } _myReader_2.Close(); //Here I have to pass this _Node_Neighbor i.e. of type List<int> to another //SQL Server query as: try { SqlCommand _myCommand_4 = _con.CreateCommand(); _myCommand_4.CommandText = @"SELECT COUNT(*) FROM GraphEdges

Named parameters in Perl

北慕城南 提交于 2019-12-13 14:11:46
问题 I'm attempting to use named parameters in Perl. I've been using http://perldesignpatterns.com/?NamedArguments as a reference. It seems to make sense. However, I can't seem to actually get the values sent in. I have tried changing to $args{'name'} , $args{"name"} as well and no luck. I just can't seem to get the values passed in. Which direction do I need to look in to figure out what on earth is happening? File doh.pm package doh; sub new () { my %args = @_; $name = $args{name}; print $name;