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


Groups > comp.lang.python > #95223

Re: Importing is partially working...

Path csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!border2.nntp.ams1.giganews.com!nntp.giganews.com!bcyclone05.am1.xlned.com!bcyclone05.am1.xlned.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.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; 'python,': 0.02; 'importerror:': 0.05; 'source.': 0.05; 'stored': 0.10; 'python': 0.10; 'file,': 0.15; 'interpreter': 0.15; 'dlls': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'function?': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'need,': 0.16; 'received:192.168.1.4': 0.16; 'work.)': 0.16; 'wrote:': 0.16; 'module,': 0.18; '2015': 0.20; 'aug': 0.20; 'extension': 0.20; '(on': 0.22; 'seems': 0.23; "haven't": 0.24; 'import': 0.24; '(most': 0.24; 'implemented': 0.24; 'header:In-Reply-To:1': 0.24; 'module': 0.25; 'header:User-Agent:1': 0.26; 'chris': 0.26; "skip:' 10": 0.28; 'sentence': 0.29; 'there!': 0.29; 'windows,': 0.29; 'anywhere': 0.30; 'work.': 0.30; 'code': 0.30; 'probably': 0.31; 'traceback': 0.33; 'file': 0.34; 'so,': 0.35; 'something': 0.35; 'but': 0.36; 'loaded': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'there,': 0.37; 'say': 0.37; 'does': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'your': 0.60; 'special': 0.73; 'precompiled': 0.84; 'coach': 0.93
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=CvRCCSMD c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=EBOSESyhAAAA:8 a=UWU4mQFGWXkA:10 a=IkcTkHD0fZMA:10 a=8_iErv3XAAAA:8 a=iyBtf6O4YI-SHv7CLAEA:9 a=QEXdDO2ut3YA:10
X-AUTH mrabarnett@:2500
Subject Re: Importing is partially working...
To python-list@python.org
References <D1ED09E0.10CC86%Dwight@GoldWinde.com> <CAPTjJmrPQ2PUnh46+C_=eKp8cy0nEtz4+P9k2qAeJYFxLopXcg@mail.gmail.com>
From MRAB <python@mrabarnett.plus.com>
Date Mon, 10 Aug 2015 16:48:59 +0100
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0
MIME-Version 1.0
In-Reply-To <CAPTjJmrPQ2PUnh46+C_=eKp8cy0nEtz4+P9k2qAeJYFxLopXcg@mail.gmail.com>
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.44.1439221743.3627.python-list@python.org> (permalink)
Lines 39
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1439221743 news.xs4all.nl 2827 [2001:888:2000:d::a6]:57681
X-Complaints-To abuse@xs4all.nl
X-Received-Bytes 4563
X-Received-Body-CRC 768188882
Xref csiph.com comp.lang.python:95223

Show key headers only | View raw


On 2015-08-10 11:11, Chris Angelico wrote:
> On Sun, Aug 9, 2015 at 3:45 PM, Dwight GoldWinde <Dwight@goldwinde.com> wrote:
>> name = 'Jim'
>> coach = 'Dwight'
>> import importlib
>> sentence = 'Hi, there, ' + name + '. My name is ' + coach + '. I will be
>> your coach today.'
>> from Functions.py import humprint
>> humprint (sentence)
>>
>> Traceback (most recent call last):
>>
>>   File "Intro.py", line 5, in <module>
>>
>>     from Functions.py import humprint
>>
>> ImportError: No module named 'Functions.py'; 'Functions' is not a package
>>
>>
>>
>> So, it seems like it is accessing the module, but not the function?
>
> You're almost there! But in Python, you don't import something from a
> specific file - you import from a module, and the Python interpreter
> is free to locate that file anywhere that it can. It might be
> implemented in C, and be stored in Functions.so (on Unix-like systems)
> or Functions.dll (on Windows); it might be precompiled and loaded from
> Functions.pyc; it might come from a zip file, or some other form of
> special import source. So all you say is:
>
On Windows, the extension for Python extension DLLs is ".pyd".

> from Functions import humprint
>
> and Python does the rest. Yep, that's all the change you need, and
> your code will most likely work. (I haven't tested it, but it'll
> probably work.)
>

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


Thread

Re: Importing is partially working... MRAB <python@mrabarnett.plus.com> - 2015-08-10 16:48 +0100
  Re: Importing is partially working... Steven D'Aprano <steve@pearwood.info> - 2015-08-11 12:40 +1000

csiph-web