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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:38:00+00:00 2026-06-13T11:38:00+00:00

I have 2 modules mexec1.py def exec1func(): print ‘exec1’ exec ‘c:/python27/exec2.py’ if __name__ ==

  • 0

I have 2 modules

mexec1.py

def exec1func():
    print 'exec1'
    exec 'c:/python27/exec2.py'

if __name__ == '__main__':
    exec1func()

exec2.py

def exec2func(parm=''):
    print 'exec2 parm',parm

if __name__ == '__main__':
    exec2func(parm='')

From exec1.py I want to call exec2func of the exec2.py using only exec or execfile…I don’t want subprocess.Popen..

  • 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-13T11:38:01+00:00Added an answer on June 13, 2026 at 11:38 am

    Use import instead:

    def exec1func():
        from exec2 import exec2func
        exec2func()
    

    If you want to import using the full path, use imp.load_source:

    import imp
    
    def exec1func():
        exec2 = imp.load_source('exec2', 'c:/python27/exec2.py')
        exec2.exec2func()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose you have these modules: module1.py import module2 def a(): module1.b() def c(): print
I have three modules as: one.py : def abc(): print "Heeeeeeeeeeeiiiiiioooooooooo" two.py : import
Suppose I have two modules: a.py: import b print __name__, __file__ b.py: print __name__,
I have next modules. module A module B def self.method_b(value) #code end end end
I have several modules of a project and i have made each module as
say I have two 'modules'. For instance the hardware-interface layer of a RS-232 port
If I have 6 modules in my project is it possible to build only
Zend Project with multiple modules and every modules have its own routes.ini defined inside
In theory in layered architecture you can have multiple modules on the same layer.
In my code base I find that two modules have structures with the same

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.