Having a mare with Classes

sebastien s.keim at laposte.net
Wed Feb 13 11:36:13 EST 2002


Graeme Matthew <graeme.matthew at unite.com.au> wrote in message news:<3C6A4BC4.4060409 at unite.com.au>...
> Please can someone help, im having an absolute mare, I have Wesley Chuns 
> book on core python programming and I cannot get casses to work, im just 
> using a simple test from the examples in the book.
> 
> OK I HAVE A CLASS PERSON
> 
> class Person:
> 
>      def printName(self):
>          print 'You printed it'
> 
> I HAVE A SCRIPT:
> 
> #!/usr/local/bin/Python2.2
> 
> 
> import sys
> 
> sys.path.append('/www/cgi-bin')
> 
> import Person
> person = Person()
> 
> person.printName()
> 
> I keep on getting this error:
> 
> #! /usr/local/bin/Python2.2
> 
> 
> TypeError: call or non function (type module)
> 
> Please if you can help it would be much appreciated.
> 
> Thanks graeme

In fact you have created a module (the Person.py file) which define
the class Person.

try this:
#!/usr/local/bin/Python2.2
 
 
import sys
 
sys.path.append('/www/cgi-bin')
 
import Person
person = Person.Person()  ## here we call the class Person of the
module Person
 
person.printName()



More information about the Python-list mailing list