function

How can I get the source code of python function?

Suppose, I have simple python function named foo as shown below, def foo(arg1,arg2): #do something with args a = arg1 + arg2 return a I get name of the function using >> foo.func_name how can I get >> foo.somemethod ? #do something with args a = arg1 + arg2 return a What is best way to do this? Thanks in advan...

Arguments or parameters?

I often find myself confused with how the terms 'arguments' and 'parameters' are used. They seem to be used interchangeably in the programming world. What's the correct convention for their use? ...

Auto generate function documentation in Visual Studio

I was wondering if there is a way (hopefully keyboard shortcut) to create auto generate function headers in visual studio. Example: Private Function Foo(ByVal param1 As String, ByVal param2 As Integer) And it would automagically become something like this... '---------------------------------- 'Pre: 'Post: 'Author: 'Date: 'Para...

Having problems creating a custom lookup function in excel. Issue with match and concatenated ranges

Hi there, I'm having some trouble with a large spreadsheet of mine. I bring in a lot of raw data into a data sheet, and then do a number of lookups across the data. Using built in functions I've come up with =IF(ISNA(INDEX(Data!$L$7:$L$1100,MATCH(Data!$I$2&$B$199&$B29&Data!$J$5,Data!$K$7:$K$1100&Data!$J$7:$J$1100&Data!$I$7:$I$1100&Data!...

How do I enable the PostgreSQL function profiler?

This took me a while to figure out and I found the answer on a foreign-language wiki a number of weeks ago, and it was very helpful, so I thought I would share. ...

Ignore python multiple return value

Say I have a Python function that returns multiple values in a tuple: def func(): return 1, 2 Is there a nice way to ignore one of the results rather than just assigning to a temporary variable? Say if I was only interested in the first value, is there a better way than this: x, temp = func() ...

Function application: Why is $ used here?

A while ago, I asked a question about $, and got useful answers -- in fact, I thought I understood how to use it. It seems I was wrong :( This example shows up in a tutorial: instance Monad [] where xs >>= f = concat . map f $ xs I can't for the life of me see why $ was used there; ghci isn't helping me either, as even tests I do...

JavaScript function parameter

I am trying to pass a number to my JavaScript function, but actually a wrong value is getting passed. I am giving the entire code here: <html> <head> <script type="text/javascript"> function test(num) { /*It should alert as 01004 or 1004 but to my surprise it's alerting as 516!*/ alert(num); } </script> </head> <body> <a href="javascrip...

How to call java objects and functions from CPython?

I have a python program, which runs on the CPython implementation, and inside it I must call a function defined in a java program. How can I do this? It would be nice to be able to use some java objects too. Jython is not an option. I must run the python part in CPython. ...

make a parent function return - super return?

there is a check I need to perform after each subsequent step in a function, so I wanted to define that step as a function within a function. >>> def gs(a,b): ... def ry(): ... if a==b: ... return a ... ... ry() ... ... a += 1 ... ry() ... ... b*=2 ... ry() ... >>> gs(1,2) # should return 2 >>> gs(1,1) # should re...

C# Replace with Callback Function like in AS3

In AS3 you have a function on a string with this signature: function replace(pattern:*, repl:Object):String The repl:Object can also specify a function. If you specify a function, the string returned by the function is inserted in place of the matching content. Also, is it possible to get the the original string in which I want to re...

Arrays as result type and input for functions

in delphi7 i have a function that i need to return a array as a result type b "function createsbox(key:tkey):array[0..255] of byte;" this is not allowed it is expecting a "identifyer expected but array found" is the error throw up. seems to work fine if i declare a record type of array but it seems pointless to do this for one function....

Help please--Getting out of a function in Python

I want to get out of a function when an exception occurs or so. I want to use other method than 'return' Help in this. ...

Troubleshooting PHP Login connection

I have encountered a problem that I have not come accross yet when setting up a log in page using php. The page has a error message that relates to line 1 ( require_once('../Connections/Login.php) that states [function.require-once]: failed to open stream: No such file or directory Fatal Error: require_once() [function.require]: ...

Oracle 9i: Supposedly missing right parenthesis

I have a simple function written in Oracle 9i (version 9.2.0.4.0) to simulate an in-line IF. For those interested, here's the code: create or replace FUNCTION IIF (testExpression NUMBER, trueResult NUMBER, falseResult NUMBER) RETURN NUMBER AS BEGIN /* A simple in-line IF function for use with SQL queries. If the...

What do you call this functional language feature?

ok, embarrassing enough, I posted code that I need explained. Specifically, it first chains absolute value and subtraction together, then tacks on a sort, all the while not having to mention parameters and arguments at all, because of the presense of "adverbs" that can join these functions "verbs" What (non-APL-type) languages support t...

Confusing evaluation of $args in PowerShell

The $args variable should, by definition, contain all arguments passed to a script function. However if I construct a pipeline inside my function, the $args variable evaluates to null. Anyone knows why? See this example: function test { 1..3 | % { echo "args inside pipeline: $args" } ; echo "args outside pipeline: $args" } This is th...

VB.NET Function Return

In order to return a value from a VB.NET function one can assign a value to the "Functions Name" or use "return value." I sometimes see these inter-mixed in the same function. Personally, I prefer the return. My question is, what is the internal difference, if any, between the two? ...

How do I iterate over/dereference an array of subroutine refs in Perl?

I’m trying to figure out how to iterate over an array of subroutine refs. What’s wrong with this syntax? use strict; use warnings; sub yell { print "Ahh!\n"; } sub kick { print "Boot!\n"; } sub scream { print "Eeek!\n"; } my @routines = (\&yell, \&kick, \&scream); foreach my $routine_ref (@routines) { my &routine = &{$routine_ref};...

Help with include function

Im trying to make a simple template system in PHP. I'm new to PHP, so it's nothing serious. I have some problems though: A regular include works: $variable = "test"; include("templates/news.html"); But this won't: This says $variable is undefined: $variable = "test"; getTemplate("news"); The Function: function getTemplate($tpl) ...