<jupyter_start><jupyter_text>Diseño de software para cómputo científico---- Unidad 1: Cerrando  Agenda de la Unidad 1---- Clase 1:    - Diferencias entre alto y bajo nivel.    - Lenguajes dinámicos y estáticos.    - Limbo:    - Introducción al lenguaje Python.    - Librerías de cómputo científico.    - Clase Limbo + 1 y Limbo + 2:    - **Orientación a objetos**, decoradores.  Classes en el mundo real---- namedtuples<jupyter_code>from collections import namedtuple

Coso = namedtuple("Coso", ["a", "b"])

c  = Coso(a=1, b=2)
c<jupyter_output><empty_output><jupyter_text>Classes en el mundo real---- dataclass<jupyter_code>import dataclasses

@dataclasses.dataclass
class InventoryItem:
    '''Class for keeping track of an item in inventory.'''
    name: str
    unit_price: float
    quantity_on_hand: int = 0
InventoryItem(name="tito", unit_price=43)
InventoryItem(name=23, unit_price=43)<jupyter_output><empty_output><jupyter_text>Classes en el mundo real---- attrs<jupyter_code>!pip install attrs -U
import attr

@attr.s
class SomeClass(object):
    a_number = attr.ib(default=42)
    list_of_numbers: list = attr.ib(factory=list)
    
    @a_number.validator
    def must_be_a_number(self, attribute, value):
        if not isinstance(value, (int, float)):
            raise TypeError()
            
    def hard_math(self, another_number):
        return self.a_number + sum(self.list_of_numbers) * another_number

sc = SomeClass(1, {1, 2, 3})
sc
sc.hard_math(23)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11251664447403462, 'fraction_numerical': 0.014647137150466045, 'mean_word_length': 3.9278688524590164, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '447281', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 547, 'n_tokens_neox': 530, 'n_words': 135, 'path': 'legacy/unidad_1/08_oofinal.ipynb', 'repo_name': 'LVFerrero/diseno_sci_sfw', 'size': '1502'}