1
Good evening, I’m a beginner in python and I have a question about how to make an array of an object or class. My main program contains a function that cuts into text, delimiting blocks and so on. Very simple. And I have another that only leaves the classes and objects, determining the types of each attribute. The function works correctly, however I cannot call the attributes of the Classes in my package.
The structure of the function needs to stay that way.
Nome = RecortaTexto(Offset,Bloco,Loja.Esqueleto.Nome.Valor_I,Loja.Esqueleto.Nome.Valor_I)
Main Program
from library.Tipos import Loja, Esqueleto, Modo
# Da o que está entre o inicio e o fim em determinado texto, respeitando offset e retornando offset inclusive.
def CortaFora(Offset,Texto,Inicio,Fim):
Inicial = Final = ''
Inicial = PosEx(Inicio, Texto, Offset) + len(Inicio)
Offset = Inicial
Final = PosEx(Fim, Texto, Offset)
Offset = Final
return Texto[ Inicial:Final ].strip(' '), Offset
Offset = 0
Texto = '<h1 Teste </h1>'
Nome, Offset = CortaFora(Offset,Texto, Loja.Esqueleto.Valor_I, Loja.Esqueleto.Valor_F)
print(Nome)
Package where I stored the classes
from dataclasses import dataclass
class Modo(object):
Descricao = str
Valor_I = (data['Valor_I'])
Valor_F = (data['Valor_F'])
Versao = int
class Esqueleto(object):
Esqueleto = Modo()
PRODUTO = int
PRECOS = int
NOME = str
NOME2 = int
class Loja:
ID = int # ID da Loja
SID = str # ID em String da Loja para evitar conversão em mil lugares.
Cron = str # Cron
Nome = str
Esqueleto = [Modo] #Aqui tentei fazer o Esqueleto sendo um array de modo
The intention is to make Store receive a Skeleton object that receives valor_I and valor_F. As the example requested to me. I thank anyone who can help, and apologies if it was not clear my problem.
Well let me get this straight, you want your Shop class in the skeleton attribute, get the values of the Skeleton class as a list, is that it? Another question, your skeleton class has a Skeleton attribute there with the instance of the Mode class, your intention was to inherit the attributes of the Mode class or you need to create an instance of the same class?
– Robson Silva
Good morning, I need to create a class establishment. The question of the skeleton attribute is one of my problems, because I wanted to make him understand which skeleton receives a mode array. In case , if I choose 'PRODUCT' it will need to receive Valor_i, and Valor_f.
– Marcos Vinicios