How to print the codes in python? -



How to print the codes in python? -

this question has reply here:

print out code in python script 1 reply

how 1 print lines of code?

suppose have here 2 variables.

var1 = 2*8 msg = "answer is: "

what statement should add together here programme print source code?

the easiest way print lines of codes through utilize of built-in functions.

print open(__file__).read()

or write code in string mode , print them. won't executable codes anymore 1 time written in quotation marks.

python

Comments