smart
smart

Reputation: 161

Importing files from another program

I have this program named

program.py

When i try to import it using the line:

import program.py as p

it makes an error that no such file exists.

Upvotes: 1

Views: 21

Answers (1)

Aliaksandr S.
Aliaksandr S.

Reputation: 1176

The line:

.py

is used to identify that the program is in Python. To import anything, you only type:

import program as p

Unless a file or module with the same name exists.

Upvotes: 3

Related Questions