Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #12835

Re: Python marks an instance of my class undefined

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <gandalf@shopzeus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.025
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'subject:Python': 0.06; 'imports': 0.07; '"import': 0.16; 'subject:instance': 0.16; 'this:': 0.16; 'wrote:': 0.16; '>>>': 0.18; 'to:2**1': 0.20; 'header:In-Reply-To:1': 0.22; 'module,': 0.23; 'statement': 0.25; 'import': 0.28; 'example': 0.30; 'module': 0.30; 'solved': 0.30; 'thanks': 0.30; 'class': 0.30; 'list': 0.32; 'to:addr:python- list': 0.33; 'calling': 0.33; 'header:User-Agent:1': 0.34; 'object': 0.35; 'anything': 0.36; 'thread': 0.37; 'subject:: ': 0.39; 'received:192': 0.39; 'under': 0.39; 'to:addr:python.org': 0.39; 'subject:class': 0.84; 'titled': 0.84
Date Tue, 06 Sep 2011 16:18:32 +0200
From Laszlo Nagy <gandalf@shopzeus.com>
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Thunderbird/3.1.13
MIME-Version 1.0
To Kayode Odeyemi <dreyemi@gmail.com>, python-list@python.org
Subject Re: Python marks an instance of my class undefined
References <CAPbrmCumW-mcJvsER-GQUDQUeuqmtvsH9kD2usZVWaW4pgb=hQ@mail.gmail.com> <CAPbrmCu0PEQgZg0DMej073p+zzfc266uZAiWQ3pt-WZiHoFafQ@mail.gmail.com>
In-Reply-To <CAPbrmCu0PEQgZg0DMej073p+zzfc266uZAiWQ3pt-WZiHoFafQ@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
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>
Newsgroups comp.lang.python
Message-ID <mailman.802.1315318727.27778.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1315318727 news.xs4all.nl 2541 [2001:888:2000:d::a6]:52598
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:12835

Show key headers only | View raw


On 2011-09-06 15:42, Kayode Odeyemi wrote:
> I was able to get this solved by calling class like this:
>
> >>> from core.fleet import Fleet
> >>> f = Fleet()
>
> Thanks to a thread from the list titled "TypeError: 'module' object is 
> not callable"
Or you can also do this:

import core.fleet # import module core.fleet under the name core.fleet
f = core.fleet.Fleet()

Please note that the import statement imports the module with the given 
name.

So for example

import x.y.z

will import the name "x.y.z". Anything that is in module "z" will be 
available through its module, that is "x.y.z".
Whenever you use "import <name>", you have to access module contents 
through "<name>".

You can change the name:

import core.fleet as c # import module core.fleet under the name c
f = c.Fleet()

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Python marks an instance of my class undefined Laszlo Nagy <gandalf@shopzeus.com> - 2011-09-06 16:18 +0200
  Re: Python marks an instance of my class undefined Hans Mulder <hansmu@xs4all.nl> - 2011-09-06 17:12 +0200

csiph-web