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

  • SEARCH
  • Home
  • 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 8911315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:54:44+00:00 2026-06-15T03:54:44+00:00

i am having a problem with scope. i would like to have a function

  • 0

i am having a problem with scope. i would like to have a function operate on the result of the builtin function dir(). so, as a simple example, i want to

>>> print (dir())
>>>  .... bunch of stuff ...

but, i want define a function which operates on this results of dir(). however, if try this like so

>>> def print_dir(dummy_var=None):
        print dir()
>>> print_dir()
>>> ['dummy_var']

i cant access the namespace of what called print_dir which i understand is a scope thing and makes sense, but is there a way to access the namespace from which a function is called? or do i have to pass the result of dir() to the function? like.

>>> act_on_namespace(dir())

the specific goal in mind is something like this,

def act_on_namespace()
    for k in dir():
        try:
            print(eval(k).__module__)
        except:
            pass
  • 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-15T03:54:45+00:00Added an answer on June 15, 2026 at 3:54 am

    No, there is no straightforward way to manipulate the calling namespace like that. The simplest way is to do what you already suggested: call act_on_namespace(dir()). If you really want to get crazy, you could look at the inspect module, which allows you to look through the call stack, but that is probably not a good idea unless what you’re doing is writing some kind of debugging tool.

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

Sidebar

Related Questions

hello I am having problem related to https:// . I have used FB.getLoginStatus(function(response) function
I am having a problem with what should be a fairly simple (I would
I think I am having a problem with the scope of 'this' when needing
Im having problem in my UIscrollView ,this is what I have done: Whenever a
I'm having problem with datagrid view. I have attached an image with the code
I'm having a little problem with constant scope in mixin modules. Let's say I
We have many instances in our application where we would like to be able
I have a section of code like the following: ---- file.php ---- require_once(mylib.php); function($a,$b)
I'm having a newbie problem in C++. I have a struct Edge defined as
Having problems with out of scope for NSDate in an iphone app. I have

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.