Using the below Python scripts i can able to create html file by already set the variables(a,b,c,d) as global.I want to run the script dynamically, even also i don't set some variables as globally ,for eg: if we didn't set the value of "a" as global it throwing error "global 'a' is not defined".So please let me know any python scripts for dynamically taking the values and convert them in to html table.
import HTML
import html2
from html2 import *
#print a
#print b
file = open('out.html', 'w')
table_data = [
['S.No', 'Testcase - ID', 'Result'],
['1', a, b],
['2', c, d],
]
htmlcode = HTML.table(table_data)
c=htmlcode
print htmlcode
file.write(c)
-
3Taking the values from where?Dek Dekku– Dek Dekku2013年05月21日 08:25:05 +00:00Commented May 21, 2013 at 8:25
-
It is in seperate file html2, so we give import html2.Anub– Anub2013年05月21日 10:19:03 +00:00Commented May 21, 2013 at 10:19
1 Answer 1
table_data needs a, b, etc. to be defined. It incorporates their values into a new global.
This has otherwise nothing to do with HTML.table(); your table_data list cannot be defined as it currently stands without a and b being defined as well.
If you want a, b, c and d used as parameters from another module, you need to make this a function:
def create_table(a, b, c, d):
table_data = [
['S.No', 'Testcase - ID', 'Result'],
['1', a, b],
['2', c, d],
]
return HTML.table(table_data)
Now you can call create_table() with different parameters.