"Payal Rathod" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> In Alan's tutorial I haven't got the example of print42() even after
> reading the explanation.
> I get 110 if I use it as a function.
>
>>>> spam = 42
>>>> def print42(): print spam
> ...
>>>> spam = 110
>>>> print42()
> 110
>
> Why do you get 42 when you use it as module? I haven't understood the
> explantaion.

The problem here is that you are typing it all at the >>> prompt.
If you look closely you will notice that the code examples are in
different modules - ie different files.

The >>> prompt basically acts like all the code you type is in the
same module, namespaces are really only effectoive when you are
using multiple files/modules.

However I'll refrain from saying much more since I do think the
namespaces topic could be significantly improved if only I could
find better words and examples.

So please everyone, feel free to try to explain this idea to Payal
so that I can steal your ideas for the tutorial!!  :-)

-- 
Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld







_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to