You need to do from file1 import x
or class y(file1.x)
to make this work.
EDIT: Make sure you have no spaces in your file names. Maybe it's just a typo in your question, but at the top of File2 you are saying import File 1
instead of import File1
. If the name of your Python module corresponding to File1 does indeed contain one or more spaces, you should remove them (or replace them with underscores), both in the file name and the import
statement. As explained in the accepted answer to this question, file names are used as identifiers for imported modules, and Python identifiers can't contain spaces.