loading

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

www.codecademy.com

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

Required:

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:

1. Time

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:

import os
a = open("hi.bat","w")

a.write(str("@echo off" + "\n" + "echo hi" + "\n" + "pause"))

a.close()

os.startfile("hi.bat")

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!

Python works on any operating system. Windows is not a requirement. But, I'm not sure if the batch file you created will work as expected on Unix based systems. There'll be plenty of documentation on this, though :)
<p>I didn't mean you needed windows for Python(and I'm sorry if it sounded like that). I wasn't sure how the os part would work out on other systems. Also, since it was a batch file I made I was pretty sure it wouldn't be able to work the same way on systems that don't use Windows. </p>
<p>If you enjoy Python your a sucker for a Raspberry pi. Go for it.</p>
<p>I've looked into Raspberry Pi but I haven't got around to buying it. I actually began Python looking for more ways to control my current robot that uses an Arduino.</p>

About This Instructable

877views

28favorites

License:

Bio: I just love making stuff...and working out!
More by Red_:Make a program with a Python program Processing Tools For Arduino Using a joystick with your Arduino 
Add instructable to: