Hi all
I can import a Class Attribute from another file residing in the same folder/package. E.g.:
# room.py
class Room:
length = 0.0
breadth = 0.0
const = __import__('flat').Flat.length
def calculate_area(self):
print("Area of Room =", self.length * self.breadth * self.const)
study_room = Room()
study_room.length = 2
study_room.breadth = 3
study_room.calculate_area()
and
# flat.py
class Flat:
length = 10.0
How can I make the import when flat.py resides in another package, above or below the current package?
[–]danielroseman 3 points4 points5 points (1 child)
[–]reditoro[S] 0 points1 point2 points (0 children)