How to import a function from another module...
Dwight at GoldWinde.com
Tue Aug 4 14:35:57 CEST 2015
> Thank you, Steven.
> I am a newbie with Python? so I really want to learn how to do it the easy
> 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" <steve at 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 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
>> >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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list