Taula de continguts

Curso python (PCPP1) PUE 2023

PCPP1 / M1 | Advanced Perspective of Classes and Object-Oriented Programming in Python

1 OOP FOUNDATIONS

2 OOP ADVANCED

3 ADVANCED TECHNIQUES OF CREATING AND SERVING EXCEPTIONS

4 OBJECT PERSISTENCE

5 METAPROGRAMMING

PCPP1 / M2 | Best Practices and Standardization (Python Enhancement Proposals)

1 INTRODUCTION TO PEPS

PCPP1 / M3 | Introduction to GUI Programming in Python: TkInter (Python Enhancement Proposals)

1 GUI PROGRAMMING

PCPP1 / M4 | Working with RESTful APIs

1

2

PCPP1 / M5 | File Processing

summary

class Classe:
  class_var = 0
  def __init__(self):
    self.instance_var = 0
    Classe.class_var += 1
 
class SubClasse(Classe):
  pass
def simple_decorator(own_funct):
  def internal_wrapper(*args,**kwargs)
  	print("pre-execution")
    	own_function(*args,**kwargs) # original method executed
 
  return internal_wrapper
 
@simple_decorator
def decorators(*args,**kargs):
  pass
 
def simple_decorator_attributes(attribute):
  def wrapper(our_funct):
    def internal_wrapper(*args):
      pass
    return internal_wrapper
  return wrapper
 
@simple_decorator_attributes('argument')
def decorators_with_attribute(*args):
  pass
 
@simple_decorator
@simple_decorator_attributes('other_argument')
# simple_decorator(  simple_decorator_attributes( funcion() )  )
 
class SimpleDecoratorClass:
  def __init__(self, own_funct):
    self.func = own_funct
  def __call__(self,*args,**kwargs):
    print(self.func.__name__)
    self.func(*args,**kwargs)
 
class SimpleDecoratorClassWithArguments:
  def __init__(self,argument):
    pass
  def __call__(self,own_funct)
 
@SimpleDecoratorClass
def simple_function(*args,**kwargs):
  pass
 
def object_counter(class_):
    class_.__getattr__orig = class_.__getattribute__
 
    def new_getattr(self, name):
        if name == 'mileage':
            print('We noticed that the mileage attribute was read')
        return class_.__getattr__orig(self, name)
 
    class_.__getattribute__ = new_getattr
    return class_
 
@object_counter
class Car:
    def __init__(self, VIN):
        self.mileage = 0
        self.VIN = VIN

otros conocimientos

guia estilo

utilidades