return

What's the best way to return multiple values from a function in Python?

I have a function where I need to do something to a string. I need the function to return a boolean indicating whether or not the operation succeeded, and I also need to return the modified string. In C#, I would use an out parameter for the string, but there is no equivalent in Python. I'm still very new to Python and the only thin...

Hibernate criteria _ how to use criteria to return only one element of an object instead the entire object

Hello, I'm trying to get only the list of id of object bob for example instead of the list of bob. It's ok with a HQL request, but I would know if it's possible using criteria ? An example : final StringBuilder hql = new StringBuilder(); hql.append( "select bob.id from " ) .append( bob.class.getName() ).append( " bob " ) .appe...

In Java, does return trump finally?

If I have a try/catch block with returns inside it, will the finally block be called? For example: try { something(); return success; } catch (Exception e) { return failure; } finally { System.out.println "i don't know if this will get printed out." } I know I can just type this in an se...

Checking Unix script ftp return codes.

I am currently creating an overnight job that calls a Unix script which in turn creates and ftps a file. I would like to check all possible return codes. The unix man for ftp doesn't list return codes. Does anyone know where to find a list? Anyone with experience with this? We have other scripts that grep for certain return strings ...

C++ having cin read a return character

Hey everyone, I was wondering how to use cin so that if the user does not enter in any value and just pushes ENTER that cin will recognize this as valid input. Thanks in advance, Tomek ...

Best Practice: function return value or byref output parameters?

I have a function called FindSpecificRowValue that takes in a datatable and returns the row number that contains a particular value. If that value isn't found, I want to indicate so to the calling function. Is the best approach to: Write a function that returns false if not found, true if found, and the found row number as a byref/out...

Will the c++ compiler optimize away unused return value?

If I have a function that returns an object, but this return value is never used by the caller, will the compiler optimize away the copy? (Possibly an always/sometimes/never answer.) Elementary example:ReturnValue MyClass::FunctionThatAltersMembersAndNeverFails() { //Do stuff to members of MyClass that never fails return success...

Returning an interface from a WCF service

I have some .NET remoting code where a factory method, implemented in some server side class, returns interfaces to concrete objects, also executing on the very same server. .NET remoting automagically creates proxies and allows me to pass the interfaces across to the client, which can then call them directly. Example interfaces: publi...

What is the best way to return an error from a function when I'm already returning a value?

I wrote a function in C that converts a string to an integer and returns the integer. When I call the function I also want it to let me know if the string is not a valid number. In the past I returned -1 when this error occurred, because I didn't need to convert strings to negative numbers. But now I want it to convert strings to negativ...

Problem with return statement

I have problem with return statment >.< I want to store all magazine names into ArrayList<String> ListNameMagazine = new ArrayList<String>(); I have a DB; in the DB there is a table name_magazine and the data in name_magazine is Magazine1 Magazine2 Magazine3 Magazine4 This my main: ShowData Show = new ShowDa...

Is returning early from a function more elegant than an if statement?

Myself and a colleague have a dispute about which of the following is more elegant. I won't say who's who, so it is impartial. Which is more elegant? public function set hitZone(target:DisplayObject):void { if(_hitZone != target) { _hitZone.removeEventListener(MouseEvent.ROLL_OVER, onBtOve...

Set Variable from an Array directly into a List of Variables in Java

I have a Java method which returns an array of doubles. I would then like to store these values in individual variables in the calling function. Is there an elegant way of doing this in Java. I could write it as this: double[] returnValues = calculateSomeDoubles(); double firstVar = returnValues[0]; double secondVar = returnValues[1];...

JQuery AJAX Return Link Not Working

I have a problem in integrating PHP and JQuery: My main file is MyFile.html and the AJAX call file is ajax.php. The ajax.php function returns links to myFile.html as <a href Link.php?action=Function ></a> (i.e echo " <a href Link.php?action=Delete";) When I click the returned link from MyFile.html it's performing as expected. I nee...

JQuery Ajax Return value

Dear all, I have jquery that, i have called an ajax function file.php , that has some fields like Milk , Will I assign into again JQuery function, If so how to do It?.I attached the sample file <html> <head> <LINK REL=StyleSheet HREF="examples.css" TITLE="Contemporary" TYPE="text/css"> <script src="jquery-1.2.6.js" type="text/j...

PHP Return from function in another file

Hi, I have a class called User with static function loginRequired(), which returns false if the user is logged in and true if the user is logged out. It also appends an error to an error class that I created that tells the person using the site that they must be logged in to view the content. The idea is that for the top of each functio...

ajax Return Data Not working in JQuery

Dear all I have developed code with ajax and JQuery , I have Got Response from my.php, I have Tried to extract the Values of response ,Here the code My.php ?php echo '<div id="title">My Title </div>'; echo '<div id="message"> My message </div>'; ?> I Try to extract Title and Message SO My Code is Below <script t...

I need help--lists and Python

How to return a list in Python??? When I tried returning a list,I got an empty list.What's the reason??? ...

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...

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? ...

return statement vs exit() in main()

Should I use exit() or just return statements in main()? Personally I favor the 'return' statements 'cause I feel it's like reading any other function and the flow control when I'm reading the code is smooth (in my opinion). And even if I want to refactor the main() function, having 'return' seems like a better choice than exit(). Does ...