gabrielkolbe
gabrielkolbe

Reputation: 145

Sending values to python script then running

Sorry guys, I am a php dev not a python one. This is probably very basic for someone. I want to import a python script, but send a value (id) to it for it to run. I have a 'parent' page and import one after the other scripts and run them when they return expected values. Using python 3

On parent script...

import script1 << give id
script 1 get the id and run a query and return values

impot script2 << send id
script 2 get the id and run a query and return v

Upvotes: 0

Views: 44

Answers (1)

Nuran
Nuran

Reputation: 331

Normally pythonic way would be to import the required methods and execute those methods in your script. please refer the example below.

script1

def example_method():
   return 1

script2

def example_method_2():
   return 1

Your script

from script1 import example_method
from script2 import example_method_2

result1 = example_method()
result2 = example_method_2()

Upvotes: 1

Related Questions