Introduction: Make a Program With a Python Program
It all begins with an idea. Literally.
Python is a really simple and powerful language. You can do so much with a few lines of code which makes it simpler to use.
A great site to learn more about python is
Through this site is where I got the idea for this instructable.
Anyways, using python we will write a batch program in the notepad application(so you might need windows for this).
Let's get started
Step 1: All the Stuff You Need
1. A computer
2.I think that computer is required to have windows
3.Python(I'm using 3.4, and this includes IDLE and everything)Optional:
2. Your favorite beverage
Step 2: Lets Write the Program
Open up IDLE.
Go to File and start a new program.
Once there copy the following code in:
a = open("hi.bat","w")
a.write(str("@echo off" + "\n" + "echo hi" + "\n" + "pause"))
See what I mean by a few lines of code?
Let me explain the code.
First, you import the os library which allows us to start the program automatically.
Then, you open up the file to be wrote to, hence the w(we could put r or r+ instead so we could read what was wrote to the file). The file will be batch file due to simplicity and you can use any name you want.
After that you write to the file with the code you want in the file. To do this you write a command(as a string)and then add a \n in between so it puts each on its own line.
After you write to a file you must close the file with .close(). Always.
Then, we use os.startfile(your file path here) to automatically start the program.
Step 3: Run the Python Program
Go up to run.
Click on run module.
You can save this program as whatever you want.
The program should then run and your newly made batch program should come up!
Step 4: Troubleshooting
If you copied it straight from here you shouldn't have a problem from that.
But if you are using a different version you may need to modify the code.
There might be syntax problems though so make sure to watch that.
Let me know if you have any problems and I will try to help!
Step 5: Ideas for Using This
You could make an editor to make programs.
Or...I am not liable if you decide to do this....make a virus of some sort.
Anyways thanks for reading this!