FAQ
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

Search Discussions

  • Rene Pijlman at Dec 8, 2003 at 5:22 pm
    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
  • Daniel Pryde at Dec 8, 2003 at 6:02 pm

    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
  • Rene Pijlman at Dec 8, 2003 at 6:15 pm
    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
  • Daniel Pryde at Dec 8, 2003 at 6:50 pm

    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
  • Michael T. Babcock at Dec 8, 2003 at 5:49 pm

    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.

    In the future, please actually post your code with your questions.

    However, I'll guess you did something like:

    class foo:
    def __init__(self, params):
    print "hello"

    foo()

    ... when in reality you need to create an object of type foo ...

    a = foo() <-- prints "hello"


    --
    Michael T. Babcock
    C.T.O., FibreSpeed Ltd.
    http://www.fibrespeed.net/~mbabcock
  • Robert Brewer at Dec 8, 2003 at 6:27 pm
    Let's hope your home version had double underscores surrounding "init".
    ;)

    class ImagePyramid:
    def __init__(self, parameters):
    do stuff :-)


    Robert Brewer
    MIS
    Amor Ministries
    fumanchu at amor.og
    -----Original Message-----
    From: Daniel Pryde [mailto:dpryde+usenet at cis.strath.ac.uk]
    Sent: Monday, December 08, 2003 10:02 AM
    To: python-list at python.org
    Subject: Re: Class problem


    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

    --
    http://mail.python.org/mailman/listinfo/python-list
  • Daniel Pryde at Dec 8, 2003 at 7:09 pm

    Robert Brewer wrote:

    Let's hope your home version had double underscores surrounding "init".
    ;)

    class ImagePyramid:
    def __init__(self, parameters):
    do stuff :-)


    Robert Brewer
    MIS
    Amor Ministries
    fumanchu at amor.og
    Double whoops! I'm definite the one at home had double underscores
    though. Thanks for the correction.

    Daniel

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedDec 8, '03 at 5:18p
activeDec 8, '03 at 7:09p
posts8
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase