Curso python (PCPP1) PUE 2023

  • Classes, instances, attributes, methods, as well as working with class and instance data;
  • shallow and deep operations;
  • abstract classes, method overriding, static and class methods, special methods;
  • inheritance, polymorphism, subclasses, and encapsulation;
  • advanced exception handling techniques;
  • the pickle and shelve modules;
  • metaclasses.
  • PEP 20 (The Zen of Python)
  • PEP 8 (Style Guide for Python Code)
  • PEP 257 (Docstring conventions)
  • how to avoid common errors and mistakes when writing code;
  • how to write elegant and effective code.
  • what GUI is and where it came from;
  • how to construct a GUI using basic blocks and conventions;
  • how event-driven programming works;
  • some popular and commonly used GUI environments and toolkits;
  • what tkinter is and how to build a GUI with its help;
  • how to use widgets, windows, and events, and how to create basic applications based on tkinter's application life cycle.
  • the basic concepts of network programming, REST, network sockets, and client-server communication;
  • how to use and create sockets in Python, and how to establish and close the connection with a server;
  • what JSON and XML files are, and how they can be used in network communication;
  • what HTTP methods are, and how to say anything in HTTP;
  • how to build a sample testing environment;
  • what CRUD is;
  • how to build a simple REST client, and how to fetch and remove data from server, add new data to it, and update the already-existing data.
  • class, instance, object, attribute, method, type (__class__)
  • instance variables: <object>.__dict__
  • class variables:
    • <class>.__dict__
    • <class>.class_var = 1
  • superclass methods:
    • __init__
  • special methods:
    • __name__
    • __getattribute__
  • magic methods
  • Inheritance
    • MRO ≡ Method Resolution Order
  • Polymorphism
  • arguments
    • *args: tuple (a,b,c)
    • **kwargs: dictionary {}
  • decorators
    • @simple_decorator()
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

guia estilo

  • pip install pycodestyle

utilidades

  • info/cursos/pue/python-pcpp1.txt
  • Darrera modificació: 04/03/2024 02:52
  • per mate