I am working on a Jupyterhub project and beginner Python user. I would like to print returned values from the function in another py
file for dubug.
a.py
:
class TestSpawner(SlurmSpawner):
def _options_form_default(self):
return """
<label for="queue">node type</label>
<select name="queue">
<option value="standard">standard</option>
<option value="dev-test">TEST</option>
</select>
<label for="runtime">Job duration</label>
<select name="runtime">
<option value="1:00:00">1 hour</option>
<option value="2:00:00">2 hours</option>
</select>
"""
def options_from_form(self, formdata):
print ( formdata.get('queue', [''])[0].strip())
options = {}
options['queue'] = formdata.get('queue', [''])[0].strip()
options['runtime'] = formdata.get('runtime', [''])[0].strip()
print (options)
return options
b.py
:
import sys
from a import *
print (options)
print (queue)
I can see the queue and options values using print (options)
in a.py
, but I am not sure how I can print the values in b.py
and make sure it gets correct values from a.py
. Please help me and Thanks.
Import your module, make an instance, and call the method in b.py
:
import a
spawner = a.TestSpawner()
formdata = 'my form data' # add your data here
print(options_from_form(formdata))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.