# how to make a line break in a text object from an external file

So I am controlling a test object's text property from an external text file with this code

def text():
import bge
from bge import logic
path = logic.expandPath('//')

cont= logic.getCurrentController()
scene= logic.getCurrentScene()
own= cont.owner
T= int(own['t'])

try:
file = open(path+'text_file.txt', 'r')
own.text = info[T]
except:
print('error')


it works fine except for if I want line breaks so it doesn't stretch off the box i have it in. for example i have the veriable 't' set to 0 and the first line of the txt doc says "example text for stuff" but i want a line break between "text" and "for". If i was setting the normal text vaule and wanted a break there i'd have the code

own.text='example text\nfor stuff'


but if i type that in the txt file it just displays the line break command (\n). how do i make a line break command from inside the txt file be recognized by python? or is it even possible.

When the text file is read, no interpretation is made of what is written, is just text. For that reason yo sould write in the text file as: own.text = 'write it in \na new line' and then in your script use exec.

from bge import logic

def text():
path = logic.expandPath('//')
cont= logic.getCurrentController()
scene= logic.getCurrentScene()
own= cont.owner

try:
file = open(path+'text_file.txt', 'r')