5. Múltiple herencia y ¿Qué objeto es?

1class Ethernet:
2    def __init__(self, nombre, direccion_mac):
3        self.nombre = nombre
4        self.direccion_mac = direccion_mac
5
6
7class Wireless(Ethernet):
8    def __init__(self, nombre, direccion_mac):
9        Ethernet.__init__(self, nombre, direccion_mac)
10
11
12class PCI:
13    def __init__(self, bus, fabricante):
14        self.bus = bus
15        self.fabricante = fabricante
16
17
18class USB:
19    def __init__(self, dispositivo):
20        self.dispositivo = dispositivo
21
22
23class PCIEthernet(PCI, Ethernet):
24    def __init__(self, bus, fabricante, nombre, direccion_mac):
25        PCI.__init__(self, bus, fabricante)
26        Ethernet.__init__(self, nombre, direccion_mac)
27
28
29class USBWireless(USB, Wireless):
30    def __init__(self, dispotivo, nombre, direccion_mac):
31        USB.__init__(self, dispotivo)
32        Wireless.__init__(self, nombre, direccion_mac)
33
34
35wlan0 = USBWireless("usb0", "wlan0", "00:33:44:55:66")
36eth0 = PCIEthernet("pci :0:0:1", "realtek", "eth0", "00:11:22:33:44")
37
38
39print(isinstance(wlan0, Ethernet))
40print(isinstance(eth0, PCI))
41print(isinstance(eth0, USB))
line that just executed

next line to execute

Print output (drag lower right corner to resize)
Frames
Objects

Activity: CodeLens 5.1 (cl_l25_5)

En una escala del 1 (a mejorar) al 3 (excelente), ¿cómo calificaría este capítulo?




Activity: 5.2 Poll (TWP25)

You have attempted 1 of 3 activities on this page