return

Accessing a class's variable in Python

class Example(object): def the_example(self): itsProblem = "problem" theExample = Example() print(theExample.itsProblem) How do I access a class's variable? I've tried adding this definition: def return_itsProblem(self): return itsProblem Yet, that fails also. ...

Returning From a Void Function in C++

Consider the following snippet: void Foo() { // ... } void Bar() { return Foo(); } What is a legitimate reason to use the above in C++ as opposed to the more common approach: void Foo() { // ... } void Bar() { Foo(); // no more expressions -- i.e., implicit return here } ...

Function returning a tuple or None: how to call that function nicely?

Hello, Suppose the following: def MyFunc(a): if a < 0: return None return (a+1, a+2, a+3) v1, v2, v3 = MyFunc() # Bad ofcourse, if the result was None What is the best way to define a function that returns a tuple and yet can be nicely called. Currently, I could do this: r = MyFunc() if r: v1, v2, v3 = r else: # bad!! ...

How do C++ progs get their return value, when a return is not specified in the function?

Hi Everyone, I recently wrote a post: http://stackoverflow.com/questions/3452355/weird-error-in-c-program-removing-printout-breaks-program ...in which I was trying to solve a seemingly baffling problem, in which removing a cout statement would break my program. As it turned out, my problem was that I forgot to return my true/false succ...

c++ return array in a function

Hi before someone storm "it's simple or duplicate" i swear i've searched but because it's pretty easy i couldn't find it between much more complex ones , unlucky maybe. Anyway my question is very simple , I have normal array int arr[5] that is passed to function fillarr(int arr[]) all i want is fixing the next code: int fillarr(int arr[...

Select from dropdown list selected option with php after check

Hi! I ran out of ideas... Imagine, I have fields that must be filled <select> <option value="1">Yes</options> <option value="2">No</options> <option value="3">Fine</options> </select> <input type="text" value="" name="name"> <input type="submit" value="go" name="go"> butI forgot to fill my name and I press submit. How to return option...

Which is generally faster, a yield or an append?

I am currently in a personal learning project where I read in an XML database. I find myself writing functions that gather data and I'm not sure what would be a fast way to return them. Which is generally faster: yields, or several append()s within the function then return the ensuing list? I would be happy to know in what situati...

Returning a tuple of multipe objects in python C api

I am writing a native function that will return multiple python objects PyObject *V = PyList_New(0); PyObject *E = PyList_New(0); PyObject *F = PyList_New(0); return Py_BuildValue("ooo", V, E, F); This compiles fine, however, when I call it from python, I get an error\ SystemError: bad format char passed to Py_BuildValue How can t...

Emulating 'return' in macro

Is there any standard compliant way to emulate 'return' with macro? Currently, I'm trying to wrapping _alloca function to emulate variable length array on stack (which is supported in C99) with macro in C++. Since the _alloca function manipulates stack pointer, I think inline function isn't suitable solution for this time. Below is the...

Returning from a nested function in javascript

Hello, I'm trying to make a function that uses jquery's ajaxfunction to get some info from my ajax.php file. code: function ajaxIt(dataLine){ $.ajax({ type: "POST", url: "ajax.php", data: "ajax=true&"+dataLine, success: function(msg){ console.log("[AjaxIt]: "+dataLine+" returned "+msg); ...

c# optimize returning a empty string

Possible Duplicate: In C#, should I use string.Empty or String.Empty or ? Is it better to return string.Empty; instead of return ""; What do you think? ...

Can't get correct return value from an jQuery Ajax call

This is supposed to return a JSON object containing a list of picture filenames. The commented alert shows the correct data, but alert(getPicsInFolder("testfolder")); shows "error". function getPicsInFolder(folder) { return_data = "error"; $.get("getpics.php?folder=" + folder, function (data) { data = jQuery.parseJSON(data); ...

android AlertDialog get return value withouth handler

i would like to show a number of alertdialogs so the user has to handle off some questions (a little like a wizzard) is it possible to make the alertDialog wait until the user chooses something and then returning the choisen value? HashMap<Integer, Question> questions = DataConnector.getCallQuestions(position); int nextQuest...

Jquery return post data

Ok so I have this function: function getAreas(){ $.post("/custom_html/weathermap.php",'', function(data){ return data }, "json"); } which works fine. now what I am trying to do is to pass the data back to a variable, in other words: var data=getAreas() but it doesnt return anything....

PHP: pass a variable to a function, do something to the variable, return it back.

Assuming the following code: <?php function doStuff($rowCount) { $rowCount++; echo $rowCount.' and '; return $rowCount; } $rowCount = 1; echo $rowCount.' and '; doStuff($rowCount); doStuff($rowCount); doStuff($rowCount); ?> The desired output is 1 and 2 and 3 and 4 and The actual output is 1 and 2 and 2 and 2 and I ...

PHP: Is it possible to return multiple values from a function?

I have a function that should return several values. Is this possible, perhaps with an array? If so, how would I reference that array? Do I have any alternatives to using an array? ...

about the return expression

level: beginner the following code will print 'False' def function(x): if len(x) == 5: return True else: return x[0] == x[-1] print function('annb') why does the line "else: return x[0] == x[-1]" print False? i do understand what's happening but i'm having difficulties to put this into plain english...how can this behaviour ...

Boolean functions: if statements or simple return

I was checking a friend's code, and this pattern showed up quite a bit whenever he wrote functions that returned a boolean value: def multiple_of_three(n): if (n % 3) is 0: return True else: return False I maintain that it's simpler (and perhaps a bit faster) to write: def multiple_of_three(n): return (n % 3...

Android google market returns

I'm finding a great many people buy my Android app in the google market and immediately return it for a refund. That works fine with physical goods, but for virtual goods, they have now acquired the app for free! Has anyone else noticed this fatal flaw in the Google Android market for apps? What other markets are there without this p...

How to I return different type with __toString() method?

We use __toString() to returning class's default value like that: <?php class my { public function __toString() { return "asdasd"; } } ?> It returns only string type. But I want to return resource type: <?php class my { public function __toString() { return imagecreatefromjpeg("image.jpg"); } } ?> ...