AnsweredAssumed Answered

problem using python modules

Question asked by bschwarz on Mar 6, 2013
Latest reply on Mar 6, 2013 by bschwarz
I have a rather basic python question re: modules

I have a python script that's essentially structured as follows:

======================================
## aaa.py

func1():
   ...some code...
...arcpy.AddMessage("message")
...return

func2():
    ...some code...
...arcpy.AddMessage("message")
...return

If __name__ = "main":

...import sys, arcpy, argparse, os, time
   
    ...some code...
...func1()
...func2()
...return
======================================

I want to write another script that uses the functions within aaa.py.  So I import aaa.py as a module into this other script (see bleow).

======================================
## bbb.py

import sys, arcpy, argparse, os, time, aaa
   
some code...
aaa.func1()
=======================================

When I execute aaa all is fine.
When I execute bbb, it returns an error "NameError: global name 'arcpy' is not defined". 

Appreciate any insight on how to avoid this.

b

PS - used ... in post above to show indent since spaces and tabs removed

Outcomes