Sometimes it is useful to have a data type bundling together a few named data items. An empty class definition will do nicely:
#define an empty class
class Employee:
pass
#create an instance of the class
john = Employee() # Create an empty employee record
# Fill the fields of the record
john.name = 'John Doe'
john.dept = 'computer lab'
john.salary = 1000
This way perhaps makes the code more extendable ?
Aucun commentaire:
Enregistrer un commentaire