Visualizzazione post con etichetta thinkpython. Mostra tutti i post
Visualizzazione post con etichetta thinkpython. Mostra tutti i post

sabato 29 luglio 2023

GPL3 e altre licenze

 Ecco un elenco di alcuni pacchetti Python con licenze diverse da GPL:


1. Requests: Licenza Apache 2.0

2. NumPy: Licenza BSD

3. Pandas: Licenza BSD

4. Matplotlib: Licenza BSD

5. Django: Licenza BSD

6. Flask: Licenza BSD

7. TensorFlow: Licenza Apache 2.0

8. Keras: Licenza MIT

9. Scikit-learn: Licenza BSD

10. SQLAlchemy: Licenza MIT

11. BeautifulSoup: Licenza MIT

12. Pygame: Licenza LGPL

13. PyTorch: Licenza BSD

14. OpenCV: Licenza BSD

15. PyQT: Licenza GPL con un'opzione commerciale


Ci sono diverse licenze compatibili con la GPL3, che permettono di distribuire il software sotto termini diversi ma ancora compatibili con la GPL3. Alcune di queste licenze includono:


- Licenza MIT: è una licenza permissiva che permette la distribuzione e la modifica del software, ma richiede solo l'inclusione del copyright e della licenza originale. È compatibile con la GPL3.


- Licenza Apache 2.0: è una licenza permissiva che permette la distribuzione, la modifica e la sublicenza del software, ma richiede l'inclusione del copyright, della licenza originale e dei riconoscimenti dei contributi. È compatibile con la GPL3.


- Licenza BSD: ci sono diverse varianti della licenza BSD, ma la maggior parte di esse sono compatibili con la GPL3. Queste licenze sono permissive e permettono la distribuzione, la modifica e la sublicenza del software, ma richiedono solo l'inclusione del copyright e della licenza originale.


- Licenza Creative Commons Attribution-ShareAlike (CC BY-SA): è una licenza che permette la distribuzione e la modifica del software, ma richiede l'attribuzione dell'autore originale e la condivisione delle opere derivate con la stessa licenza. È compatibile con la GPL3.


Queste sono solo alcune delle licenze compatibili con la GPL3. È importante leggere attentamente i termini di ogni licenza per assicurarsi che siano compatibili con i propri scopi e con la GPL3.


Si prega di notare anche che le licenze possono variare nel tempo, quindi è sempre consigliabile verificare la licenza ufficiale di ogni pacchetto prima di utilizzarlo.

giovedì 8 aprile 2021

PYTHON - Light database from json file

 A very light textual database, very simple and basic. 

Download the two files maker.py and lightdb.py in the same directory. Run lightdb.py to build the database on a json file. Then there is the possibility to add data directly from lightdb or you can build a .py file that will serve to manage the database. There is also the possibility to transform the json file into an excel file.

 You can download  the file from repo on github: lightdb

sabato 3 aprile 2021

PYTHON - Make and read JSON file with JSON library

Simple example for to show python power
import json
import sys
#Write and read json file with json library and dict
def makeJSON(jsFile):
    dict={}
    while True:
        chiave=input("Chiave> ")
        if chiave=='#e':
            break
        valori=input("Valori> ")
        lista=valori.split(' ')
        dict[chiave]=lista
    with open(jsFile,"w") as json_file:
        json.dump(dict, json_file)

def readJSON(jsFile):
    dict={}
    with open(jsFile,"r") as json_file:
        dict=json.load(json_file)
    return dict

def understandvalues(dict):
    n=0
    f=0.0
    l=[]
    d={}
    klist=list(dict.keys())
    for i in range(len(klist)):
        val=dict[klist[i]]
        if type(val)==type(l):
            print("Lista")
        elif type(val)==type(n) or type(val)==type(f):
            print("numero")
        elif type(val)==type(d):
            print("dizionario")

if __name__ == "__main__":
    comandi="Ho to use: ej3.py (r or w) (file name) \nr read json file\nw write json file"
    try:
        if sys.argv[1]=='r':
            d=readJSON(sys.argv[2])
            understandvalues(d)
            print(d)
        elif sys.argv[1]=='w':
            makeJSON(sys.argv[2])
        else:
            print(comandi)
    except:
        print(comandi)

PYTHON - Building a memory based on external stimuli

This script parses the incoming phrase with the keys contained in the json file, if it finds the key it processes a response, otherwise it adds the key and rewrites the json file.
import json
#Da stimoli esterni il software allarga le proprie conoscenze

def caricaCoscienza(nomeCoscienza):
    with open(nomeCoscienza,"r") as json_file:
        dictFromJSon=json.load(json_file)
    return dictFromJSon

def memorizza(valori,dict,nomeCoscienza):
    chiave=valori[0]
    lista=[]
    for i in range(len(valori)):
        if i>0:
            lista.append(valori[i])
    dict[chiave]=lista
    with open(nomeCoscienza,"w") as json_file:
            json.dump(dict, json_file)
    with open(nomeCoscienza,"r") as json_file:
        dictFromJSon=json.load(json_file)
    return dictFromJSon

def elabora(valori,ch,keys,dict):
    chiave=keys[ch]
    risposta=dict[chiave]
    return risposta

def ricerca(ingresso,dict,nomeCoscienza):
    keys=list(dict.keys())
    valori=ingresso.split(' ')
    trovato=False
    r=''
    for i in range(len(keys)):
        for c in range(len(valori)):
            if keys[i]==valori[c]:
                trovato=True
                ch=i
    if not(trovato):
        dict=memorizza(valori,dict,nomeCoscienza)
    else:
        r=elabora(valori,ch,keys,dict)
    return r


if __name__ == "__main__":
    dict=caricaCoscienza("result.json")
    dato=input(">")
    print(ricerca(dato,dict,"result.json"))

PYTHON - FROM DICTIONARIES to JSON

Python dictionaries: a power; python dictionaries + JSON: super power.
import json
#HOW TO MANAGE DICTIONARY
#+-+-+-+-+-+-+-+-+-+-+-+#
d = {
  "Chiave": "Codice",
  "Costo": 1.23,
  "Ricarico": 30,
  "Listino": 3.00
}
c = d.items()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
c = d.keys()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
c=d.values()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
nd = {
    "dizionario":{"subDict":["ch1","ch2","ch3"],
                "other":"otherSub"
                },
    "numero":2,
    "codice":"codice"
}
c=nd.items()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
c = nd.keys()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
c=nd.values()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
newD=lista[0]
c=newD.values()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
nuovaLista=lista[0]
for i in range(len(nuovaLista)):
    print(nuovaLista[i])
print("Costruzione JSON")
with open("result.json", "w") as json_file:
    json.dump(nd, json_file)
json_string = json.dumps(nd)
print(json_string)
with open("result.json","r") as json_file:
    dictFromJSon=json.load(json_file)
print(dictFromJSon)

giovedì 1 aprile 2021

PYTHON - DICTIONARIES: A POWER

Python dictionaries: a power. Find the name of the keys, the values. Dictionaries can, linked to JSON, become a powerful lightweight database.
#HOW TO MANAGE DICTIONARY
#+-+-+-+-+-+-+-+-+-+-+-+#
d = {
  "Chiave": "Codice",
  "Costo": 1.23,
  "Ricarico": 30,
  "Listino": 3.00
}
c = d.items()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
c = d.keys()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
c=d.values()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
nd = {
    "dizionario":{"subDict":["ch1","ch2","ch3"],
                "other":"otherSub"
                },
    "numero":2,
    "codice":"codice"
}
c=nd.items()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
c = nd.keys()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
c=nd.values()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
newD=lista[0]
c=newD.values()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
nuovaLista=lista[0]
for i in range(len(nuovaLista)):
    print(nuovaLista[i])

domenica 28 marzo 2021

PYTHON - MAKE A JSON FILE FROM DICT

Practical example of how to transform a dictionary into a json file.
The filename is updated using a variable contained in "count.py". Each file is added to the "listalogiche.dat" file.
From here we start for artificial intelligence.
import json
import conteggio
import sys

lista2={}
while True:
v1=input('Parola ')
if v1=='fine':
break
elif v1=='annulla':
sys.exit()
else:
v2=input('comando ')
lista2[v1]=v2
nomefile="comandi"+str(conteggio.conta)+".json"
#save lista2 as .json file
with open(nomefile, "w") as json_file:
json.dump(lista2, json_file)
#aggiornamento dei file di configurazione
f=open("conteggio.py","w")
n=conteggio.conta
n+=1
f.write('conta='+str(n))
f.close()
f=open("listalogiche.dat","a")
f.write(nomefile)
f.close()

lunedì 31 agosto 2020

PYTHON - MACHINE LEARNING

I couldn't rely on existing databases for my machine learning project. I need a highly plastic database, so I decided to implement mine. 
Using json and python files I can modify the structures of the tables without having to worry about modifying existing queries, they adapt to changes automatically.
The idea is that, when the machine does not find the data in its databases, it searches for them with the means at its disposal, automatically evaluating which is the best way to search for a given data. The decision tree will automatically expand with the accumulated experience. 
It is not impossible, but it will be long. For now I start building my database.



lunedì 20 aprile 2020

PYTHON - LE BASI DELLA PROGRAMMAZIONE

English translation after Italian. 

C'è chi cerca soluzioni di algoritmi e chi le basi per iniziare a programmare in python e il mio blog è ben lontano da fornire informazioni di questo tipo, dato il già esteso numero di siti e blog pieni delle basi, ma il pdf a questo link credo che sia un eccezzionale libro thinkpython_italian.pdf che bisogna avere.
Oltre che spiegare bene la sintassi, spiega anche la logica del programmatore, cosa da non sottovalutare: un programma, a differenza di tante altre cose, può funzionare anche se scritto male. 

Quando ho iniziato a studiare informatica alle superiori oltre cha valutare se il programma funzionava veniva fatto anche il calcolo computazionale di tale programma, poichè le risorse dei PC erano limitate; ai giorni nostri ci sono PC molto potenti e le grandi software house commerciali tendono a sfruttare questa potenza nello spreco, allenarsi a sfruttare la potenza del linguaggio per sfruttare al meglio, senza sprechi, la potenza del PC.
 Qualcuno potrebbe obiettare che a livello commerciale non conviene "perdere tempo" ad ottimizzare i programmi, e potrei anche dargli ragione, ma credo che per quello che si chiama "amor proprio" ottimizzare ogni programma è una grande soddisfazione.


There are those looking for algorithm solutions and those who have the basics to start programming in python and my blog is far from providing information of this type, given the already extensive number of sites and blogs full of bases, but the pdf to this link I think it is an exceptional thinkpython_italian.pdf book that you must have. 
In addition to explaining the syntax well, it also explains the programmer's logic, which should not be underestimated: a program, unlike many other things, can work even if written poorly. 
When I started studying computer science in high school, besides evaluating if the program worked, the computational calculation of this program was also done, as the PC resources were limited; nowadays there are very powerful PCs and the big commercial software houses tend to exploit this power in waste, train to exploit the power of language to make the best use, without waste, of the power of the PC. 
Some might argue that on a commercial level it is not convenient to "waste time" on optimizing programs, and I might even agree with it, but I believe that for what is called "self-love" optimizing each program is a great satisfaction.