In python, is there a way I can use instance variables as optional arguments in a class method? ie:
def function(self, arg1=val1, arg2=val2, arg3=self.instance_var):
# do stuff....
Any help would be appreciated.
...
Hi guys!
Please help me understand why this function throws an exception when it reaches fclose :
void receive_file(int socket, char *save_to, int file_size) {
FILE *handle = fopen(save_to,"wb");
if(handle != NULL) {
int SIZE = 1024;
char buffer[SIZE];
memset(buffer,0,SIZE);
int read_so_far = 0;
int re...
Is there any reason to use the "Param( ... )" construction inside a function definition? My understanding is that you should use this for specifying parameters to scripts (and scriptblocks). I see a lot of examples on the web with parameters listed this way instead of just listing the parameters after the function name.
Example:
f...
I am trying to create a generic menu button class that is templated to a class, so I can make this button in any class. I want to create a void function pointer to different functions in that class, so when you click on the New Game button, it will call the NewGame() function etc.
I'm still a little new to the idea of creating function...
Hey there, quick question here. I'm sure there's a simple answer.
Coming from PHP, I'm used to declaring a function with a default argument value like this:
function myFunction ($array, $sort = FALSE) {
}
I the sort parameter wasn't filled, the function would continue with the default value of false. In Obj-C, is there a similar t...
when ever a function has a object passed by value it uses either copy constructor or bit wise copy to create a temporary to place on stack to use inside the function,How about some object returned from function ?
//just a sample code to support the qn
rnObj somefunction()
{
return rnObj();
}
and also explain how the return value is ta...
Hello guys,
Is it possible to enumerate every function present in a DLL ? How about getting its signature ?
Can I do this in C# ? Or do I have to go low level to do this?
Regards and tks,
Jose
...
Is this proposition true?
For all functions f
f(a+b) = f(a) + f(b).
If yes then why? If no then what are those special functions called and what property do they have?
EDIT:
Wow i think floor/celing functions do not hold the property.? I can think of counterexamples but could somebody please prove this. But what are the functions ...
how to find unused functions in a c++ project vc2008
...
How can I write a wrapper that can wrap any function and can be called just like the function itself?
The reason I need this: I want a Timer object that can wrap a function and behave just like the function itself, plus it logs the accumulated time of all its calls.
The scenario would look like this:
// a function whose runtime shoul...
I need to call a library function that sometimes won't terminate within a given time, unfortunately. Is there a way to call the function but abort it if it doesn't terminate within n seconds?
I cannot modify the function, so I cannot put the abort condition into it directly. I have to add a timeout to the function externally.
Is it may...
One table has "John Doe <[email protected]>" while another has "[email protected]". Is there a UDF or alternative method that'll match the email address from the first field against the second field?
This isn't going to be production code, I just need it for running an ad-hoc analysis. It's a shame the DB doesn't store both friendly and non-fri...
I have a small program to test passing char* pointers in and out of functions.
When I compile with cc, I get warning and errors saying I have conflicting types even though all my variables are char* . Please enlighten
#include <stdio.h>
main()
{
char* p = NULL;
foo1(p);
foo2();
}
void foo1(char* p1)
{
}
char* foo2(void)
...
I want to make a file that contains useful functions for my project. Well, I know that I can define a function inside my class implementation. But I don't really get it... I mean: I don't want to create a "class", just functions. Or are functions always part of a class? My objective-c knowledge is pretty limited, and my nice big book on ...
So I'm not to OOP in PHP.
Here is my issue I have a object that I can call a function from and it provides back an arrary. So here is the code.
$obj = new OBJ();
function go($url){
$array = $obj->grabArray($url);
echo $array['hits'];
}
go('http://www.mysite.com/hello');
This gives me the error
Fatal error: Call to a member...
I am new to programming. I have been trying to write a function in C++ that explodes the contents of a string into a string array at a given parameter, example:
string str = "___this_ is__ th_e str__ing we__ will use__";
should return string array:
cout << stringArray[0]; // 'this'
cout << stringArray[1]; // ' is'
cout << stringArra...
Possible Duplicate:
Is there a better way to do optional function parameters in Javascript?
I would like a javascript function to have optional arguments which I set a default on, which gets used if the value isn't defined. In ruby you can do it like this:
def read_file(file, delete_after = false)
# code
end
Does this work...
I recently saw the presentation about the changes in ECMAScript 5. And there was a slide with this statement:
Function vs Callable
typeof f === 'function' // → f is Callable
({}).toString.call(f) === '[object Function]' // → f is a Function
Can anyone explain to me what the difference between Function and Ca...
Hi,
I have created a Queue class in javascript and I would like to store functions as data in a queue. That way I can build up requests (function calls) and respond to them when I need to (actually executing the function).
Is there any way to store a function as data, somewhat similar to
.setTimeout("doSomething()", 1000);
except it...
Just working through learning python and started to look at nested/factory functions (simple example):
def maker(N):
def action(X):
return X * N
return action
Are there any advantages of factory functions over creating a class? performance? memory? clean up?
...