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 9181579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:21:00+00:00 2026-06-17T18:21:00+00:00

A small bit of code will explain why I’m asking and why this is

  • 0

A small bit of code will explain why I’m asking and why this is not a duplicate. (I hope)

>>> def foo():
...    return 1
... 
>>> bar=foo
>>> bar.__name__
'foo'

How do I get ‘bar’?

I’ve tried inspect and frames, but everything I’ve found so far fails this test.

  • 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-06-17T18:21:01+00:00Added an answer on June 17, 2026 at 6:21 pm

    bar is just a reference to an already created object(foo), doing bar=foo means you created another reference to the same object.

    In [62]: def foo():pass
    
    In [63]: bar=foo
    
    In [64]: spam=bar     #another reference to foo function object
    
    In [65]: spam.__name__,bar.__name__
    Out[65]: ('foo', 'foo')
    
    In [66]: spam is foo,bar is foo
    Out[66]: (True, True)
    
    In [67]: import sys
    
    In [68]: sys.getrefcount(foo)  # no of variable pointing to that object
    
    Out[68]: 4           #3+1, 1 added by default by getrefcount()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a small bit of DRY going on in code I and others
I have this small snippet to change a bit of html when a user
Currently I'm using this minor bit of javascript to remove a small list of
I am working on a small bit of script that will allow for easy
I have a small bit of code I made on Microsoft Visual studio that
May be this question a bit not for StackOverflow, but both compilers and Verilog
This is how I plan to make it: There will be a small JFrame
Quick question I currently have a small bit of code that is pulling comments
I've got a small bit of code that I'm trying to execute via an
I tried to implement a small authentication via http and copied this bit of

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.