In Python, If I want to import a file from a different directory then I'm supposed to do that,
import sys
sys.path.append("/path")
Now,
I have two files to be imported,
File1.py and File2.py,
these are the locations of the files,
MyFiles/File1.py
MyFiles/File2.py
Now, If I want to import these two files, I'd do that
from MyFiles import File1
from MyFiles import File2
this shouldn't work because I haven't defined the path for these files using sys.path
But when I am running my code the files are importing successfully without defining the path using sys.path
This is the code,
from __future__ import print_function
import sys
import os
import hashlib
import struct #Interpret strings as packed binary data
import getopt #for Runtime arguments
from MyFiles import File1
from MyFiles import File2
Eventhough, I haven't defined sys.path , this code is still successfully importing the files from the directory.
and the path is not already available in sys.path
['C:\\Users\\Sufiyan\\Desktop\\MyFolder', 'C:\\Windows\\SYSTEM32\\python33.zip', 'C:\
\Python33\\DLLs', 'C:\\Python33\\lib', 'C:\\Python33', 'C:\\Python33\\lib\\site-
packages']
It is clear that the path,
C:\\Users\\Sufiyan\\Desktop\\MyFolder\\MyFiles
is not there.
then why this code is working ?