Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #11242
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ppv.grps@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'newbie': 0.03; 'python.': 0.04; 'mrab': 0.04; 'subject:module': 0.04; 'raises': 0.07; 'subject:object': 0.07; 'python': 0.08; 'be:': 0.09; 'callable.': 0.09; 'message-id:@glegroupsg2000goo.googlegroups.com': 0.09; 'reply-to:addr:comp.lang.python': 0.09; 'to:addr:comp.lang.python': 0.09; 'class,': 0.15; "subject:' ": 0.15; 'forget.': 0.16; 'instantiate': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.16; 'thanks,': 0.18; 'cc:no real name:2**0': 0.20; 'appears': 0.20; 'wrote': 0.20; 'subject:not': 0.21; 'file,': 0.21; 'cc:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'code': 0.25; "i'm": 0.27; 'received:209.85.220': 0.27; 'correct': 0.28; 'import': 0.28; 'fine.': 0.29; 'importing': 0.29; 'module.': 0.29; 'print': 0.29; 'cc:addr:python.org': 0.30; 'module': 0.30; 'imported': 0.30; 'typeerror:': 0.30; 'class': 0.30; 'error': 0.32; 'list': 0.32; 'does': 0.32; "isn't": 0.33; 'there': 0.33; 'however,': 0.34; 'header:User-Agent:1': 0.34; 'file.': 0.34; 'clearly': 0.34; 'like:': 0.34; 'thank': 0.35; 'object': 0.35; 'problem.': 0.36; 'thursday,': 0.37; 'something': 0.37; 'think': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'should': 0.38; 'subject:: ': 0.39; 'either': 0.39; 'recommended': 0.39; 'called': 0.40; "it's": 0.40; 'your': 0.61; '11,': 0.68; 'august': 0.70; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.71; 'reply-to:addr:googlegroups.com': 0.74; 'adopt': 0.84; 'mat': 0.84; 'or:': 0.91; 'resides': 0.91 |
| Newsgroups | comp.lang.python |
| Date | Thu, 11 Aug 2011 17:56:34 -0700 (PDT) |
| In-Reply-To | <mailman.2198.1313108544.1164.python-list@python.org> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=108.16.47.51; posting-account=21vsegoAAAAdfdSoDHW2LJ4n8gspC-l6 |
| References | <b5d26e9e-df36-4721-bf1b-d5b60b816fb0@glegroupsg2000goo.googlegroups.com> <mailman.2198.1313108544.1164.python-list@python.org> |
| User-Agent | G2/1.0 |
| X-Google-Web-Client | true |
| MIME-Version | 1.0 |
| Subject | Re: TypeError: 'module' object is not callable |
| From | Forafo San <ppv.grps@gmail.com> |
| To | comp.lang.python@googlegroups.com |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| Reply-To | comp.lang.python@googlegroups.com |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Message-ID | <mailman.2199.1313110597.1164.python-list@python.org> (permalink) |
| Lines | 51 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1313110597 news.xs4all.nl 23970 [2001:888:2000:d::a6]:48669 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:11242 |
Show key headers only | View raw
On Thursday, August 11, 2011 8:22:20 PM UTC-4, MRAB wrote: > On 11/08/2011 23:43, Forafo San wrote: > > I wrote a class, Univariate, that resides in a directory that is in my PYTHONPATH. I'm able to import that class into a *.py file. However when I try to instantiate an object with that class like: > > > > x = Univariate(a) # a is a list that is expected by the Univariate class > > > > python raises the TypeError: 'module' object is not callable. If I embed the code of the Univariate class in my *.py file, there is no problem. Also, when the class is imported and I do a > > > > print dir(Univariate) > > > > it does not print all the methods that are in the class, while if the class code appears in my *.py file, all the methods are available and a list with the correct methods are printed. > > > > What gives? > > > I think you mat be confusing the class with the module. > > When you write: > > import Univariate > > you're importing the module. > > If the module is called "Univariate" and the class within the module is > called "Univariate" then you should either write: > > import Univariate > x = Univariate.Univariate(a) # the class Univariate in the module > Univariate > > or: > > from Univariate import Univariate > x = Univariate(a) > > Incidentally, it's recommended that module names use lowercase, so that > would be: > > import univariate > x = univariate.Univariate(a) > > or: > > from univariate import Univariate Thank you all for your replies. When I do a from Univariate import Univariate the TypeError disappears and everything is fine. Clearly this was an error that a newbie such as myself is likely to make because of little experience with Python. However, this isn't something I'm likely to forget. I will also adopt the style recommendations. Thanks, again.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
TypeError: 'module' object is not callable Forafo San <ppv.grps@gmail.com> - 2011-08-11 15:43 -0700
Re: TypeError: 'module' object is not callable John Gordon <gordon@panix.com> - 2011-08-11 23:39 +0000
Re: TypeError: 'module' object is not callable David Robinow <drobinow@gmail.com> - 2011-08-11 20:15 -0400
Re: TypeError: 'module' object is not callable MRAB <python@mrabarnett.plus.com> - 2011-08-12 01:22 +0100
Re: TypeError: 'module' object is not callable Forafo San <ppv.grps@gmail.com> - 2011-08-11 17:56 -0700
Re: TypeError: 'module' object is not callable Forafo San <ppv.grps@gmail.com> - 2011-08-11 17:56 -0700
csiph-web