<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#ffffff">
Hi <br>
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: <b><br>
<br>
NameError: name 'MyClass' is not defined</b><br>
<br>
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. <span class="k"><br>
</span><font face="Courier 10 Pitch"><br>
</font>
<pre><big><b><big><span class="k">class</span> <span class="nc">MyClass</span><span
 class="p">:</span>
    <span class="sd">"""A simple example class"""</span>
    <span class="n">i</span> <span class="o">=</span> <span class="mi">12345</span>
    <span class="k">def</span> <span class="nf">f</span><span class="p">(</span><span
 class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="s">'hello world'</span></big></b></big>
</pre>
<font face="Courier 10 Pitch"><br>
</font><b>&gt;&gt;&gt; MyClass<br>
Traceback (most recent call last):<br>
&nbsp; File "&lt;stdin&gt;", line 1, in &lt;module&gt;<br>
NameError: name 'MyClass' is not defined</b><br>
<br>
Still the same error. What am I doing wrong?<br>
I tried this in gnome-terminal in a Python shell and using IDLE.<br>
<br>
First I do: <b>import myscript.py<br>
</b>(no errors)<b><br>
</b><br>
Then I run: <b>MyClass</b><br>
(error)<br>
<br>
I try:&nbsp; n = <b>MyClass()</b><br>
(error)<br>
<br>
I try: <br>
<b>MyClass.n<br>
n.MyClass<br>
i.MyClass<br>
MyClass.i<br>
i.MyClass()<br>
f.MyClass<br>
f.MyClass()</b><br>
<br>
(nothing but errors)<br>
<br>
<br>
<br>
</body>
</html>