473,395 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Class problem

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

Jul 18 '05 #1
4 1227
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.

--
René Pijlman
Jul 18 '05 #2
Rene Pijlman wrote:
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.


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

Jul 18 '05 #3
Daniel Pryde:
the code's on my home hard drive
Never leave home without it :-)
import ImagePyramid
pyramid = ImagePyramid(parameters)


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

--
René Pijlman
Jul 18 '05 #4
Rene Pijlman wrote:
Daniel Pryde:
the code's on my home hard drive

Never leave home without it :-)

import ImagePyramid
pyramid = ImagePyramid(parameters)

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

Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Steve | last post by:
Hello, I'm encountering an unexpected behavior when using the "new" modifier in a derived class to hide an inherited base class property. I use "new" intentionally so I can change the Type of...
9
by: Banaticus Bart | last post by:
I wrote an abstract base class from which I've derived a few other classes. I'd like to create a base class array where each element is an instance of a derived object. I can create a base class...
21
by: Jon Slaughter | last post by:
I have a class that is basicaly duplicated throughout several files with only members names changing according to the class name yet with virtually the exact same coding going on. e.g. class...
21
by: Mark Broadbent | last post by:
Consider the following statements //------- Item i = Basket.Items; //indexer is used to return instance of class Item Basket.Items.Remove(); //method on class item is fired item i = new...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
8
by: tshad | last post by:
I cannot seem to get the asp:textbox to use classes. Style works fine. I am trying to set the textbox to act like a label in some instance so it doesn't have a border, readonly and the background...
4
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
5
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something...
3
by: Hamilton Woods | last post by:
Diehards, I developed a template matrix class back around 1992 using Borland C++ 4.5 (ancestor of C++ Builder) and haven't touched it until a few days ago. I pulled it from the freezer and...
3
by: TamusJRoyce | last post by:
Hello. This is my first thread here. My problem has probably been came across by a lot of people, but tutorials and things I've seen don't address it (usually too basic). My problem is that I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.