[Courses] [python] Lesson 1: Hello world

॥ स्वक्ष ॥ vid at svaksha.com
Sat Jun 18 13:21:15 UTC 2011

On Fri, Jun 17, 2011 at 22:47, Akkana Peck <akkana at shallowsky.com> wrote:
> You'll hear programmers arguing endlessly about "vim versus emacs",
> but don't worry about it. You can use any text editor you want.
> You probably already have gedit installed if you're on a Gnome system,
> or Kate if  you're on KDE; or few other good options include nano,
> leafpad and pico.

With default gedit settings (Alternatively, you can edit the settings
to '4 spaces'), I've hit white spacing bug errors when I reuse my
code. I find SPE (Stani's Python Editor) very handy to quickly check
for those.  Unlike other languages which use some form of parentheses
or curly brace delimiters, Python has easy to read syntax but you need
to watch out for the whitespace bugs :)

Disclaimer: I'm not new to Python but I love revisiting stuff as it
helps me refresh my basics. So, can I participate? Feel free to
decline and I wont feel bad :).

> ================= Homework =========================
> 1. I'm interested in hearing what version of Python everybody is running,
>   on which operating system, distro and version. Please post your results!
>   Especially if python3 is the default, or if you have any other problems
>   running the examples.

Python 2.6.5 on Kubuntu-Lucid.

> 2. Why are there two commas in
>    print "Hello,", name
>    ? What do you think the difference is between them?

The first comma is not very important from a programming perspective,
just readability --so instead  of "Hello, Vid" it would print "Hello

However, the second comma is very important as its a delimiter which
is part of the Python syntax. If you ran the program without a comma
the Python interpreter cannot differentiate when the print statement
ends (the "inverted comma" is a indicator for the print statement) and
does not pull your earlier variable declaration (where you entered
your name). The declared variable in the first line is ignored and
because there is an undeclared expression in the second line, it
throws a syntax error "SyntaxError: invalid syntax".

Suppose I modify the file to run, print "Hello, name" it prints
whatever is within the inverted comma and again ignores the values
declared in the variable 'name' in the first statement.

> 3. Anyone know why the language was named Python?

After the Monty Python flying circus?

vid ॥ http://svaksha.com

More information about the Courses mailing list