Hello Friends,
I am an absolutely beginner in the world of computer programming. I started my voyage in this world yesterday by starting learning Python. I am reading an e-book on python here. That book has been written with examples from Linux platform. So, I felt this problem while going through that book.
I want to ask you that If I have a python script present in my computer at say D:\Python Practice\mytest1.py then what I should do to be able to use all the functions defined in this script in the Python shell? I mean what command I should run to import the functions of this script into my python shell.

In addition is there a way of starting the python shell from the directory in which my target script is present so that I don't have to write its absolute path but only its file name??????

Thankyou very much in advance!!!!!

Recommended Answers

All 2 Replies

import is taking files usually from the same directory as the script you write without problem, you only make sure that '.' is in your systems path or define another path variable PYTHONPATH with value D:\Python Practice\ or other locations of your own modules/books modules will be saved.

Also it is possible to put the modules in standard location for modules in <your python location>\Lib\site-packages

python shell
File->new window
Write or paste in your code
To make it run-->run(F5)

Get a good editor is smart like pyscripter.
Here you can run all code bye push the run button.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.