Class problem

D

Daniel Pryde

Hello. I'm currently trying to create my first class in python, but I've
ran into a bit of a problem which I fear may just be a simple error. I
created a class called ImagePyramid.py which currently only contains an
_init_ method which takes in 2 parameters and performs a bunch of things
using these parameters. I believe I've followed the tutorial correctly,
but when I import it and try to make an instance of it, it returns with
the error that 'module' is not callable. I'm kind of new to this
language so I believe that it's most likely a simple error on my behalf.
Any advice on what I may be doing wrong would be greatly appreciated.

Daniel
 
R

Rene Pijlman

Daniel Pryde:
when I import it and try to make an instance of it, it returns with
the error that 'module' is not callable.

My guess is you should do:

import spam
eggs = spam.spam()

instead of:

import spam
eggs = spam()

If not, please post the source code and exact text of the error message.
 
D

Daniel Pryde

Rene said:
Daniel Pryde:



My guess is you should do:

import spam
eggs = spam.spam()

instead of:

import spam
eggs = spam()

If not, please post the source code and exact text of the error message.

Thanks. Sorry everyone for not posting the problem code with it. I only
have internet access at university and unfortunately the code's on my
home hard drive, however it was something like:
===========
import Image

class ImagePyramid:
def _init_(self, parameters):
do stuff :)
===========

And I would use it as such:
===========
import ImagePyramid
pyramid = ImagePyramid(parameters)
===========

I'l try out the above solution and hopefully that'll fix things. Thanks.:)

Daniel
 
D

Daniel Pryde

Rene said:
Daniel Pryde:



Never leave home without it :)




Yes, that should be:

import ImagePyramid
pyramid = ImagePyramid.ImagePyramid(parameters)

This is explained in section 6 "Modules" of the tutorial on
http://www.python.org/doc/current/tut/node8.html
Whoops! I got into trouble last time when I posted and found out that
the answer was in the tutorial. I'll need to pay attention a bit more
often. :) Thanks for the help though.

Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,172
Messages
2,570,934
Members
47,474
Latest member
AntoniaDea

Latest Threads

Top