Re: TypeError: 'module' object is not callable ; why not?
Alan Gauld via Tutor <[email protected]> Sun, 14 Dec 2025 09:24:31 +0000
| Newsgroups | gmane.comp.python.tutor |
|---|---|
| Message-ID | <[email protected]> |
On 12/12/2025 22:58, Francis Belliveau via Tutor wrote: > I am sure that I am missing something fundamental > import sequencers.SequenceInt > si1 = sequencers.SequenceInt(-1, -9, -3) You are importing the module SequenceInt and then calling it. > The SequenceInt.py file starts with the following code exerpt: > > class SequenceInt: The class is inside SequenceInt so you need to include the name twice. This is one advantage of using lowercase for module names and mixed case for classes - it makes this kind of mistake more obvious. > TypeError: 'module' object is not callable Quite correct because you needed: either from sequencers.SequenceInt import SequenceInt sil = SequenceInt(...) OR import sequencers.SequenceInt # better to add an "as SI" alias here? sil = sequencers.SequenceInt.SequenceInt(...) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - To unsubscribe send an email to [email protected] To unsubscribe or change subscription options: %(web_page_url)slistinfo/%(_internal_name)s