I'm restarting a project I did in Java, trying to learn about Python in POO, but I'm stuck on something I have not found any solution to:
I have 2 files ("working.py" and ".py files").
The 2nd is responsible for any services related to file (writing, testing, reading ...), all cute inside a class named Files.
But when I try to import somehow it works I get an error from some function that has not been defined. The overwhelming majority of functions within .py files depends on a name function .
working.py:
"""==========
trabalhando.py
=========="""
from arquivos import Arquivos
a = Arquivos()
print(a.le("banco.txt")) #Uma lista do tamanho da qtd de linhas
files.py:
"""==========
arquivos.py
=========="""
class Arquivos:
#testes
def existe (nome):
try:
with open(nome, "r") as arquivo:
pass
except IOError:
return (nome, "w")
arquivo.close
return (nome, "a")
#leitura de arquivo
def le (arquivo):
objeto = existe(arquivo) ##<= linha problema
if (objeto == (arquivo, "w")):
return []
file = open(objeto[0], "r")
texto = []
for i in file:
if (i == "\n"):
continue
texto.insert(len(texto), i[:i.index("\n")])
if (len(texto)%136 == 0):
print(aguarde(len(texto)))
file.close
return texto
So, how do I call the .py file (.py file) function without it pointing me to "exists not defined" problem?