a question on variables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chainsinthewall
    New Member
    • Feb 2008
    • 3

    a question on variables

    Im a student at a local technology college and I am taking a program design class. I have been trying to turn some of the programs we design in class into python programs but it is proving to be VERY problematic. The main problem I am having at the moment is that modules(functio n) cannot use variables from another module(function ). Is there a way to do that?
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Originally posted by chainsinthewall
    Im a student at a local technology college and I am taking a program design class. I have been trying to turn some of the programs we design in class into python programs but it is proving to be VERY problematic. The main problem I am having at the moment is that modules(functio n) cannot use variables from another module(function ). Is there a way to do that?
    Yes. Pass arguments to a function and return the results. Example:[code=Python]>>> from macrolib.indexL ist import indexList
    >>> from macrolib.inch_p rint import inch_print
    >>> idx_list = indexList([inch_print(num) for num in [12.2, 15.5, 17.7, 25.5, 12.2]], '12 3/16')
    >>> idx_list
    [0, 4]
    >>> [/code]The variables used in the functions are not accessible, but an object or objects can be returned and assigned to a name.

    Comment

    Working...