3
I’m a beginner in python and I wanted to know what I call attributes of another object in another class, because in Java, for example:
package model;
import java.util.ArrayList;
import java.util.List;
public class FuncionarioDAO {
Produto p; // Essa linha... como faço isso em python?
List<Produto> itens = new ArrayList<Produto>();
public void Cadastrar(Produto p) {
itens.add(p);
}
public void Remover(int codigo) {
for(int i=0; i<itens.size(); i++) {
Produto p = itens.get(i);
if(p.getCodigo() == codigo) {
itens.remove(i);
break;
}
}
}
public void Alterar(Produto p) {
Remover(p.getCodigo());
Cadastrar(p);
}
}
I also have another question, I have basis of POO, only that I do not understand very well the database interconnection with the application.
There comes a time when I need to pass the data to SQL and I don’t know what to do.
Someone could give me tips?
You have asked more than one question and one of them can be answered at this link http://pythonclub.com.br/gerenciando-banco-dados-sqlite3-python-parte1.html
– Fabricio
We didn’t miss an Inject in this product ? @Inject Product p; ?
– Otávio Reis Perkles
but how do you do it in python? because I have tested it this way and it is wrong
– Rafaela Lima
I’m drafting an answer
– Otávio Reis Perkles