Why is there a difference between these?:
# Python
f = open("./text.txt", "r")
for i in f.readlines():
for l in i:
print(print(l == "\n", ":", l))
f.close()
# -----------------------------
# Julia
f = open("./text.txt", "r")
while !eof(f)
for l in readline(file)
println(l == '\n', " : ", l)
end
end
close(f)
The Python one outputs this:
False : h
False : e
False : l
False : l
False : o
False :
False : W
False : o
False : r
False : l
False : d
True :
<--- yep, it is as expected
False : y
False : a
False : y
The Julia one outputs this:
false : h
false : e
false : l
false : l
false : o
false : <--- is this not a \n??
false : W
false : o
false : r
false : l
false : d
false : y
false : a
false : y
text.txt is this:
hello World
yay
As you can see the outputs are different. How can I make the Julia one behaves like the Python one? Are there other ways of reading a file in Julia?