Hi
I am running Linux with Python 2.6.6. I have done lists, tuples, dictionaries, etc. Now I want to move on to creating a "class". I keep getting an error for everything I try. Here is the error: *

NameError: name 'MyClass' is not defined*

I had originally tried to create my own class by watching some video tutorials. Nothing worked. Then from the python2.6-doc documentation I just decided to copy and paste from the documentation.

*class  MyClass:
    """A simple example class"""
    i  =  12345
    def  f(self):
        return  'hello world'*


*>>> MyClass
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'MyClass' is not defined*

Still the same error. What am I doing wrong?
I tried this in gnome-terminal in a Python shell and using IDLE.

First I do: *import myscript.py
*(no errors)*
*
Then I run: *MyClass*
(error)

I try:  n = *MyClass()*
(error)

I try:
*MyClass.n
n.MyClass
i.MyClass
MyClass.i
i.MyClass()
f.MyClass
f.MyClass()*

(nothing but errors)



_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to