0
Module Making 2
How would you make this code work? >>Code import _whatever_ as wt wt.text(text="hi") >>Output hi
9 Respostas
+ 1
def text(msg="my default text"):
return msg
print(text(msg="Hi"))
+ 1
Hi!
You make first a module file with the name _whatever_.py. In that file you create a function with the name text(), that contain a keyword argument and that return the argument.
That id actually all you need to do.
/Regards Per B
0
What would be the code tho
0
I know how to make modules but I don't know how to make that arg
0
tysm
0
How would we make it not have to have print?
0
You can always assign it to a variable and print it out later:
my_var = wt.text(msg="hi")
But if you call the function from the interactive prompt, it will probably print it out without using print, if you donât assign it. It is one of the specially things with the interactive prompt.
0
What about making a tkinter label
0
Tkinter:
x = Tk()
l = Label(x, text="hi")
My Module :
sysLabel(msg="somthing")
Output of both :
hi (In GUI)