Hello World!

Cool stuff for Mac

Hey guys,

Recently, I got a Mac. This means I’ll be able to help a lot more with Mac problems on our author forums and on this blog. In related news, here’s a cool trick for Macs only. You can make your program talk to you! Start by importing os. OS is a module that lets you interact with your computer’s operating system. Then, type the following:


os.system(“say Hello World!”)

This will send a command to Mac OS telling it to, well, say, “Hello World!” You can put whatever you want after say. However, apostrophes (‘) don’t seem to work. If you have one in your string, it won’t say anything at all. Here’s an example program:

import os
os.system(“say Whats your name?”)
#For some reason, apostrophes don’t work.

name = raw_input(“What’s your name?”)
# It’s good to put it on the screen as well,
# in case users don’t have their speakers on.

print “Hi, “+name+”, hows it going?”
os.system(“say Hi, “+name+”, hows it going?”)

I hope this brings a whole new level of interaction to all your future programs!

Carter Sande