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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:40:22+00:00 2026-05-22T02:40:22+00:00

Given the python code: import sys import os def MyPythonMethod(value1, value2): # defining some

  • 0

Given the python code:

import sys
import os 

def MyPythonMethod(value1, value2):
    # defining some variables 
    a = 4
    myValue = 15.65
    listValues = [4, 67, 83, -23]

    # check if a file exists
    if ( os.path.exists('/home/hello/myfile.txt') ):
        pass

    # doing some operation on the list
    listValues[0] = listValues[1]       

    # check if a file exists
    print sys.path

    # looping through the values
    for i in listValues:
        print i 

How can I extract the names of all external methods in function MyPythonMethod?

Ideally, I’d like to get a list of all external methods/members that are being invoked.

For MyPythonMethod, this will return:

moduleNames = ["os", "sys"]

methodsInvoked = ["os.path.exists", "sys.path"]

(yes, I know that ‘path’ is a member of sys, not a method; but I think you get the idea).

Any ideas?

  • 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-22T02:40:23+00:00Added an answer on May 22, 2026 at 2:40 am

    You can’t ever fully know what functions (and in your case we’re talking about plain functions, not methods, since methods are member functions of a class), a function will call without parsing it, because it might do so dynamically and their names may depend on what is imported into the global namespace when the function gets called.

    But you can see the module and function names that are referenced by a function by inspecting MyPythonMethod.func_code.co_names. In your case, this attribute would return the tuple ('os', 'path', 'exists', 'sys').

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

Sidebar

Related Questions

I am debugging some python code in emacs using pdb and getting some import
I have that code: #!/usr/bin/python -u localport = 9876 import sys, re, os from
#! /usr/bin/env python import os import stat import sys class chkup: def set(file): filepermission
I was given this Python code that would calculate an MD5 value for any
Python 2.5.1 http://www.cgsecurity.org/wiki/After_Using_PhotoRec I've just run PhotoRec and the code given as a way
Given an instance of some class in Python, it would be useful to be
Working on some code and I'm given the error when running it from the
I have some question about functions which have default parameters. import sys from random
I am trying to optimize some python code (to speed up some matrix operations),
I received this python script that generates a file checksum: import sys,os if __name__==__main__:

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.