Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6217395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:25:10+00:00 2026-05-24T07:25:10+00:00

I just saw a code snippet in Dive into Python where a function was

  • 0

I just saw a code snippet in Dive into Python where a function was calling another function (that actually returns something other than None) and still the calling function does NOT assign the returned value to a variable.

I got alarmed by it and quickly went to try it:

>>> def foo(): return "hello_world!"
... 
>>> def bar(): foo()    
... 

I realize every function in python returns (either None or something else)

To my surprise when I tried the same logic in my previously learned languages, they seem to show similar behavior:

C:

#include<stdio.h>

char* foo(){return "hello_world!";}

int main(void){
  foo();                                                 // works!
  return 0;
}

C++

#include<iostream>
#include<string>
using namespace std;

string foo(){return "hello_world!";}

int main(){
  foo();                                                 // works!
  return 0;
}

Java:

public class Test{

  public static String foo(){return "hello_world!";}

  public static void main(String args[]){
    foo();                                               // works!
    System.exit(0);    
  }  
}

All this time I was assuming if a function actually returns something, it SHOULD be set to some variable, otherwise where would the returned value go?!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T07:25:11+00:00Added an answer on May 24, 2026 at 7:25 am

    It disappears.

    In case of languages and runtimes in which an object is returned that would need to be garbage collected, the result of calling that function is eligible for collection as soon as the function returns.

    In case of languages and runtimes that return an object that is reference counted, or similarly protected, to force an immediate cleanup when the object is no longer needed, that cleanup will occur when the function has returned.

    Otherwise, for all intents and purposes, the value is just lost. There’s no harm done and should be perfectly safe to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just saw a really cool WPF twitter client that I think is developed
I just saw that there is a Ruby to Parrot compiler called Cardinal ,
I just saw this mentioned in Stack Overflow question Best WYSIWYG CSS editor and
I just saw a comment of suggesting J# , and it made me wonder...
I just saw Clone Detective linked on YCombinator news, and the idea heavily appeals
I just saw this question: Understanding .NET’s SecurityAction parameter for permissions And I have
I just saw a article on Swing being used in JavaFX. How can an
Just looking for the first step basic solution here that keeps the honest people
Just what the title says, I need to change the password for an existing
just a quick question: I am a CS undergrad and have only had experience

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.