Avatar ·

ImportError: attempted relative import with no known parent package python

📁 Advanced Python Topics, Error, project

I have the following project structure

---package1/code.py---package2/ext.py

How can I import a variable from ext.py into code.py?

from ext import var - doesn't work, says module ext does not exist

from ..package2.ext import var - also doesn't work, gives error: ImportError: attempted relative import with no known parent package

Avatar ·
to_float(to_int(a) + to_int(b)) == a + bto_int(a) < to_int(b) when a < b, etc.

I remembered that in Python ints are infinite. has 11 bits for the exponent, so when multiplying by 2**(2**12) you get an integer that can be stored in an int. You just need to multiply during the conversion, not the fractional number - otherwise overflow will occur.

Log in to leave an answer

Blogs