arguments

How to enforce unicode arguments for methods?

I have a model class with getter and setter methods, and the occasional static methods. I would like to enforce the usage of unicode strings as arguments for specific methods and using decorators was the first idea I had. Now I have something like this: import types class require_unicode(object): def __init__(self, function): ...

Default arguments in JAR-manifest

Is there a way to create a JAR-file that contains some arguments that are passed to the main class? (It does not matter whether it prepends or appends the arguments to potential command line arguments.) I know I could simply write a bootstrapping class and specify this as main class (calling the real main class with the arguments), but ...

Parse string into argv/argc

Is there a C library function that I can use to parse a piece of text and obtain values for argv and argc, as if the text had been passed to an application on the command line? This doesn't have to work on Windows, just Linux - I also don't care about quoting of arguments. ...

Read in command line arguments from DrScheme

How do I detect what command line arguments where given when a script is run with mred? That is, the equivalent of sys.argv in Python, args[] in Java, etc... ...

C Programming: Forward variable argument list.

Hi, I'm trying to write a function that accepts a variable number of parameters like printf, does some stuff, then passes the variable list to printf. I'm not sure how to do this, because it seems like it would have to push them onto the stack. Something approximately like this http://pastie.org/694844 #include <stdio.h> #include <st...

Invalid Argument When Using String Array

Hello, I'm building a program that uses a WriteAllLines generic function: private static void WriteAllLines(string file, string[] contents) { using (StreamWriter writer = new StreamWriter(file)) { foreach (string line in contents) { writer.Write(line); } } } But the problem is that when...

Is it possible to define a block with default arguments in Ruby?

This question deals with optional arguments passed to a Ruby block. I'm wondering if it's also possible to define arguments with default values, and what the syntax for that would be. At first glance, it appears that the answer is "no": def call_it &block block.call end call_it do |x = "foo"| p "Called the block with value #{x}" e...

Are there compelling reasons to adopt HTML5?

The main website for my company is due to be completely overhauled next year as part of a major rebranding exercise. While it is expected to only require a "new lick of paint" (i.e. update CSS and imagery), it may also be the best time to look at moves towards a shift to HTML5. There are plenty of reasons why I would not want to do thi...

C++ Access to command line arguments outside main?

I have a couple command line apps that both end up calling into com objects. Rather than adding new interface to these com objects, can they access the parameters passed from the command line? Edit: Sort of how I can call GetModuleFileName to get the file name. Im wondering if there is an equivalent method to get the args. ...

Read from File, or STDIN

I've written a command line utility that uses getopt for parsing arguments given on the command line. I would also like to have a filename be an optional argument, such as it is in other utilities like grep, cut etc. So, I would like it to have the following usage tool -d character -f integer [filename] How can I implement the followi...

python reduce error?

The following is my python code: >>> item = 1 >>> a = [] >>> a.append((1,2,3)) >>> a.append((7,2,4)) >>> sums=reduce(lambda x:abs(item-x[1]),a) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: <lambda>() takes exactly 1 argument (2 given) >>> How can I fix it? Thanks! ...

extract the number and name of python method arguments

How can I return the arguments of a function in a different module #Module: functionss.py def simple(a, b, c): print "does something" #Module: extract.py #load the called module and function def get_args(module_name, function_name): modFile, modPath, modDesc = imp.find_module(module_name) mod = imp.load_module(module_name,...

Efficient passing of std::vector

When a C++ function accepts an std::vector argument, the usual pattern is to pass it by const reference, such as: int sum2(const std::vector<int> &v) { int s = 0; for(size_t i = 0; i < v.size(); i++) s += fn(v[i]); return s; } I believe that this code results in double dereferencing when the vector elements are accessed, beca...

A question about JavaScript's slice and splice methods

I came across the following code: var f = function () { var args = Array.prototype.slice.call(arguments).splice(1); // some more code }; Basically, the result in args is an array that is a copy of the arguments without its first element. But what I can't understand exactly is why f's arguments (which is an object that holds...

Redirecting Command-line Arguments for Bootstrapping

I am trying to rewrite the following program in C instead of C# (which is less portable). It is obvious that "int system ( const char * command )" will be necessary to complete the program. Starting it with "int main ( int argc, char * argv[] )" will allow getting the command-line arguments, but there is still a problem that is difficult...

Comparing character arrays and string literals in C++ without cstring

In my programming class we currently have a project that requires us to take arguments into the program. I then need to be able to check one of the arguments to see which value was passed to the program so that I can choose the appropriate behavior for the program to follow. In a previous homework assignment I did this with the strcmp fu...

Passing return value of a function as an argument

What are some ways of passing the return value of one function as an argument to another? What are some examples in programming languages that you favor, JS, Python, etc? ...

How Can I Get the Arguments of Function Calls from the Firebug Profiler?

Firbug profiler outputs the functions called, but not the arguments/parameters of each function call. Is there any way to get those arguments? I've dug through the DOM tab for any of the given function calls that I know would have to have had some arguments, but was unsuccessful in pulling out any details. ...

Getting information from button1_click() to button2_click()

I am fairly new to c#. I have one winform with 2 buttons on it. button1_click() generates some data say data1, data2, data3, data4. Now I want to use this data in button2_click(): private void button1_click(object sender, EventArgs e) { //generate data1, data2, data3, data4.. } private void button2_click(obje...

argument passing to a javascript function from an asp.net c# button clock event

i have to pass a string value which is stored in a variable to a javascript function which i'm calling in a button click event of my asp.net c# web application. i have tried some ways but not getting exactly. below is the code which i'm using protected void Button1_Click(object sender, EventArgs e) { myButton.Attributes...