-1

is there way to make "code template" in visual studio code?

All I want after creating new file is to fill the file with this code here like c# does...

This can save me time

# Imports
x = 10
# Set Variables

def main(text, number, variable):
    print("Hello, world..", text, number, variable)

# Main function


if __name__ == "__main__":
    main("xyz", 5, x)

2 Answers2

0

Unfortunately, there is no option to do this in IDLE. You will have to type it in manually.

Oliver
  • 94
  • 8
0

I see that you want to open a file with a code already written on it. For that purpose you can use the following code:

f = open("myfile.py", "w") # This will create a file.
f.write('''
    # Imports
    x = 10
    # Set Variables

    def main(text, number, variable):
        print("Hello, world..", text, number, variable)

    # Main function


    if __name__ == "__main__":
        main("xyz", 5, x)
    ''')
f.close()
Sergey Shubin
  • 3,040
  • 4
  • 24
  • 36
Rohit_VE
  • 109
  • 5