[Cialug] python

Matthew Nuzum newz at bearfruit.org
Sat Apr 19 19:50:14 CDT 2008


On Sat, Apr 19, 2008 at 4:59 PM, Mike Davis <mike.davis.50322 at gmail.com> wrote:
> You know what I feel like?  Someone who's not QUITE
> drowning.  lol.
>
> OK, so I want to download Python.  I searched for it
> in synaptic, but didn't find it.  So I did a google
> search for ubuntu python download and finally got it
> from this page:

A signficant portion the Ubuntu desktop experience is written in
Python so you should be able to start learning it without installing
anything new.

Just open a terminal and type

    python

then at your prompt, write your first python program:

>>> print "hello world!"
hello world!

Press ctrl + d to exit.

You can create a python programming by creating a text file. If you
use the normal Ubuntu text editor (known as gedit Applications ->
Accessories -> Text editor) and save the file with a .py extension
you'll get syntax highlighting.

#!/usr/bin/python
print "hello world!"

Depending on how you run the program you may have to make the file
executable. You can right click it and choose the permissions tab and
check the box next to "Execute" near the bottom. Or from a terminal
type this command:

   chmod +x helloworld.py

The first line of the file should be the hash-bang
(#!/usr/bin/python)... it's a key to the operating system indicating
how to execute it.

You can leave out the hash bang and you can skip the executable stuff
if you want to run your program from a terminal like this:

    python helloworld.py

Have fun!

If you need quicker help, use IRC to connect to freenode and join the
channel #cialug.

-- 
Matthew Nuzum
newz2000 on freenode


More information about the Cialug mailing list