Classes, why ? so many problems ?

Christian Tismer tismer at tismer.com
Tue Apr 16 07:46:58 EDT 2002


Graeme Matthew wrote:
> hi all im really having problems with Python can anyone please tell me why I
> cannot run this code, I keep on getting:
> SyntaxError: invalid syntax
> Traceback (most recent call last):
>   File "C:\www\cgi-bin\test.py", line 9, in ?
>     template.PrintOut()
> AttributeError: Template instance has no attribute 'PrintOut'
> 
> class Template:
> 
>     def __init__(self):
>         self.name = 'Template'
> 
>     def PrintOut(self):
>         print self.name

The above code works. You have probably some other
problems. Maybe your sys.path si wrong, and an older
version from an other directory comes into play?

Instead of
 > sys.path.append('C:\\www\\classes')
try
 > sys.path.insert(0, 'C:\\www\\classes')

If that works, you have probably different
versions somewhere.

ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer at tismer.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  pager +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/







More information about the Python-list mailing list