[Tutor] On understanding defintions

Alan Gauld alan.gauld at btinternet.com
Tue Dec 4 20:06:22 CET 2012


On 04/12/12 18:29, frank ernest wrote:
> Opensuse 12.2 python3.2
> I discoverd that some of the examples for definitions in the tutorial
> are not valid. I am reporting this as a bug.

It's not clear what you mean by definitions here.

> In the mean time I tried to look up definitions in the Language
> Referance part of the python documentation but I'm still confused. The
> if, for, etc. are statements of evaluation, comparing one item to
> another; so what does that make definitions?

I don't know what you mean by definitions?
Can you give examples?

> What is self?

See the OOP topic in my tutorial.
But given your other remarks I suspect its a topic you should leave 
until later.

> How are definitions properly used?

That depends on what you mean by definitions.

> What are the mandetory parts?
> What are the optional parts?


> (in if statements the optional parts are
> or, and, elif, else, etc.)

No, 'or' and 'and' are not part of the if statement
they are part of the *expression*.
The expression is a mandatory part of the if statement.

elif and else are optional.
An expression is also mandatory with an elif

> I also tried looking into the demos directory, I found lots of
> definitions but little help in understanding them.
> I am confused on all types of definitions not just functions or classes.

It sounds like you need to step back and start at the beginning.
Do you know any other programming languages? If so, work through the 
official python tutor and ask specific questions here when you get stuck 
(with a reference to the relevant tutor section).

http://docs.python.org/3/tutorial/index.html

If not start with one of the Non Programmers tutorials
  - perhaps mine(see below)! :-)

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list