Estou fazendo um programa em python(2,7) onde pego infos de um arquivo,e armazendo como objetos em uma lista, eu gostaria de imprimir a lista mas só retorna os endereços, estou aprendendo a programar em python e nenhuma resposta que encontro para isso me serve. Como posso imprimir isso como string?
Exemplo do arquivo:(Não sei como deixar na formatação correta mas entre os espaços existe uma tabulação) 3 s 43-12 31
Classe que funciona como uma struct:
class Expressao(object):
def __init__(self, nivel, tipo, expressao, resposta):
self.nivel = nivel
self.tipo = tipo
self.expressao = expressao
self.resposta = resposta
Classe que pega o arquivo e armazena numa lista como objetos:
class FonteDeExpressoes(object):
import csv
def lista (self):
expressoes = []
with open('exp.txt') as f:
for line in f:
row = line.split('\t')
exp = Expressao(row[0], row[1], row[2], row[3])
expressoes.append(exp)
#print expressoes
return expressoes
Resultado do Print FonteDeExpressoes().lista()
[<__main__.Expressao object at 0x7f09343ad710>, <__main__.Expressao object at 0x7f093b7e25d0>, <__main__.Expressao object at 0x7f093b7e2e90>, <__main__.Expressao object at 0x7f0934017050>, <__main__.Expressao object at 0x7f0934017090>, <__main__.Expressao object at 0x7f09340170d0>, <__main__.Expressao object at 0x7f0934017110>, <__main__.Expressao object at 0x7f0934017150>, <__main__.Expressao object at 0x7f0934017190>, <__main__.Expressao object at 0x7f09340171d0>, <__main__.Expressao object at 0x7f0934017210>, <__main__.Expressao object at 0x7f0934017250>, <__main__.Expressao object at 0x7f0934017290>, <__main__.Expressao object at 0x7f09340172d0>, <__main__.Expressao object at 0x7f0934017310>, <__main__.Expressao object at 0x7f0934017350>, <__main__.Expressao object at 0x7f0934017390>, <__main__.Expressao object at 0x7f09340173d0>, <__main__.Expressao object at 0x7f0934017410>, <__main__.Expressao object at 0x7f0934017450>, <__main__.Expressao object at 0x7f0934017490>, <__main__.Expressao object at 0x7f09340174d0>, <__main__.Expressao object at 0x7f0934017510>, <__main__.Expressao object at 0x7f0934017550>, <__main__.Expressao object at 0x7f0934017590>, <__main__.Expressao object at 0x7f09340175d0>, <__main__.Expressao object at 0x7f0934017610>, <__main__.Expressao object at 0x7f0934017650>, <__main__.Expressao object at 0x7f0934017690>, <__main__.Expressao object at 0x7f09340176d0>, <__main__.Expressao object at 0x7f0934017710>, <__main__.Expressao object at 0x7f0934017750>, <__main__.Expressao object at 0x7f0934017790>, <__main__.Expressao object at 0x7f09340177d0>, <__main__.Expressao object at 0x7f0934017810>, <__main__.Expressao object at 0x7f0934017850>, <__main__.Expressao object at 0x7f0934017890>, <__main__.Expressao object at 0x7f09340178d0>, <__main__.Expressao object at 0x7f0934017910>, <__main__.Expressao object at 0x7f0934017950>, <__main__.Expressao object at 0x7f0934017990>, <__main__.Expressao object at 0x7f09340179d0>, <__main__.Expressao object at 0x7f0934017a10>, <__main__.Expressao object at 0x7f0934017a50>, <__main__.Expressao object at 0x7f0934017a90>, <__main__.Expressao object at 0x7f0934017ad0>, <__main__.Expressao object at 0x7f0934017b10>, <__main__.Expressao object at 0x7f0934017b50>, <__main__.Expressao object at 0x7f0934017b90>, <__main__.Expressao object at 0x7f0934017bd0>, <__main__.Expressao object at 0x7f0934017c10>, <__main__.Expressao object at 0x7f0934017c50>, <__main__.Expressao object at 0x7f0934017c90>, <__main__.Expressao object at 0x7f0934017cd0>, <__main__.Expressao object at 0x7f0934017d10>, <__main__.Expressao object at 0x7f0934017d50>, <__main__.Expressao object at 0x7f0934017d90>, <__main__.Expressao object at 0x7f0934017dd0>, <__main__.Expressao object at 0x7f0934017e10>, <__main__.Expressao object at 0x7f0934017e50>, <__main__.Expressao object at 0x7f0934017e90>, <__main__.Expressao object at 0x7f0934017ed0>, <__main__.Expressao object at 0x7f0934017f10>, <__main__.Expressao object at 0x7f0934017f50>, <__main__.Expressao object at 0x7f0934017f90>, <__main__.Expressao object at 0x7f0934017fd0>, <__main__.Expressao object at 0x7f0934045050>, <__main__.Expressao object at 0x7f0934045090>, <__main__.Expressao object at 0x7f09340450d0>, <__main__.Expressao object at 0x7f0934045110>, <__main__.Expressao object at 0x7f0934045150>, <__main__.Expressao object at 0x7f0934045190>, <__main__.Expressao object at 0x7f09340451d0>, <__main__.Expressao object at 0x7f0934045210>, <__main__.Expressao object at 0x7f0934045250>, <__main__.Expressao object at 0x7f0934045290>, <__main__.Expressao object at 0x7f09340452d0>, <__main__.Expressao object at 0x7f0934045310>, <__main__.Expressao object at 0x7f0934045350>, <__main__.Expressao object at 0x7f0934045390>, <__main__.Expressao object at 0x7f09340453d0>, <__main__.Expressao object at 0x7f0934045410>, <__main__.Expressao object at 0x7f0934045450>, <__main__.Expressao object at 0x7f0934045490>, <__main__.Expressao object at 0x7f09340454d0>, <__main__.Expressao object at 0x7f0934045510>, <__main__.Expressao object at 0x7f0934045550>, <__main__.Expressao object at 0x7f0934045590>, <__main__.Expressao object at 0x7f09340455d0>, <__main__.Expressao object at 0x7f0934045610>, <__main__.Expressao object at 0x7f0934045650>, <__main__.Expressao object at 0x7f0934045690>, <__main__.Expressao object at 0x7f09340456d0>, <__main__.Expressao object at 0x7f0934045710>, <__main__.Expressao object at 0x7f0934045750>, <__main__.Expressao object at 0x7f0934045790>, <__main__.Expressao object at 0x7f09340457d0>, <__main__.Expressao object at 0x7f0934045810>, <__main__.Expressao object at 0x7f0934045850>, <__main__.Expressao object at 0x7f0934045890>, <__main__.Expressao object at 0x7f09340458d0>, <__main__.Expressao object at 0x7f0934045910>, <__main__.Expressao object at 0x7f0934045950>, <__main__.Expressao object at 0x7f0934045990>, <__main__.Expressao object at 0x7f09340459d0>, <__main__.Expressao object at 0x7f0934045a10>, <__main__.Expressao object at 0x7f0934045a50>, <__main__.Expressao object at 0x7f0934045a90>, <__main__.Expressao object at 0x7f0934045ad0>, <__main__.Expressao object at 0x7f0934045b10>, <__main__.Expressao object at 0x7f0934045b50>, <__main__.Expressao object at 0x7f0934045b90>, <__main__.Expressao object at 0x7f0934045bd0>, <__main__.Expressao object at 0x7f0934045c10>, <__main__.Expressao object at 0x7f0934045c50>, <__main__.Expressao object at 0x7f0934045c90>, <__main__.Expressao object at 0x7f0934045cd0>, <__main__.Expressao object at 0x7f0934045d10>, <__main__.Expressao object at 0x7f0934045d50>, <__main__.Expressao object at 0x7f0934045d90>, <__main__.Expressao object at 0x7f0934045dd0>, <__main__.Expressao object at 0x7f0934045e10>, <__main__.Expressao object at 0x7f0934045e50>, <__main__.Expressao object at 0x7f0934045e90>, <__main__.Expressao object at 0x7f0934045ed0>, <__main__.Expressao object at 0x7f0934045f10>, <__main__.Expressao object at 0x7f0934045f50>, <__main__.Expressao object at 0x7f0934045f90>, <__main__.Expressao object at 0x7f0934045fd0>, <__main__.Expressao object at 0x7f0934029050>, <__main__.Expressao object at 0x7f0934029090>, <__main__.Expressao object at 0x7f09340290d0>, <__main__.Expressao object at 0x7f0934029110>, <__main__.Expressao object at 0x7f0934029150>, <__main__.Expressao object at 0x7f0934029190>, <__main__.Expressao object at 0x7f09340291d0>, <__main__.Expressao object at 0x7f0934029210>, <__main__.Expressao object at 0x7f0934029250>, <__main__.Expressao object at 0x7f0934029290>, <__main__.Expressao object at 0x7f09340292d0>, <__main__.Expressao object at 0x7f0934029310>, <__main__.Expressao object at 0x7f0934029350>, <__main__.Expressao object at 0x7f0934029390>, <__main__.Expressao object at 0x7f09340293d0>, <__main__.Expressao object at 0x7f0934029410>, <__main__.Expressao object at 0x7f0934029450>, <__main__.Expressao object at 0x7f0934029490>, <__main__.Expressao object at 0x7f09340294d0>, <__main__.Expressao object at 0x7f0934029510>, <__main__.Expressao object at 0x7f0934029550>, <__main__.Expressao object at 0x7f0934029590>, <__main__.Expressao object at 0x7f09340295d0>, <__main__.Expressao object at 0x7f0934029610>, <__main__.Expressao object at 0x7f0934029650>, <__main__.Expressao object at 0x7f0934029690>, <__main__.Expressao object at 0x7f09340296d0>, <__main__.Expressao object at 0x7f0934029710>, <__main__.Expressao object at 0x7f0934029750>, <__main__.Expressao object at 0x7f0934029790>, <__main__.Expressao object at 0x7f09340297d0>, <__main__.Expressao object at 0x7f0934029810>, <__main__.Expressao object at 0x7f0934029850>, <__main__.Expressao object at 0x7f0934029890>, <__main__.Expressao object at 0x7f09340298d0>, <__main__.Expressao object at 0x7f0934029910>, <__main__.Expressao object at 0x7f0934029950>, <__main__.Expressao object at 0x7f0934029990>, <__main__.Expressao object at 0x7f09340299d0>, <__main__.Expressao object at 0x7f0934029a10>, <__main__.Expressao object at 0x7f0934029a50>, <__main__.Expressao object at 0x7f0934029a90>, <__main__.Expressao object at 0x7f0934029ad0>, <__main__.Expressao object at 0x7f0934029b10>, <__main__.Expressao object at 0x7f0934029b50>, <__main__.Expressao object at 0x7f0934029b90>, <__main__.Expressao object at 0x7f0934029bd0>, <__main__.Expressao object at 0x7f0934029c10>, <__main__.Expressao object at 0x7f0934029c50>, <__main__.Expressao object at 0x7f0934029c90>, <__main__.Expressao object at 0x7f0934029cd0>, <__main__.Expressao object at 0x7f0934029d10>, <__main__.Expressao object at 0x7f0934029d50>, <__main__.Expressao object at 0x7f0934029d90>, <__main__.Expressao object at 0x7f0934029dd0>, <__main__.Expressao object at 0x7f0934029e10>, <__main__.Expressao object at 0x7f0934029e50>, <__main__.Expressao object at 0x7f0934029e90>, <__main__.Expressao object at 0x7f0934029ed0>, <__main__.Expressao object at 0x7f0934029f10>, <__main__.Expressao object at 0x7f0934029f50>, <__main__.Expressao object at 0x7f0934029f90>, <__main__.Expressao object at 0x7f0934029fd0>, <__main__.Expressao object at 0x7f093401f050>, <__main__.Expressao object at 0x7f093401f090>, <__main__.Expressao object at 0x7f093401f0d0>, <__main__.Expressao object at 0x7f093401f110>, <__main__.Expressao object at 0x7f093401f150>, <__main__.Expressao object at 0x7f093401f190>, <__main__.Expressao object at 0x7f093401f1d0>, <__main__.Expressao object at 0x7f093401f210>, <__main__.Expressao object at 0x7f093401f250>, <__main__.Expressao object at 0x7f093401f290>, <__main__.Expressao object at 0x7f093401f2d0>, <__main__.Expressao object at 0x7f093401f310>, <__main__.Expressao object at 0x7f093401f350>, <__main__.Expressao object at 0x7f093401f390>, <__main__.Expressao object at 0x7f093401f3d0>, <__main__.Expressao object at 0x7f093401f410>, <__main__.Expressao object at 0x7f093401f450>, <__main__.Expressao object at 0x7f093401f490>, <__main__.Expressao object at 0x7f093401f4d0>, <__main__.Expressao object at 0x7f093401f510>, <__main__.Expressao object at 0x7f093401f550>, <__main__.Expressao object at 0x7f093401f590>, <__main__.Expressao object at 0x7f093401f5d0>, <__main__.Expressao object at 0x7f093401f610>, <__main__.Expressao object at 0x7f093401f650>, <__main__.Expressao object at 0x7f093401f690>, <__main__.Expressao object at 0x7f093401f6d0>, <__main__.Expressao object at 0x7f093401f710>, <__main__.Expressao object at 0x7f093401f750>, <__main__.Expressao object at 0x7f093401f790>, <__main__.Expressao object at 0x7f093401f7d0>, <__main__.Expressao object at 0x7f093401f810>, <__main__.Expressao object at 0x7f093401f850>, <__main__.Expressao object at 0x7f093401f890>, <__main__.Expressao object at 0x7f093401f8d0>, <__main__.Expressao object at 0x7f093401f910>, <__main__.Expressao object at 0x7f093401f950>, <__main__.Expressao object at 0x7f093401f990>, <__main__.Expressao object at 0x7f093401f9d0>, <__main__.Expressao object at 0x7f093401fa10>, <__main__.Expressao object at 0x7f093401fa50>, <__main__.Expressao object at 0x7f093401fa90>, <__main__.Expressao object at 0x7f093401fad0>, <__main__.Expressao object at 0x7f093401fb10>, <__main__.Expressao object at 0x7f093401fb50>, <__main__.Expressao object at 0x7f093401fb90>, <__main__.Expressao object at 0x7f093401fbd0>, <__main__.Expressao object at 0x7f093401fc10>, <__main__.Expressao object at 0x7f093401fc50>, <__main__.Expressao object at 0x7f093401fc90>, <__main__.Expressao object at 0x7f093401fcd0>, <__main__.Expressao object at 0x7f093401fd10>, <__main__.Expressao object at 0x7f093401fd50>, <__main__.Expressao object at 0x7f093401fd90>, <__main__.Expressao object at 0x7f093401fdd0>, <__main__.Expressao object at 0x7f093401fe10>, <__main__.Expressao object at 0x7f093401fe50>, <__main__.Expressao object at 0x7f093401fe90>, <__main__.Expressao object at 0x7f093401fed0>, <__main__.Expressao object at 0x7f093401ff50>, <__main__.Expressao object at 0x7f093401ff10>, <__main__.Expressao object at 0x7f093401ff90>, <__main__.Expressao object at 0x7f0934039050>, <__main__.Expressao object at 0x7f093401ffd0>, <__main__.Expressao object at 0x7f0934039090>, <__main__.Expressao object at 0x7f09340390d0>, <__main__.Expressao object at 0x7f0934039110>, <__main__.Expressao object at 0x7f0934039150>, <__main__.Expressao object at 0x7f0934039190>, <__main__.Expressao object at 0x7f09340391d0>, <__main__.Expressao object at 0x7f0934039210>, <__main__.Expressao object at 0x7f0934039250>, <__main__.Expressao object at 0x7f0934039290>, <__main__.Expressao object at 0x7f09340392d0>, <__main__.Expressao object at 0x7f0934039310>, <__main__.Expressao object at 0x7f0934039350>, <__main__.Expressao object at 0x7f0934039390>, <__main__.Expressao object at 0x7f09340393d0>, <__main__.Expressao object at 0x7f0934039410>, <__main__.Expressao object at 0x7f0934039450>, <__main__.Expressao object at 0x7f0934039490>, <__main__.Expressao object at 0x7f09340394d0>, <__main__.Expressao object at 0x7f0934039510>, <__main__.Expressao object at 0x7f0934039550>, <__main__.Expressao object at 0x7f0934039590>, <__main__.Expressao object at 0x7f09340395d0>, <__main__.Expressao object at 0x7f0934039610>, <__main__.Expressao object at 0x7f0934039650>, <__main__.Expressao object at 0x7f0934039690>, <__main__.Expressao object at 0x7f09340396d0>, <__main__.Expressao object at 0x7f0934039710>, <__main__.Expressao object at 0x7f0934039750>, <__main__.Expressao object at 0x7f0934039790>, <__main__.Expressao object at 0x7f09340397d0>, <__main__.Expressao object at 0x7f0934039810>, <__main__.Expressao object at 0x7f0934039850>, <__main__.Expressao object at 0x7f0934039890>, <__main__.Expressao object at 0x7f09340398d0>, <__main__.Expressao object at 0x7f0934039910>, <__main__.Expressao object at 0x7f0934039950>, <__main__.Expressao object at 0x7f0934039990>, <__main__.Expressao object at 0x7f09340399d0>, <__main__.Expressao object at 0x7f0934039a10>, <__main__.Expressao object at 0x7f0934039a50>, <__main__.Expressao object at 0x7f0934039a90>, <__main__.Expressao object at 0x7f0934039ad0>, <__main__.Expressao object at 0x7f0934039b10>, <__main__.Expressao object at 0x7f0934039b50>, <__main__.Expressao object at 0x7f0934039b90>, <__main__.Expressao object at 0x7f0934039bd0>, <__main__.Expressao object at 0x7f0934039c10>, <__main__.Expressao object at 0x7f0934039c50>, <__main__.Expressao object at 0x7f0934039c90>, <__main__.Expressao object at 0x7f0934039cd0>, <__main__.Expressao object at 0x7f0934039d10>, <__main__.Expressao object at 0x7f0934039d50>, <__main__.Expressao object at 0x7f0934039d90>, <__main__.Expressao object at 0x7f0934039dd0>, <__main__.Expressao object at 0x7f0934039e10>, <__main__.Expressao object at 0x7f0934039e50>, <__main__.Expressao object at 0x7f0934039e90>, <__main__.Expressao object at 0x7f0934039ed0>, <__main__.Expressao object at 0x7f0934039f10>, <__main__.Expressao object at 0x7f0934039f50>, <__main__.Expressao object at 0x7f0934039f90>, <__main__.Expressao object at 0x7f0934039fd0>, <__main__.Expressao object at 0x7f0926744050>, <__main__.Expressao object at 0x7f0926744090>, <__main__.Expressao object at 0x7f09267440d0>, <__main__.Expressao object at 0x7f0926744110>, <__main__.Expressao object at 0x7f0926744190>, <__main__.Expressao object at 0x7f0926744150>, <__main__.Expressao object at 0x7f09267441d0>, <__main__.Expressao object at 0x7f0926744210>, <__main__.Expressao object at 0x7f0926744250>, <__main__.Expressao object at 0x7f0926744290>, <__main__.Expressao object at 0x7f09267442d0>, <__main__.Expressao object at 0x7f0926744310>, <__main__.Expressao object at 0x7f0926744350>, <__main__.Expressao object at 0x7f0926744390>, <__main__.Expressao object at 0x7f09267443d0>, <__main__.Expressao object at 0x7f0926744410>, <__main__.Expressao object at 0x7f0926744450>, <__main__.Expressao object at 0x7f0926744490>, <__main__.Expressao object at 0x7f09267444d0>, <__main__.Expressao object at 0x7f0926744510>, <__main__.Expressao object at 0x7f0926744550>, <__main__.Expressao object at 0x7f0926744590>, <__main__.Expressao object at 0x7f09267445d0>, <__main__.Expressao object at 0x7f0926744610>, <__main__.Expressao object at 0x7f0926744650>, <__main__.Expressao object at 0x7f0926744690>, <__main__.Expressao object at 0x7f09267446d0>, <__main__.Expressao object at 0x7f0926744710>, <__main__.Expressao object at 0x7f0926744750>, <__main__.Expressao object at 0x7f0926744790>, <__main__.Expressao object at 0x7f09267447d0>, <__main__.Expressao object at 0x7f0926744810>, <__main__.Expressao object at 0x7f0926744850>, <__main__.Expressao object at 0x7f0926744890>, <__main__.Expressao object at 0x7f09267448d0>, <__main__.Expressao object at 0x7f0926744910>, <__main__.Expressao object at 0x7f0926744950>, <__main__.Expressao object at 0x7f0926744990>, <__main__.Expressao object at 0x7f09267449d0>, <__main__.Expressao object at 0x7f0926744a10>, <__main__.Expressao object at 0x7f0926744a50>, <__main__.Expressao object at 0x7f0926744a90>, <__main__.Expressao object at 0x7f0926744ad0>, <__main__.Expressao object at 0x7f0926744b10>, <__main__.Expressao object at 0x7f0926744b50>, <__main__.Expressao object at 0x7f0926744b90>, <__main__.Expressao object at 0x7f0926744bd0>, <__main__.Expressao object at 0x7f0926744c10>, <__main__.Expressao object at 0x7f0926744c50>, <__main__.Expressao object at 0x7f0926744c90>, <__main__.Expressao object at 0x7f0926744cd0>, <__main__.Expressao object at 0x7f0926744d10>, <__main__.Expressao object at 0x7f0926744d50>, <__main__.Expressao object at 0x7f0926744d90>, <__main__.Expressao object at 0x7f0926744dd0>, <__main__.Expressao object at 0x7f0926744e10>, <__main__.Expressao object at 0x7f0926744e50>, <__main__.Expressao object at 0x7f0926744e90>, <__main__.Expressao object at 0x7f0926744ed0>, <__main__.Expressao object at 0x7f0926744f10>, <__main__.Expressao object at 0x7f0926744f50>, <__main__.Expressao object at 0x7f0926744f90>, <__main__.Expressao object at 0x7f0926744fd0>, <__main__.Expressao object at 0x7f0926772050>, <__main__.Expressao object at 0x7f0926772090>, <__main__.Expressao object at 0x7f09267720d0>, <__main__.Expressao object at 0x7f0926772110>, <__main__.Expressao object at 0x7f0926772150>, <__main__.Expressao object at 0x7f0926772190>, <__main__.Expressao object at 0x7f09267721d0>, <__main__.Expressao object at 0x7f0926772210>, <__main__.Expressao object at 0x7f0926772250>, <__main__.Expressao object at 0x7f0926772290>, <__main__.Expressao object at 0x7f09267722d0>, <__main__.Expressao object at 0x7f0926772310>, <__main__.Expressao object at 0x7f0926772390>, <__main__.Expressao object at 0x7f0926772350>, <__main__.Expressao object at 0x7f09267723d0>, <__main__.Expressao object at 0x7f0926772450>, <__main__.Expressao object at 0x7f0926772410>, <__main__.Expressao object at 0x7f0926772490>, <__main__.Expressao object at 0x7f09267724d0>, <__main__.Expressao object at 0x7f0926772510>, <__main__.Expressao object at 0x7f0926772550>, <__main__.Expressao object at 0x7f0926772590>, <__main__.Expressao object at 0x7f09267725d0>, <__main__.Expressao object at 0x7f0926772610>, <__main__.Expressao object at 0x7f0926772650>, <__main__.Expressao object at 0x7f0926772690>, <__main__.Expressao object at 0x7f09267726d0>, <__main__.Expressao object at 0x7f0926772710>, <__main__.Expressao object at 0x7f0926772750>, <__main__.Expressao object at 0x7f0926772790>, <__main__.Expressao object at 0x7f09267727d0>, <__main__.Expressao object at 0x7f0926772810>, <__main__.Expressao object at 0x7f0926772850>, <__main__.Expressao object at 0x7f0926772890>, <__main__.Expressao object at 0x7f09267728d0>, <__main__.Expressao object at 0x7f0926772910>, <__main__.Expressao object at 0x7f0926772950>, <__main__.Expressao object at 0x7f0926772990>, <__main__.Expressao object at 0x7f09267729d0>, <__main__.Expressao object at 0x7f0926772a10>, <__main__.Expressao object at 0x7f0926772a50>, <__main__.Expressao object at 0x7f0926772a90>, <__main__.Expressao object at 0x7f0926772ad0>, <__main__.Expressao object at 0x7f0926772b10>, <__main__.Expressao object at 0x7f0926772b50>, <__main__.Expressao object at 0x7f0926772b90>, <__main__.Expressao object at 0x7f0926772bd0>, <__main__.Expressao object at 0x7f0926772c10>, <__main__.Expressao object at 0x7f0926772c50>, <__main__.Expressao object at 0x7f0926772c90>]