Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created January 7, 2019 01:04
Show Gist options
  • Save Fhernd/c3512a12b6f321cb58279f8943b6cd85 to your computer and use it in GitHub Desktop.
Save Fhernd/c3512a12b6f321cb58279f8943b6cd85 to your computer and use it in GitHub Desktop.
Definición de una clase abstracta en Python.
from abc import ABCMeta, abstractmethod
class IStream(metaclass=ABCMeta):
@abstractmethod
def leer(self, bytes_maximos=-1):
pass
@abstractmethod
def escribir(self, datos):
pass
class SocketStream(IStream):
def leer(self, bytes_maximos=-1):
# Operaciones de lectura
pass
def escribir(self, datos):
# Operaciones de escritura
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment