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


Groups > comp.lang.python > #36649

Re: Problem with importing in Python

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'main()': 0.07; 'python': 0.09; 'flush': 0.09; 'way:': 0.09; 'file,': 0.15; 'sat,': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'helps!': 0.16; 'java.': 0.16; 'main().': 0.16; 'naming': 0.16; 'subject:Problem': 0.16; 'wrote:': 0.17; 'jan': 0.18; '(or': 0.18; 'module': 0.19; 'file.': 0.20; 'import': 0.21; "haven't": 0.23; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'definition': 0.29; 'class': 0.29; 'that.': 0.30; 'function': 0.30; 'to:addr:python-list': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'received:209.85': 0.35; 'but': 0.36; '12,': 0.36; 'subject:with': 0.36; 'drop': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; "you'll": 0.62; 'circle': 0.65; '2013': 0.84; 'easy!': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=ZBbh+sptuNnZauOxDUmQDCuU9RHIU4yl5jCFbh6npFo=; b=MJaFWgzs55KXZDJmJCeyCOSBqvFuBvh9su2l125K7s23dY6I7g6Ly+c4k66h8soOfF epjgi3Hq8bTuezWmiDaSVD3YxrCOU21kYWCwZaIdKXr02eX/mPr3nhb0Ag8cfZb6DeOR g1DUgxp8MEQY4anLbSeGUZ8bmxC9royvf1EIMZK753gqsAqfqxT7xbCfgLn2+gBfyzzK 501rltymozIWQY0q2fy4d1Je30kGJy/082kQEBUqHTNUZwnXjcUZSHciFnHbwWBii6d3 UN5k7KDhO1sF59lpmTi3P1ieU+fTz6YrUg9VEf9S2LhoIBB6dmyhuhQxL79Qc5Q96ocp wTnw==
MIME-Version 1.0
In-Reply-To <1eb7cd76-ade3-4c34-8816-6eaa7201262e@googlegroups.com>
References <1eb7cd76-ade3-4c34-8816-6eaa7201262e@googlegroups.com>
Date Sat, 12 Jan 2013 09:27:21 +1100
Subject Re: Problem with importing in Python
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.416.1357943251.2939.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1357943251 news.xs4all.nl 6849 [2001:888:2000:d::a6]:49228
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:36649

Show key headers only | View raw


On Sat, Jan 12, 2013 at 9:17 AM, su29090 <129km09@gmail.com> wrote:
> Circle.py
>
> class circle:
>
> from Circle import Circle

Inside the Circle module is a class named circle. You can't import
Circle from that.

But Python isn't Java. You don't have to put each class into its own
file. Just put class circle (or class Circle to follow Python naming
convention) into the other file, whose name you haven't given.

If they're already in the same file, then just drop the import. Easy!

By the way:
>    main() # Call the main function
You'll need to put that flush left. At the moment, that call is part
of the definition of main().

Hope that helps!

ChrisA

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


Thread

Problem with importing in Python su29090 <129km09@gmail.com> - 2013-01-11 14:17 -0800
  Re: Problem with importing in Python Adnan Sadzak <sadzak@gmail.com> - 2013-01-11 23:25 +0100
    Re: Problem with importing in Python su29090 <129km09@gmail.com> - 2013-01-11 14:29 -0800
    Re: Problem with importing in Python su29090 <129km09@gmail.com> - 2013-01-11 14:29 -0800
  Re: Problem with importing in Python Chris Angelico <rosuav@gmail.com> - 2013-01-12 09:27 +1100
    Re: Problem with importing in Python su29090 <129km09@gmail.com> - 2013-01-11 14:38 -0800
    Re: Problem with importing in Python su29090 <129km09@gmail.com> - 2013-01-11 14:38 -0800
  Re: Problem with importing in Python Dave Angel <d@davea.name> - 2013-01-11 17:43 -0500
    Re: Problem with importing in Python su29090 <129km09@gmail.com> - 2013-01-11 15:23 -0800
    Re: Problem with importing in Python su29090 <129km09@gmail.com> - 2013-01-11 15:23 -0800
    Re: Problem with importing in Python Tim Roberts <timr@probo.com> - 2013-01-11 20:37 -0800
      Re: Problem with importing in Python Chris Angelico <rosuav@gmail.com> - 2013-01-12 15:54 +1100
      Re: Problem with importing in Python Dave Angel <d@davea.name> - 2013-01-12 00:14 -0500
  Re: Problem with importing in Python Terry Reedy <tjreedy@udel.edu> - 2013-01-11 22:53 -0500

csiph-web