Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'newbie': 0.05; 'that?': 0.05; 'subject:How': 0.09; 'imported.': 0.09; 'path.': 0.09; 'python': 0.10; '>in': 0.16; '>on': 0.16; 'importable': 0.16; 'received:yourhostingaccount.com': 0.16; 'subject:import': 0.16; 'wrote:': 0.16; '>': 0.18; 'python?': 0.18; 'language': 0.19; '>>>': 0.20; '2015': 0.20; 'aug': 0.20; '(all': 0.22; 'simpler': 0.22; 'trying': 0.22; 'am,': 0.23; 'defined': 0.23; 'this:': 0.23; 'import': 0.24; 'script': 0.25; 'header:User-Agent:1': 0.26; 'skip:" 20': 0.26; 'parameters': 0.27; 'module.': 0.27; 'function': 0.28; 'always,': 0.29; 'spaces': 0.29; 'books': 0.30; 'url:mailman': 0.30; 'work.': 0.30; 'another': 0.32; "can't": 0.32; 'language.': 0.32; 'url:python': 0.33; 'url:listinfo': 0.34; 'tue,': 0.34; 'file': 0.34; 'skip:d 20': 0.34; 'skip:& 20': 0.35; 'could': 0.35; 'arrange': 0.35; 'skip:i 20': 0.36; 'url:org': 0.36; 'received:10.20': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'really': 0.37; 'received:66': 0.38; 'names': 0.38; 'skip:p 20': 0.38; 'thank': 0.38; 'subject:from': 0.39; 'url:mail': 0.40; 'to:addr:python.org': 0.40; 'easy': 0.60; 'your': 0.60; 'within': 0.64; 'life': 0.67; '>from': 0.76; '>you': 0.84; 'received:112': 0.93; 'fight': 0.97 X-Authority-Analysis: v=2.1 cv=MLvumapl c=1 sm=1 tr=0 a=eBvjjtMVdWwtQGedh7GyLg==:117 a=PoOWLfzGka9mwUgIqhcdbQ==:17 a=pq4jwCggAAAA:8 a=QPcu4mC3AAAA:8 a=8_iErv3XAAAA:8 a=1E9jo8_qk6kA:10 a=wpL1jeqTJocA:10 a=uRRa74qj2VoA:10 a=PeFO9FbFhS32YxYntvkA:9 a=IHpK4gAxAAAA:8 a=kZ7UWmmPAAAA:8 a=8AHkEIZyAAAA:8 a=nMTaA3EHI4hiXbs1CfwA:9 a=4VmKGKSqCdEA:10 a=ji7QSrVxmoL8bka_UHYA:9 a=jJU4q9EP0pW17xVL:21 a=_W_S_7VecoQA:10 User-Agent: Microsoft-MacOutlook/14.4.7.141117 Date: Tue, 04 Aug 2015 20:35:57 +0800 Subject: Re: How to import a function from another module... From: Dwight GoldWinde To: Python Python Thread-Topic: How to import a function from another module... Mime-version: 1.0 Content-type: multipart/alternative; boundary="B_3521565391_27651480" X-EN-UserInfo: 6c5a25a10f5591a3de9585e9195aba16:931c98230c6409dcc37fa7e93b490c27 X-EN-AuthUser: dwight@goldwinde.com Sender: Dwight GoldWinde X-EN-OrigIP: 112.117.105.244 X-EN-OrigHost: unknown X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 101 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1438693831 news.xs4all.nl 2931 [2001:888:2000:d::a6]:35515 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:94963 > This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --B_3521565391_27651480 Content-type: text/plain; charset="Big5" Content-transfer-encoding: 7bit > Thank you, Steven. > I am a newbie with Python? so I really want to learn how to do it the easy > way. > Yes, could you tell me how to put the py.file that contains the function > in the Python search path??? > BIG SMILE... > Always, Dwight > www.3forliving.key.to (video playlist on YouTube) > www.couragebooks.key.to (all my books on Amazon) > On 8/4/15, 9:24 AM, "Steven D'Aprano" wrote: >> >On Tue, 4 Aug 2015 09:57 am, Dwight GoldWinde wrote: >> > >>> >> I am trying to import a function defined in another module. >> > >> >You can't use spaces in the name of importable Python modules: change the >> >name from "Simulate typing.py" to "simulate_python.py". You can use spaces >> >in file names if they are only used as a runnable script and not imported. >> > >> >Then use this: >> > >> >from simulate_python import humprint >> > >> >There's no need to use importlib. >> > >> >You may need to arrange for the simulate_python file to be placed >> >somewhere >> >in the Python search path. Do you need help with that? >> > >> >What you are trying to do with importlib is fight the language. Your life >> >will be much simpler if you work within the parameters of how the language >> >is designed to work. >> > >> > >> > >> >-- >> >Steven >> > >> >-- >> >https://mail.python.org/mailman/listinfo/python-list > --B_3521565391_27651480 Content-type: text/html; charset="Big5" Content-transfer-encoding: quoted-printable
Thank you, Steven.
= I am a newbie with Python? so I really want to learn how to do it the easy
way.
Yes, could you tell me how to put the py.file that c= ontains the function
in the Python search path???

BIG SMILE...
Always, Dwight=
www.3forliving.key.to (video playlist on Yo= uTube)
www.couragebooks.key.to (all my books on Amazon)

On 8/4/15, 9:24 AM, "Steven D'Aprano" <steve@pearwood.info> wrote:
>= On Tue, 4 Aug 2015 09:57 am, Dwight GoldWinde wrote:
>
>> I am trying to import a function defined in another module.
=
>
>You can't use spaces in the name of importable Pytho= n modules: change the
>name from "Simulate typing.py" to "simul= ate_python.py". You can use spaces
>in file names if they are o= nly used as a runnable script and not imported.
>
>= ;Then use this:
>
>from simulate_python import hum= print
>
>There's no need to use importlib.
>
>You may need to arrange for the simulate_python file t= o be placed
>somewhere
>in the Python search path.= Do you need help with that?
>
>What you are tryin= g to do with importlib is fight the language. Your life
>will b= e much simpler if you work within the parameters of how the language
>is designed to work.
>
>
>
>-- 
>Steven
>
>--&nbs= p;

<= /div>
--B_3521565391_27651480--