#🍁・general-2

1 messages · Page 134 of 1

past harbor
#

yield para mí en español significa "perteneciente a "

ashen mist
#

also, si querés quedarte con los carácteres de newline, poné True como un argumento

#
>>> cadena = "linea1\nlinea2\nlinea3"
>>> cadena.splitlines()
['linea1', 'linea2', 'linea3']
>>> cadena.splitlines(True)
['linea1\n', 'linea2\n', 'linea3']
fallow dock
#

pero cómo le dirías al verbo por ej. en corrutinas o al switch de Java 13?

#

o a Thread.yield()

ashen mist
#

incluyendo \r:

>>> cadena = "linea1\r\nlinea2\r\nlinea3"
>>> cadena.splitlines()
['linea1', 'linea2', 'linea3']
>>> cadena.splitlines(True)
['linea1\r\n', 'linea2\r\n', 'linea3']
icy pollen
#

yield me parece muy similar a devolver

past harbor
#

join(cadena)

#

no creo que funcione así

ashen mist
#

ah, me encanta join

fallow dock
#

sí pero medio que eso podría ser retornar también thinky anyway, dejemos que transcurra la clase

past harbor
#

creo que está mal copiado

#

por el profe

ashen mist
#

join toma un objeto iterable como argumento

#

puede ser una lista, una tupla

past harbor
#

hazlo fácil por ahora

ashen mist
#

algo iterable

past harbor
#

lo siguiente es que me expliques diccionarios, lists, tuplas etc

#

hazlo con strings primero

#

y después me lo complicas 👀

ashen mist
#

jaja ok

past harbor
#

aprenderé py en un día a 5 días del examen

ashen mist
#

cuando decís cadena.join(cosa), join pone cadena entre cada elemento de cosa y te da el resultado

#
>>> " ".join("hola")
'h o l a'

"hola" es una cadena cuyos elementos son "h", "o", "l", y "a"
así que join une cada elemento con un espacio entre ellos

#

puedo usar otras cosas para unir las letras de la cadena "hola" también

#
>>> "-".join("hola")
'h-o-l-a'
past harbor
fallow dock
#

Helloor

ashen mist
#

sí, porque la función de join trata miCadena como un objeto iterable hecho de letras

past harbor
#

ah lo que hace es

ashen mist
#

por eso, toma cada componente (cada letra) de miCadena

past harbor
#

coger mi cadena y detrás de cada letra mete lo que le he pasado

ashen mist
#

entre cada letra

#

"Hello" no va a aparecer en el principio o al cabo

#

solamente entre cada elemento

#

.join no es como concatenar dos cadenas

#

si eso es lo que querés hacer, basta con decir miCadena + otraCadena y ta

#
>>> "Hello" + ", World."
'Hello, World.'
#

ahora, podemos complicarlo un poco

#

dije que join toma un argumento que es algo iterable

past harbor
#

ahora todo tiene más sentido

ashen mist
#

una lista es iterable, no? porque tiene elementos que podés procesar uno por uno, en orden

#
>>> "-".join(["palabra1", "palabra2", "palabra3"])
'palabra1-palabra2-palabra3'
glass dragon
#

@sacred harbor johnny

ashen mist
#

el argumento en este ejemplo es una lista de 3 cadenas

#

y la función toma cada elemento del argumento, o sea cada cadena de la lista, y pone "-" entre cada elemento

fallow dock
#

la función que cumple es la misma que la de String.join de Java, sólo que en Java los strings no son iterables

ashen mist
#
>>> ", ".join(["Hello", "World"])
'Hello, World'
#

funciona igual con tuplas, ya que las tuplas también son iterables

#
>>> " - ".join(("cosa1", "cosa2", "cosa3"))
'cosa1 - cosa2 - cosa3'
#

tené en cuenta que los elementos de tu argumento tiene que ser strings.

#

o sea, me grita si intento usar join con una lista de int

#
>>> " + ".join([1, 2, 3])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: sequence item 0: expected string, int found
#

la función esperaba que el argumento contuviera cadenas, pero encontró un entero

#

pero si uso ["1", "2", "3"], entonces funciona

#

porque ya no es una lista de ints, sino una lista de cadenas

past harbor
#

anotado

#

grx

ashen mist
#

de nada

past harbor
#

format cómo se usa?

#

esta es la teoría

#

pero no entiendo nada 😄

#

"format(valores) Formatea la cadena de entrada según la expresión contenida con los valores que se pasan."

ashen mist
#

ok

#

en la cadena, hay que indicar dónde querés poner valores

#

o sea, digamos que querés que tu cadena contenga algo, pero no sabés de antemano qué va a contener

#

por ejemplo, tu usuario te va a pasar un número o algo así

#

lo que podés hacer es indicar en la cadena que vas a incluir algo, y que el valor se va a determinar por una variable o una función o lo que sea

#

un ejemplo:

>>> cadena = "valor no predeterminado: {}"
>>> cadena.format("cosa")
'valor no predeterminado: cosa'
#

format reemplaza {} con el argumento - en este caso, la cadena "cosa"

#

el argumento no tiene siempre ser una cadena

>>> "valor no predeterminado: {}".format(1+2)
'valor no predeterminado: 3'
#

podemos reemplazar más de una cosa? por supuesto

past harbor
#

me acaba de explotar la cabeza

ashen mist
#
>>> "cosa 1: {}, cosa 2: {}".format("a", "b")
'cosa 1: a, cosa 2: b
past harbor
#

el {} es donde metes el formato?

ashen mist
#

#

es como decir "poné el valor acá"

#

y podés cambiar el orden por incluir índices en {}

#
>>> "cosa 1: {1}, cosa 2: {0}".format("a", "b")
'cosa 1: b, cosa 2: a'

o sea, reemplaza {0} con el primer argumento de format y reemplaza {1} con el segundo argumento de format

past harbor
#

a ver

#

cómo pido al usuario que escriba algo?

ashen mist
#

podés usar input

past harbor
#

escribo input y ya?

#

qué mierda que esto no funcione en py

sacred harbor
#

@sacred harbor johnny
@glass dragon johnny

past harbor
fallow dock
#

recomendado raw_input en Python 2

past harbor
#

en java sí que va

#

a ver cómo lo pongo

#

ah

#

pues no me deja en el visual code meter datos

fallow dock
#

deberías checar si no hay otras formas de correr el programa en Visual Code

ashen mist
#
cualquierweon@uruwhy:~$ cat test.py
valor = raw_input("Decime algo:\n")
print("el usuario dijo: {}".format(valor))
cualquierweon@uruwhy:~$ python2 test.py
Decime algo:
holam, mundo
el usuario dijo: holam, mundo
past harbor
#

no me deja

#

o sea, no me sale nada

#

qué hice mal

ashen mist
#

nada, creo

past harbor
ashen mist
#
>>> saludoUsuario = "Hola, {}".format("Juan")
>>> print(saludoUsuario)
Hola, Juan
>>> 
#

funcionó perfecamente para mí

fallow dock
#

no podés escribir en ese lugar?

past harbor
#

no

#

es out no in

fallow dock
#

en general querrías Terminal

past harbor
#

se ha roto

#

esto

#

ya no va nada

fallow dock
#

probablemente sea tu input esperando entrada en algún lado

#

xd

past harbor
#

cuánto t queda antes de irte, @ashen mist ?

ashen mist
#

eh

#

no sé jajaja

#

voy a estar acá por mucho tiempo

past harbor
#

ah vale

#

ya me funciona lo del format, gracias

ashen mist
#

ah genial

past harbor
#

Lo siguiente es "diccionarios o tablas has"

#

hash*

ashen mist
#

divertido

past harbor
#

se crean con {{ tienen un valor único como clave,pero el valor se puede cambir

#

no?

#

cambiar*

ashen mist
#

seh

past harbor
#

a ver

ashen mist
#

con {}

past harbor
#

ah, solo 1?

ashen mist
#

sí, así

#
>>> diccionario = {"a":1, "b":2, "c":3}
>>> diccionario
{'a': 1, 'c': 3, 'b': 2}
past harbor
#

y accedo por la clave?

#

ashen mist
#

sip

past harbor
#

la clave no se puede cambiar entonces, pero el valor sí

ashen mist
#

se puede borrar la clave

#

o añadir otra

past harbor
#

cómo

#

se da otro valor

ashen mist
#

hacelo fuera de la función de print

#

o sea,

past harbor
#

en serio

ashen mist
#
miDiccionario["Opt1"] = 3
print(miDiccionario)
past harbor
#

Uhh

#

se nota que estoy hecho todo un fan de Java 😄

#

antes puse ;

ashen mist
#

jajaja esta bien

past harbor
#

pone aquí

#

que se puede acceder a varias listas con

#

,

#

cómo va eso?

ashen mist
#
>>> miDiccionario = {"Opt1": 1, "Opt2": 2}
>>> miDiccionario["Opt1"] = 3
>>> print(miDiccionario)
{'Opt1': 3, 'Opt2': 2}
#

acceder a varias listas?

past harbor
#

me expliqué mal

#

pone esto

fallow dock
#

unpacking?

ashen mist
#
>>> miDiccionario["Opt3"] = 4 # nueva clave
>>> print(miDiccionario)
{'Opt1': 3, 'Opt3': 4, 'Opt2': 2}
#

otra manera de crear un diccionario:

>>> diccionario2 = dict()
>>> diccionario2["a"] = 1
>>> diccionario2
{'a': 1}
past harbor
#

Además a conseguir valores elementos consecutivos de la lista como una nueva lista, se realiza con un proceso sencillo indicando los índices iniciales y los del final a conseguir. Dichos índices estarán separados por :

#

pone esto

ashen mist
#

also, si querés obtener el valor de una clave en tu diccionary, te recomiendo que uses la función de get

#

ah

past harbor
#

no sé qué significa

ashen mist
#

ok

#

lista[1] te da el elemento en la segunda posición, o sea en la posición de índice 1

#

lista[1:3] te da una nueva lista que contiene los elementas de lista, empezando en índice 1 hasta índice 3 (pero no incluye el elemento de índice 3)

#
>>> lista = [0,1,2,3,4]
>>> lista[1:2]
[1]
>>> lista[1:3]
[1, 2]
past harbor
#

cuando pones

#

lista[1:2] te sobreescribe tu lista de 5 numeros?

ashen mist
#

no, te da una lista nueva

past harbor
#

o solo es una forma de acceso

#

ah vale

ashen mist
#

no cambia tu lista original

#

y si querés empezar en un índice y ir por el resto de la lista, basta con decir lista[x:], y eso te da una lista con los elementos de lista, empezando en índice x

#
>>> lista = [0,1,2,3,4]
>>> lista[1:]
[1, 2, 3, 4]
>>> lista[2:]
[2, 3, 4]
past harbor
#

ahh

ashen mist
#

lista[:x] te da una lista con los elementos de lista hasta el índice x, pero sin ese índice

past harbor
#

esto es listas no diccionarios lmao

ashen mist
#
>>> lista = [0,1,2,3,4]
>>> lista[:3]
[0, 1, 2]
#

lista[:] te da todos los elementos de lista

#

prueba que no cambia tu lista original:

>>> lista = [0,1,2,3,4]
>>> otralista = lista[:]
>>> otralista[1] = "a"
>>> lista
[0, 1, 2, 3, 4]
>>> otralista
[0, 'a', 2, 3, 4]
#

sí, se trata de las listas jaja

#

diccionarios son otra cosa

past harbor
#

append(valor), insert(posicion, valor), extends(iterable)

#

esto debo aprender de las listas

ashen mist
#

append añade un elemento al cabo de la lista

#
>>> lista = ["a", "b", "c"]
>>> lista.append("d")
>>> lista
['a', 'b', 'c', 'd']
>>> lista.append(4)
>>> lista
['a', 'b', 'c', 'd', 4]
#

notá que cambia tu lista

#

o sea, no te da una lista nueva

#

así que no hagas esto

median trail
ashen mist
#
>>> lista = lista.append(4)
>>> lista
>>> 
median trail
#

225fps btw

ashen mist
#

genial

median trail
#

UWU

hybrid hull
#

How did you add more ram to your laptop?

ashen mist
#

insert también añade un elemento a la lista, pero en la posición indicada por el argumento

#
>>> lista = [0,1,2,3,4]
>>> lista
[0, 1, 2, 3, 4]
>>> lista.insert(3, "a")
>>> lista
[0, 1, 2, 'a', 3, 4]
past harbor
#

nunca puedo dar valor a algo y después imprimirlo de una en py? @ashen mist

median trail
#

ehmmm you open it and install the ram stick you bought

hybrid hull
#

But you can't just do that with any laptop right?

ashen mist
#

es que la función de append cambia la lista, no te devuelve un valor

fallow dock
#

notebook RAM isn't soldered if that's what you think zoop

past harbor
#

aquí pone esto

median trail
#

hmmm I think it depends but most laptops can be upgraded tony

past harbor
#

Append(valor) Permite añadir el valor pasado al final de la tabla

ashen mist
#

lo que deberías hacer es

miLista.append("4")
print(miLista)
past harbor
#

¿Es incorrecto?

#

ah

hybrid hull
#

Hm. Just curious. My current laptop is suuuuper thin so idk if it has the space

#

Cool though!

ashen mist
#

no sé que tienen que ver las tablas, pero append sí añade un elemento al cabo de la lista

median trail
#

it most likely has an empty slot

ashen mist
#

es que la función en sí no devuelve un valor

#

bueno, técnicamente devuelve None

hybrid hull
#

Doesn't opening void the warranty?

ashen mist
#

porque sólo cambia la lista original

median trail
#

Yes tony

ashen mist
#

así que si decís print(miLista.append("4")), lo que pasa es que python usa la función de append, la cual devuelve None, y print va a imprimir el valor que la función devolvió

#

así que va a imprimir None

#
>>> lista = [0,1,2]
>>> print(lista.append(3))
None
>>> print(lista)
[0, 1, 2, 3]
past harbor
#

ya lo entendí

#

cómo va esto

#

dice que extends no existe

ashen mist
#

es extend, no más

past harbor
#

maldito

ashen mist
#
>>> lista = [0,1,2]
>>> lista.extend([3,4,5])
>>> print(lista)
[0, 1, 2, 3, 4, 5]
past harbor
#

profesor 😄

#

veo que no llegó el mensaje

#

pero ahora me toca probar pop, remove, index e in

ashen mist
#

mi conexión está empeorando jaja

past harbor
#

y la mía

ashen mist
#

index y qué mas?

#

insert_

#

?

past harbor
#

no

#

insert ya lo probé

#

toca pop, remove index e in

#

pero me defiendo con estos

ashen mist
#

pop quita el último elemento de la lista y te lo da

past harbor
#

no te preocupes

ashen mist
#

ok

past harbor
#

lo siguiente es

#

tuplas

ashen mist
#

ah sí

past harbor
#

esto es un lio

ashen mist
#

es como una lista inmutable

past harbor
#

existen arrays, listas, tuplas, diccionarios

#

arrays cómo se declaran?

ashen mist
#

en python hay listas

past harbor
#

ah

#

se llaman así los arrays?

ashen mist
#

creo que hay un módulo para arrays

#

así que técnicamente podés usar arrays

#

pero las listas deberían ser suficientes

fallow dock
#

no sé si alguien realmente usa array.array

past harbor
#

entonces

fallow dock
#

básicamente array.array es un array de C, so, blazing fast

#

pero numpy tiene otros arrays, también de bajo nivel

ashen mist
#

pero los elementos tienen que ser del mismo tipo, creo

past harbor
#

me estoy liando

#

entre la definicion de tupla, diccionario, listas

#

xDD

fallow dock
#

@past harbor que no te mienta el nombre

past harbor
#

a ver déjame hacer

#

otra vez ejercicios de esos

fallow dock
#

una lista es un arraylist de Java

past harbor
#

es una liada

fallow dock
#

de hecho, un ArrayList son un montón de arrays con punteros a objetos

#

y una list funciona de la misma forma

ashen mist
#

lista = una colección de cosas en un orden. la colección puede cambiar - se puede añadir más elementos, quitar elementos, y la lista puede contener elementos de varios tipos

past harbor
#

me refiero a esto, ver

#

a

ashen mist
#

una tupla también es una colección de cosas en orden, pero no puede cambiar. no se puede añadir otros elementos a una tupla ni cambiar un elemento por otro

past harbor
#

diccionario = { "Opt1": Opción 1, "Opt2": Opción 2}
lista = ["1", "2", "3"]

#

así se definen?

ashen mist
#

past harbor
#

y la tupla cómo es entonces

#

con ()?

ashen mist
#

con () y comas

past harbor
#

pensaré que las listas son arrays

ashen mist
#

(1,2) te da una tupla de dos elementos

past harbor
#

y me acordaré

ashen mist
#

jaja eso bastará

#

(1,) te da una tupla de un solo elemento

#

la coma es necesario

#

sin ella, tenés una situación así

#
>>> tupla = (1,)
>>> tupla
(1,)
>>> type(tupla)
<type 'tuple'>
>>> noestupla = (1)
>>> noestupla
1
>>> type(noestupla)
<type 'int'>
>>> 
#

no me preguntes para qué sirve una tupla de un solo elemento jajaja

past harbor
#

o sea que..

#

las listas tienen métodos para acceder a datos, modificar, etc

fallow dock
#

para pasar un argumento que necesite ser iterable y sólo necesites un elemento

past harbor
#

pero las tuplas, no?

#

leí que

fallow dock
#

por ejemplo, al iniciar un thread con argumentos

past harbor
#

miTupla[1] = 3

#

está mal

#

ah

#

acabo de leer que no se puede cambiar cosas

#

y qué sentido tiene tenr tuplas si no puedes cambiar las cosas?

fallow dock
#

que las tuplas son súper rápidas

past harbor
#

es para esto que se usa una tupla en vez de un switch?

fallow dock
#

y no consumen memoria casi

ashen mist
#

es que miTupla[1] = 3 intenta reemplazar el segundo elemento de la tupla con un 3

fallow dock
#

de hecho, funciones builtin como zip y enumerate devuelven tuplas

ashen mist
#

y no se puede cambiar la tupla

#

pero sí se puede decir x = miTupla[1] porque en este caso estás viendo un elemento de tu tupla y no lo cambiás

past harbor
#

o sea que en los diccionarios

#

puedes cambiar valores pero no claves

#

en las listas puedes hacer lo que te salga de los cojones

#

y en las tuplas no puedes ver nada más que valores?

fallow dock
#

ye

#

si necesitás pasar un valor iterable que no necesite ser modificado, para eso está la tupla

#

y por ejemplopython if x in (1, 2, 3): pass

#

conviene a

#
if x in [1, 2, 3]:
    pass```
#

aunque puede que el interpretador optimize esos casos

#

y los haga tupla

#

veo que el bytecode es el mismo

#
>>> import dis
>>> dis.dis('x in (1,2,3)')
  1           0 LOAD_NAME                0 (x)
              2 LOAD_CONST               0 ((1, 2, 3))
              4 COMPARE_OP               6 (in)
              6 RETURN_VALUE
>>> dis.dis('x in [1,2,3]')
  1           0 LOAD_NAME                0 (x)
              2 LOAD_CONST               0 ((1, 2, 3))
              4 COMPARE_OP               6 (in)
              6 RETURN_VALUE
hybrid hull
#

dis as in disassemble??

fallow dock
#

yep

past harbor
#

me toca cómo se hace un if, un bucle for, while y do-while @ashen mist

hybrid hull
#

That's super cool

fallow dock
#

you can do that in any language that compiles to bytecode I think

#

for Java, you can use javap, which is a CLI program

ashen mist
#
if (condición que devuelve True o False):
  # código
elif (otra condición):
  # código
else:
  # código
past harbor
#

después de esto me queda lambda, funciones, clases y propiedades

#

y ya terminaré, no hay más

ashen mist
#

no creo que exista for (x = 5; x < 10; x++) en python

fallow dock
#

nope

past harbor
#

aqui me pone esto

ashen mist
#

pero podés hacer for x in cosa_iterable

past harbor
#

ah

#

me pone esto

#

elemento for elemento in lista if len(elemento) > 1

fallow dock
#

los for de Python son for-eachs, a la java for (Ele el : elems) {}

past harbor
#

pero vaya manera más enrevesada de hacer las cosas

fallow dock
#

oh noooo

#

eso es genial

#

creo que fue tomado de lenguajes de usos científicos

past harbor
#

a ver, probaré el if

fallow dock
#

aunque ciertamente es confuso aprender a leerlo

past harbor
#

como

#

va el ternario, @ashen mist

fallow dock
#

la sintaxis es EXPR if EXPR else EXPR

ashen mist
#

min = a if a < b else b por ejemplo

fallow dock
#

'Es mayor' if numA > numB else 'Es menor'

#

y los ternarios son expresiones así que podés juntarlas (?)

#

'Es mayor' if numA > numB else 'Es menor' if 5 > 2 else 'Lol' epic

#

para leerlo naturalmente

#

THIS_THING if THIS_CONDITION else THIS_OTHER_THING

#

THIS_THING si la "condición" es cierta, sino, THIS_OTHER_THING

past harbor
#

me queda

#

cómo crear funciones, clases: getter, setter, propiedades @ashen mist

#

si estás cansado, me dices podemos seguir mañana

fallow dock
#

no me odies, wolf

exotic kiteBOT
fallow dock
#

meto mucho comentario porque me gusta hablar de estos temas en general, no Python (?)

#

no sé si no te estorba

past harbor
#

No es que me estorbe

ashen mist
#

funciones van en forma de def nombre(argumentos):

past harbor
#

sólo que entiendo el 10% de lo que escribes 😄

#

a veces hablas de cosas que ni sé qué son

fallow dock
#

ahhh

#

es que soy estúpido y hablo conmigo mismo

past harbor
#

jamás he dado py y a veces escribes cosas

#

que son demasiado "avanzadas" para mí

fallow dock
#

mejor me las ahorro

#

xd

past harbor
#

qué hice mal

#

ah

#

falta el print?

#

pues no no

#

va

fallow dock
#

pues el código está bien

#

con un print

past harbor
#

qué manía me tiene

#

este edito

#

r

#

em

#

existen funciones privadas y publicas o?

fallow dock
#

no hay conceptos de público y privado en nada en Python, lo más parecido son cosas como descriptors que tienen funciones totalmente diferentes

#

y no vas a ver eso tampoco

#

o sea, no hay concepto de cosas que lo garanticen

past harbor
#

ohvaya

fallow dock
#

como convención, si una variable o método empieza con _ o __, significa que no deberías tocarlo

past harbor
#

umm pues solo me quedan las clases

#

a ver

fallow dock
#

ah, pero dijiste que tenías que usar @property, así que técnicamente sí vas a ver descriptors, pero no hace falta que te definan qué son realmente

past harbor
#
class MiClase:
    def __init__(self, tipo): # Constructor
        self.tipo = tipo 
    def getTipo(self): # Método getter
        return self.tipo
    def setTipo(self, tipo):
        self.tipo = tipo`
#

a ver si me aclaro

#

el __init__ es el constructor?

#

y el self qué es

fallow dock
#

es un equivalente a lo que llamarías constructor, sí

past harbor
#

si también viene por parámetro

#

es el this?

fallow dock
#

ok, creo que es mejor que te explique algo particular de clases en Python

past harbor
#

aunque en java no tenemos un this en parámetro

fallow dock
#

porque sino self como parámetro te va a resultar súper confuso

past harbor
#

leí que el primer parámetro era un objeto

#

o algo así

#

aunque tampoco entiendo mucho a que viene eso 😄

fallow dock
#

en Python creás objetos de esta forma (acá sin overridear init)

#
class Classy:
    def algo(self):
        print("Algo!")

obj_a = Classy()
obj_b = Classy()```
#

el tema con el llamado de métodos y self

#

es que, cuando le decís a un objeto que haga algo, por ejemplo:

#
class Classy:
    def algo(self):
        print("Algo!")

obj_a = Classy()
obj_b = Classy()

obj_a.algo()```
#

esa llamada de .algo() va a pasar implícitamente al objeto obj_a como primer argumento del método

#

eso también es técnicamente porque los métodos pertenecen a la clase (Classy.algo, el cual podés llamar con esa notación)

#

de hecho, estos son equivalenes:

#
class Classy:
    def algo(self):
        print("Algo!")

obj_a = Classy()

obj_a.algo()
# es lo mismo que:
Classy.algo(obj_a)```
#

las clases son objetos en Python

#

Classy.algo es la función que querés llamar, y la querés llamar en relación a un objeto (que va a ser self)

#

entonces, literalmente eso hace que el objeto en cuestión sea un argumento más

#

obj_a.algo() realiza el mismo llamado, pero el pasado del objeto como primer argumento lo hace implícitamente

#

también notá que self no tiene nada de especial como nombre, es un parámetro nomás - podés ponerle el nombre que quieras

#
class Classy:
    def algo(this, arg_a, arg_b):
        print(this, arg_a, arg_b)

obj_a = Classy()

obj_a.algo("uno", "dos")
# es lo mismo que:
Classy.algo(obj_a, "uno", "dos")```
#

imprime

#
<__main__.Classy object at 0x7f160ab0cf70> uno dos
<__main__.Classy object at 0x7f160ab0cf70> uno dos```
#

y eso es todo lo que tengo por ahora para desmistificar el self

past harbor
#

vale, gracias

#

por qué esto está mal?

#
class Persona:
  def __init__(self, nombre, edad):
    self.nombre = nombre
    self.edad = edad
  def getEdad(self):
      return self.edad
  def setEdad(self, edad):
    self.edad = edad

p1 = Persona("Juan", 23)

print(p1.getEdad())
print(p1.setEdad(27))
#

bueno la identación da igual porque no rompe

#

no va el setEdad

#

me dice none

fallow dock
#

todas las funciones que no tienen un return explícito retornan None

#

en este caso, setEdad hace algo - setea self.edad

#

y luego la función retorna None

#

así que print(p1.setEdad(27)) se evalúa a print(None)

past harbor
#

tengo la manía de java

#

a ver

fallow dock
#

así que sí, está haciendo lo que vos querés - cambiar self.edad

#

pero no querés imprimir eso

past harbor
#

sí tengo que hacerlo fuera

#

es que en java te deja hacerlo

#

se me quedó la costumbre xd

fallow dock
#

podés pensar que es un setter comojava void setAlgo(int algo) { this.algo = algo; }

#

y no imprimirías un void

#

Java directamente te lo prohibiría

past harbor
#

me quedan

#

las propiedades privadas

fallow dock
#

no obstante, no sé si debas usar setters y getters, habías mencionado properties

#

tu profesor escribió funciones así, setAlgo, getAlgo?

past harbor
#

ah

#

pero

#

no se puede usar getter ysetter?

fallow dock
#

existen de otra forma en Python

past harbor
#

me enseño a que se podía

fallow dock
#

y no se trata de asegurar que algo sea privado, sino de otra cosa

past harbor
#

poner nombre de la clase

fallow dock
#

si querés te explico la razón

past harbor
#

barra baja creo? y el nombre de la propiedad privada

#

o con el property

fallow dock
#

que sino tampoco va a tener mucho sentido

#

las dos cosas combinadas

past harbor
#

uf

fallow dock
#

el tema es este

#

en realidad esto es algo propio de Java btw, C# y Kotlin usan otras estrategias que no te obligan a escribit setters y getters de partida

#

ahora, lo de forzar la privacidad, es algo que comparten

#

so lemme see, en Java, tendrías algo como esto

#
class Dude {
    String name;
    int age;

    Dude(String name, int age) {
        this.name = name;
        this.age = age;
    }
}```
#

y luego podrías crear un Dude de la forma

Dude wolf = new Dude("Wolf", 25);```
past harbor
#

fallow dock
#

pero, ignoremos lo de "privacidad" por un momento

#

técnicamente, querés que quien use esto, disponga del nombre y la edad

#

tonces podría tranquilamente hacer wolf.name, wolf.edad - de hecho el 99%, los setters y getters no hacen más que eso

#

el tema es... qué pasa si yo quiero cambiar Dude, por ejemplo para alertarme de si hay un cambio de name?

#

porque necesito procesar algo extra

#

si de pronto vuelvo name privado, rompo la interfaz, y el otro programador me acuchilla (aunque si estamos programando en Java, deberíamos haber sido despedido antes por no seguir los patrones de diseño de Java)

#

en Python y otros lenguajes, lo que hacés es dejar estas propiedades accesibles sin más, tal como son

#

por ejemplo

#
class Persona:
    def __init__(self, nombre, edad):
        self.nombre = nombre
        self.edad = edad```directamente, sin getters ni setters
#

y quien use esta clase puede hacer personita.edad o personita.edad = ... si quiere

#

a mí no me importa realmente que sea privado - mi clase tiene una función, y que el otro haga lo que quiera (incluyendo romper la clase)

#

no obstante, asumamos que quiero que mi clase haga algo extra

#

como imprimir "Es mayor de edad!" cuando la edad sea cambiada a 18

#

si en el código del otro está lleno de personita.edad = ..., entonces estoy arruinado, no puedo hacer nada, amirite?

#

bueno, en Python en realidad no estás arruinado

#

podés hacer que personita.edad = ... llame a una función, literalmente

#

o sea, se ve como una asignación, pero podés hacer que implícitamente llame a una función

#

para eso está @property

#

lo que te permite es "poner setters/getters" de la nada, y preservar la interfaz

#

tu otro programador no tiene que reescribir nada

#

entonces, vamos a aplicar eso con el código anterior

#
class Persona:
    def __init__(self, nombre, edad):
        self.nombre = nombre
        self.edad = edad

p1 = Persona("Juan", 17)
p1.edad = 18

print(p1.nombre, 'tiene', p1.edad, 'años')```código original, Juan cumple 18
#

ahora definamos un setter

past harbor
#

vale, gracias

#

mañana le doy otro repaso

fallow dock
#
class Persona:
    def __init__(self, nombre, edad):
        self.nombre = nombre
        self._edad = edad

    @property
    def edad(self):
        return self._edad

    @edad.setter
    def edad(self, edad):
        self._edad = edad
        if self.edad == 18:
            print("ALERTA!", self.nombre, "ES UN ADULTO AHORA")

p1 = Persona("Juan", 17)
p1.edad = 18

print(p1.nombre, 'tiene', p1.edad, 'años')```
#

@past harbor okis

#

checá que sigo haciendo p1.edad = 18

#

y el programa imprime python ALERTA! Juan ES UN ADULTO AHORA Juan tiene 18 años

#

y no hice chequeo de que realmetne tenga 18 :x

#

fixed

ashen mist
#

cómo te va, lobo? tuve que hacer otras cosas en casa un rato

past harbor
#

me queda repasar property y entender las propiedades privadas

#

y ya eso es todo lo que entra en el examen

#

lo haré mañana, estoy agotado. esto de entender un lenguaje que no tiene nada que ver a lo que estoy acostumbrado es pesado

ashen mist
#

@property esto?

past harbor
#

te agradezco mucho la ayuda

#

seh

#

y esto

#

espera t enseño

ashen mist
#

gracias a manusaurio también jaja

past harbor
#

a los dos

fallow dock
ashen mist
#

@property es como el "getter"

past harbor
#

esto

#

me duele mucho la cabeza leyendo __ .__

ashen mist
#

ah

past harbor
#

tengo que repasar eso más

#

y entenderlo xd

ashen mist
#

los doble _ marca algo, ya sea una función o una propiedad, como privado

past harbor
#

y est

ashen mist
#

no es reaaaalmente privado porque todavía se puede acceder a ello usando _NombredeClase__nombredecosa

#

como mostraste en tu primer ejemplo

past harbor
#

pero

#

por qué hace

#

pr._UnaPrivada__Privada

#

qué lío lol

ashen mist
#

eso es como "si realmente tenés que acceder a esa propiedad directamente, podés hacerlo así"

#

si simplemente decís pr.Privada, python te va a gritar

#

porque esa propiedad es definida en __init__ como self.__Privada

past harbor
#

pero

#

a ver

#

para hacer algo público escribes

#

self.Publica

#

para hacer algo privado

#

self.__Privada

ashen mist
#

con doble _

past harbor
#

y de dónde cojones

#

se saca esta llmada?

#

pr._UnaPrivada__Privada

ashen mist
#

eso es el "hack" para romper las reglas de la privacidad jaja

past harbor
#

si pero

#

me refiero a que no entiendo las barras

ashen mist
#

recordás que en python realmente no existe la privacidad?

past harbor
#

de dónde cojones se ha sacado esa definicion

#

por qué es

#

._ y después __

ashen mist
#

la forma es _NombreDeClase__NombreDeCosaQueQueresAcceder

#

python, en el fondo, cambia los nombres de las propiedades y funciones privadas

fallow dock
#

podés hacer dir(objeto) para ver sus atributos

#
>>> class C:
...     __hola = 5
... 
>>> dir(C)
['_C__hola', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__']
ashen mist
#

así que cuando definís una función o una propiedad con __ para hacerla privada, python cambia su nombre a _Clase__NombreDeCosa

fallow dock
#

fijte que __hola no existe entre los atributos de mi clase

past harbor
#

pero

fallow dock
#

el primer atributo, en vez de eso, es _C__hola

past harbor
#
pr = UnaPrivada()
print("Privada:", pr._UnaPrivada__Privada)

qué cojones hace aquí

ashen mist
#

eso es para evitar que el usuario acceda a una función o propiedad privada sin querer

past harbor
#

llama a una funcion despues a la clase y despues la propiedad?

ashen mist
#

no, simplemente accede a la propiedad privada

past harbor
#

UnaPrivada()

#

es la clase?

ashen mist
#

o sea, la propiedad definida por "self.__Privada"

#

sí, porque dice "class UnaPrivada"

past harbor
#

mejor dejémoslo 😄

#

me está petando la cabeza con tantas barras bajas y puntos

#

me lo miraré mañana de nuevo

ashen mist
#

la clase se llama UnaPrivada, así que el verdadero nombre de esa propiedad privada (llamada Privada) es _UnaPrivada__Privada

#

jaja ok

past harbor
#

te juro

#

que me peta la cabeza leyendo _

#

nunca me entero de nada

fallow dock
#

Python es terriblemente hacky, so

#

xD

#

check this shit out

#
>>> class C(int):
...     def __call__(self, other):
...             return C(self + other)
... 
>>> C(5)(2)
7
>>> C(50)(25)(25)
100```
ashen mist
#

bruh no lo confundas jajaja

fallow dock
#

es que son demasiadas cosas que no tienen comparación con otros lenguajes

#

sobre todo más restrictivos

#

pero al mismo tiempo sigue estando lleno de reglas

#

de hecho por ej. property es una clase, @property es usar esa clase como decorador

#

pero no saber qué diablos es eso irremediablemente va a hacer que parezca magia

#

so hacer cosas como definir edad(self) y edad(self, edad) deja de ser tan claro cuando recordás de que sólo puede existir un edad

#

que es parte de la magia negra que hace @property

ashen mist
#

wolf nos va a matar

fallow dock
#

wolf aprobará y luego se irá a trabajar a Oracle

ashen mist
#

el nuevo JDK, hecho por lobos

past harbor
#

No te preocupes

fallow dock
#

va a desarrollar cx_Oracle

past harbor
#

Lo primero que haré cuando vea mi DNI y ponga

#

"aprobado" será dirigirme a mi mochila

#

sacar los apuntes y romper en pedazos todo lo relacionado con Python 😄

fallow dock
#

oh, no sabía que le decían DNI en España también

past harbor
#

sí claro

#

es dni

ashen mist
#

que es eso

fallow dock
#

Documento Nacional de Identidad

ashen mist
#

ah

past harbor
#

documento nacional de identidad

fallow dock
#

al menos acá

past harbor
#

ni idea como se dice en ingles

fallow dock
#

id

ashen mist
#

acá DNI es una agencia del gobierno jajaja

fallow dock
#

bueno, los estadounidenses no tienen algo como DNI, no?

#

presentan el carnet de conducir o algo así (?)

#

qué documentos tienen como constancia de quiénes son?

ashen mist
#

sí, pero no tiene que ser ciudadano para obtener una tarjeta de conducir

#

bueno, una tarjeta de conducir es usualmente lo que la gente usa

#

por ejemplo si quieren entrar a un bar y necesitan mostrar que tienen al menos 21 años

fallow dock
#

y si no tengo eso?

ashen mist
#

no es tan común andar fuera de casa sin tu tarjeta porque es básicamente tu prueba de identidad

#

a menos que seas alguien raro que anda con su pasaporte 24/7

fallow dock
#

y qué documentación se presenta en el examen de conducir, para que sepan qué edad tenés? thinky

#

es que un DNI sirve específicamente para eso, no es pasaporte ni tarjeta de conducir ni nada similar

ashen mist
#

no sé si piden eso, pero también hay certificados de nacimiento

fallow dock
#

simplemente indica quién sos

ashen mist
#

bueno, no creo que tengamos algo así

fallow dock
#

así que es normal llevarlo

#

(aunque no todo el mundo lo hace)

#

por ej., es algo que la policía puede pedirte si sos detenido

ashen mist
#

acá, si te piden prueba de identidad, le mostrás tu tarjeta de conducir o tu pasaporte

#

porque esas cosas llevan una foto de vos

#

hay otras cosas que comprueban que naciste en EEUU o que sos un ciudadano de este país

mortal dagger
#

por favor no trabajen en Oracle

ashen mist
#

LOL

mortal dagger
#

se los ruega su amigo wzrdd

fallow dock
#

si el sueldo es bueno, acepto, y seguramente lo es thinky

ashen mist
fallow dock
#

weno, pagan menos que féisbuk

ashen mist
#

porque si trabajás en féisbuk, les vendés tu alma

ashen mist
#

lol wat

fallow dock
#

rip embed

past harbor
#

dios santo

#

11mil x hacer apps de movil

#

😄 me apunto

fallow dock
#

About 300 Oracle employees walked off the job on Thursday to protest founder and Executive Chairman Larry Ellison's decision to hold a fundraiser for President Donald Trump the previous evening

past harbor
#

ah espera

#

qesta en dolares

#

a

#

ver

#

10mil euros

fallow dock
#

Larry Ellison es medio fachito

#

Ellison was critical of NSA whistle-blower Edward Snowden, saying that "Snowden had yet to identify a single person who had been 'wrongly injured' by the NSA's data collection".

#

pero tiene 75

#

por ahí que se muere y lo reemplaza alguien mejor (?)

ashen mist
#

a veces se desea lo mismo en cuanto a nuestros políticos

#

"ojalá esta hamburguesa sea la última para él"

fallow dock
#

Jeff Bezos debe de ser el empresario más odiado

#

con justas razones

#

me causa gracia que se parezca a Lex Luthor

ashen mist
fallow dock
#

pues debería mejorar las condiciones de trabajo de sus empleados

ashen mist
#

eso le va a costar más de 10 mil millones jajaj

#

anyway, no sé cómo funciona la mente de alguien con tanto dinero

#

ok, debería hacer un poco de ejercicio

#

y cambiar mi foto... me da asco

fallow dock
#

va a ser otra cosa random?

ashen mist
#

no sé

#

tal vez va a ser el mismísimo jeff bezos

fallow dock
#

wacky Jeff Bezos?

ashen mist
#

me recuerda a ese tipo de Whiplash

fallow dock
#

"I WANT PICTURES OF SPIDERMAN!"

mortal dagger
#

yo no vendería mi alma a esos inhumanos

#

el software es para mí un arte y un acto político

#

eso no lo tranzo

ashen mist
#

tranzar?

#

eso ahí no significa besar ?

fallow dock
#

eso es en Argentina, aunque no sé si se sigue usando

mortal dagger
#

sabes que nunca me había cuestionado qué significa o si existe

#

con no tranzar o transar, a esta altura ya no sé, me refiero a que no cambiaría mi posición con respecto a eso

#

no está en discusión

#

quizás solo tiene ese significado para mí en mi propio lenguaje

fallow dock
#

besarías a Jeff Bezos?

#

pls

mortal dagger
#

sí, guardaría veneno en la boca y se lo traspasaría

#

haría ese sacrificio por la humanidad

fallow dock
ashen mist
#

Creo que leí una historia de una mujer que se metió veneno en las .. partes íntimas para intentar envenenar a su marido durante sexytime

fallow dock
#

Vagina homicide is, needless to say, a highly unusual crime
El periodista se moría de ganas de escribir esa línea

ashen mist
#

La cima de su profesión

bold gull
fallow dock
#

please, no dick pics

ashen mist
#

wat

mortal dagger
#

Griffth 💖

bold gull
#

Ok, I got it, I gotta send dick pics

glass dragon
sacred harbor
thin copper
#

Suki come here

eager wagon
wheat nacelle
#

@bold gull Are you another one of those "Griffith did nothing wrong" people?

median trail
#

@ashen mist How come routers' ports are shut down by default?

bold gull
#

Perhaps, remember that Griffith is a good person.

#

Btw, I thought that Griffith was gay because he had a strange obsession with guts.

ashen mist
#

@median trail a process will open a port to listen on it. So if there isn't a process running to listen on that port, there's nowhere for any data sent to go

median trail
#

but switches have theirs opened

ashen mist
#

That's a different type of port, I think

#

I'm referring to transport layer ports

median trail
#

Hmmm I don't know what those are

#

We have just learned about what an interface is

#

and what a NIC is

bold gull
#

¿Nivel de inglés?

lavish estuary
#

Quita eso

lavish estuary
#

What the what

eager wagon
#

@amber granite *that is spam. Did you read the rules of this network before thinking this was a good idea?

vestal pine
median trail
#

@ashen mist Hiiii, I have an oral presentation on HTTP, and so far I'm a bit lost haha

I know that HTTP stands for Hypertext transfer protocol, and it's a protocol to transfer hypertext from the web-server to a web browser

#

and Hypertext is like a normal text that also includes hyperlinks to other texts related

#

but I have some questions, is any text that also includes images, videos, music, etc. Also a hypertext?

#

I don't understand how the data gets delivered from the server to the client

#

To present a Web page, the browser sends an original request to fetch the HTML document that represents the page. It then parses this file, making additional requests corresponding to execution scripts, layout information (CSS) to display, and sub-resources contained within the page (usually images and videos). The Web browser then mixes these resources to present to the user a complete document, the Web page. Scripts executed by the browser can fetch more resources in later phases and the browser updates the Web page accordingly.

#

So the HTML document is like a black-and-white drawing, CSS is like the techniques used to decorate and paint, and the sub resources are extra decorations?

#

is HTTP the one that makes all of those GET requests?

#

and displays a web page as a mix of all of the resources requested?

fallow dock
#

it's not a protocol to "transfer hypertext" specifically

#

it's used to transfer binary data all the time

median trail
#

I don't get it

fallow dock
#

"binary" as in "not-plain text"

#

in fact, if you have a tool like CURL you can "see" the binary in your terminal

median trail
#

hmmmm this is too complicated to me

#

I don't get any of this

fallow dock
#

if I do curl -I with that URL, it will perform a GET request to that address

#

and it will show me the HTTP headers in response

median trail
#

I don't even know what a GET request is

fallow dock
#
[manuel@6500 ~]$ curl -I https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png
HTTP/2 200 
accept-ranges: bytes
content-type: image/png
content-length: 5969
date: Sun, 23 Feb 2020 21:01:24 GMT
expires: Sun, 23 Feb 2020 21:01:24 GMT
cache-control: private, max-age=31536000
last-modified: Tue, 22 Oct 2019 18:30:00 GMT
x-content-type-options: nosniff
server: sffe
x-xss-protection: 0
alt-svc: quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000```
median trail
#

ok I'm out

fallow dock
#

if I do --output - I'll see "the image"

#

humm

#

a GET is just a type of request

#

you can tell the server "hey, I want to POST this" or "I want to GET this"

#

it's really arbitrary in practice, but usually GET means "give me the resource I'm asking for"

#

for example

#

when you type google.com in your browser and press enter, you do a GET request for google.com

#

(which will usually default to http://google.com, the "URI scheme" like http is needed)

#

so the server will reply with packets, which contain a bunch of "headers" describing the response

#

and also the "content"

#

if there's any

#

@median trail let me show you a very simplyfied transaction

#

imma strip all the unnecesary headers

#
[manuel@6500 ~]$ curl -I http://google.com
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/```I tell `http://google.com` "hey, give me your page", and Google tells me "301 -> you should go to `http://www.google.com/` instead" (with `www.`)
#

so your browser would usually follow that automatically

#

doing yet another get request, this time to the location Google told you

#
[manuel@6500 ~]$ curl -I http://www.google.com/
HTTP/1.1 200 OK```this time, Google answers with "200 -> yeah, this is what you wanted"
#

and it will also respond with all the HTML the page is made of

#

in that HTML, you browser might find other resources, for example

#

an img tag with some image

#

those things are not included in the original response - your browser needs to ask for them specifically

#

so if there's something like <img src="someimage.png">, your browser will do a GET request to http://www.google.com/someimage.png

#

it's basically a ping pong game

median trail
#

I didn't understand what's the role of HTTP in what you said

fallow dock
#

it's a protocol - a set of things to expect and rules on how to respond

median trail
#
[manuel@6500 ~]$ curl -I https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png
HTTP/2 200 
accept-ranges: bytes
content-type: image/png
content-length: 5969
date: Sun, 23 Feb 2020 21:01:24 GMT
expires: Sun, 23 Feb 2020 21:01:24 GMT
cache-control: private, max-age=31536000
last-modified: Tue, 22 Oct 2019 18:30:00 GMT
x-content-type-options: nosniff
server: sffe
x-xss-protection: 0
alt-svc: quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000```

So the headers are just tiny bits of data that modifies the response or request is made? like asking for specific information?

fallow dock
#

basically a very specific way to send messages

#

and how to reply them

median trail
#

that's http, right?

fallow dock
#

yes

#

well an HTTP response has two parts

#

one are the headers, the other one is the data

#

for example

median trail
#

but what does http ask for? what does it receive? a web page? content?

#

I'm lost

fallow dock
#

if a site gives you index.html, what it actually gives you is a response that contains "hey, this is what you asked for, this date, this time, with some other details"

#

and then that's followed by the actual HTML, or any other type data

#

well, actually

#

you can send whatever you want via HTTP

#

what your browser does is ask for resources one by one... for example, via HTTP, you ask for a site

#

that sites gives you a response with headers + HTML

median trail
#

so HTTP is just a way to communicate with the server?

fallow dock
#

then your browser parses that HTML, and finds new things it should ask for, such as images or videos or JS

#

so your browser, once again via HTTP, will ask for that image, that video, that JS... each of them will need an individual request via HTTP

#

yes

#

and all of those transactions should have their own headers + content

median trail
#

then, why is it called hypertext transfer protocol? I thought hypertext was just text with links included

fallow dock
#

probably because it was the 80s

#

I really don't know about that

median trail
#

Hmmm okay, I just wanted to make sure I knew what hypertext was haha

fallow dock
#

I mean, php used to mean "Personal Home Page"

#

but people said "Hey, let's do OUR ENTIRE BACKEND LOGIC In this language"

#

so now it means "PHP: Hypertext Preprocessor"

median trail
#

El hipertexto ha sido definido como un enfoque para manejar y organizar información, en el cual los datos se almacenan en una red de nodos conectados por enlaces. Los nodos contienen textos y si contienen además gráficos, imágenes, audio, animaciones y video, así como código ejecutable u otra forma de datos se les da el nombre de hipermedio, es decir, una generalización de hipertexto.

wait this means that all the content of a webpage, images and scripts included, are hypertext*

fallow dock
#

so I'm afraid it's not always a good idea to tell what your product does in its name lol

#

I would not call an image "hypertext", in fact that quote gives them the name "hypermedia"

#

which also sounds bad but whatever

median trail
#

ah

fallow dock
#

it's like too much of an effort to make it make sense...

median trail
#

so hypertext is just text with links?

fallow dock
#

yes

#

it doesn't even need to be HTML

#

in fact, I think this concept goes beyond computers

#

because I had to do artistic "hypertext" works

#

and, I mean, nowadays HTTP is used for many things that may not have links at all

#

like RESTful APIs

#

(links as in "references to other things")

median trail
#

I have an oral presentation on this, and it'd be awesome if I could do some get requests to show my class how it's done

fallow dock
#

your browser does it for you all the time

#

but

#

there's a way to see them in action, in your browser

#

do you use Chrome/Chromium?

median trail
#

yes

fallow dock
#

this will show you a result very similar to what you saw in my curl requests

#

go to some page and press F12

median trail
#

ok

fallow dock
#

then go to the Network tab

median trail
#

ok

#

done

fallow dock
#

now... type some URL in the browser (without closing the dev tools) and press enter

#

and see the magic happen

median trail
#

yes

fallow dock
#

well, guess what - those are resources

median trail
#

😮

fallow dock
#

if you click on them, you can see some details

#

for example

#

there's also a Headers sub-tab there as you can see

#

and you can see the content in the other tabs

#

is that good enough?

median trail
#

oh

#

yes

#

thank you!!

fallow dock
#

your browser is a really smart thing, so it's doing a million things automatically

median trail
#

should I also talk about HTML?

fallow dock
#

but you can tell that for every request your browser does, some other resources might be asked for after that

#

in fact, your browser might keep asking for things, for exaple if some JavaScript program you are running (given by your server) needs them

#

should I also talk about HTML?
I don't know, probably

#

the main job of a web browser is to ask for things, parse HTML and render things

#

in reality, the HTTP part is just the protocol to send messages

#

so HTTP doesn't know anything of "HTML", "PNG" or "JavaScript"

#

by the way, the response headers serve a wide variety of purposes

#

for example, you might have noticed that sometimes you click on some link to an image (in some shady sites) and your browser either opens the image or downloads it

#

that kind of behaviour and many more are specified in the response headers

#

the server might answer with "ok, you asked for this - download it"

fossil cipher
#

Safari blocks those downloads

#

Until you allow it

fallow dock
#

yeah, the browser is free to interpret those headers the way it wants to

#

they're just text

fossil cipher
#

Yeah

fallow dock
#

btw, @median trail, the browser sends headers in its requests every time it asks for things as well - for example, the user agent, which is just a bunch of text that tells what browser you're using

#

some servers will adjust their response to that, for example to give a mobile version of the webpage

fossil cipher
#

@fallow dock Are you into IT security?

fallow dock
#

no

fossil cipher
#

Alright

fallow dock
#

I just like to break things

fossil cipher
#

Well

#

That's what we do!

median trail
fallow dock
#

what's your public?

median trail
#

students that are doing a CCNA certification

fallow dock
#

😓

median trail
#

but we don't know a lot since we are just starting

fallow dock
#

mmmm there was a good CBS series on this kind of thing

median trail
#

but we are beginners pandasad

fallow dock
#

no, I mean

#

it was quite simple to understand

#

actually I don't know if it was "CBS"

#

PBS

#

damn names

#

the CrashCourse channel on YouTube

#

it seesm they don't have anything on this topic lol

#

oh they have

#

some inspiration

ashen mist
#

@median trail lo siento, estuve en una boda

#

Creo que ya te han explicado todo?

median trail
ashen mist
#

Le digo "Hyperlink" a esa cosa de href

median trail
#

yes but I'm just explaining the difference between those two

#

hipertext and just text

fallow dock
#

is this okay?
that is correct, actually

ashen mist
#

Ah entonces debería estar bien

fallow dock
#

also a visual way to tell these terms are totally pointless...

ashen mist
#

Luego deberías aprender DNS

median trail
#

what's the application layer?

fallow dock
#

it's the one that contains the actual protocol you're using to "talk"

#

layers are a bit of a mess

#

but as an stupid example, if you want to talk to someone in your classroom, you might write something in a piece of paper and throw it as a paper plane

#

so you could say there are at least two layers there, one being the paper and the action of throwing it

#

and the other one being your language, the things written

#

to talk in HTTP, you need to be in an "application" layer, that sits over other ones

#

for example, TCP/IP and UDP

#

I do not remember all the typical layers in the internet or how they are grouped, they are a bit of a mess

#

but I hope you liked my stupid example

#

this talks about it

median trail
#

a client server protocol is a protocol where a client and a server are involved and they interact with each other?

fallow dock
#

or maybe it doesn't, but nice video regardless 🤔

#

a client server protocol is a protocol where a client and a server are involved and they interact with each other?
...yes?

#

oh it does talk about layers!

#

...and it doesn't say much more than what I said

median trail
fallow dock
#

but it has many other details on other related topics

#

do you know what "stateless" mean in this context?

#

this is why cookies exist, if you want to talk about that as well

median trail
#

I don't know what that is haha

fallow dock
#

I need a formal description first thinky

#

I'll give my own, you should look up something more "precise" later

#

but I want the concept itself to come across

#

"stateless" means that the information in a transaction doesn't change, it's always the same, so for example

#

in HTTP, each transaction is one request and one response

#

it's not a connection that's established for a prolonged time to send data back and forth constantly

#

so there are some implications there

#

it means that if someone visits a page in your site, and then goes to another page in your site, there's nothing in the protocol to "remember" what the user did before

#

every visit is a new transaction

#

so that's why cookies exist: the server might tell the client "please, set this cookie so I know who you are in your next visit to one of my pages"

#

so the next time the client asks for a page, it will include a header with that cookie... so I can tell "plase Mr. Server, I want this resource... also, I have this cookie with me"

#

so that way the server can read the cookie and adjust its response, even though it's a totally new transaction

#

I hope you're liking my dumb examples

#

this way a server can tell if you're logged in, if you set some option like dark theme in YouTube, etc.

#

about methods, you already saw GET, but there are others as well, POST, PUT, DELETE...

#

99% of the time, your browser uses GET

#

and you saw server codes as well, I showed you a 301 (Moved Permanently) - if you go to google.com, the server will tell you "no, 301, but you can go here:" (the domain starting with www. instead) in a header - it depends on your client to follow that

#

Chrome nowadays hides the full URL for some reason, so it's hard to tell

#

but if you click on it and move the cursor around to edit it (with the arrow keys) you will see all of it

#

and you'll notice you'll never be in https://google.com, it always redirects you to https://www.google.com

#

anyway, I gotta go, good luck

rain ermine
#

Guys

#

How can I check what motherboards my case can fit for my pc

fallow dock
#

there's no easy way but by looking at the distribution of the bolts it can hold

#

(for most cases, you'd need to open it)

#

or if you miraculously know the name of the case or you haven't throw away the manual, you can actually read if it's for ATX or what

rain ermine
arctic niche
#

Yes

#

No

#

Maybe

rain ermine
#

What

crystal kraken
#

#7

fathom flame
#

To convert formula units to moles you divide the quantity of formula units by Avogadro's number, which is 6.022 x 1023 formula units/mole.

arctic niche
#

Use avogrados number

#

Divide

silver bear
#

Pensé lo mismo

crystal kraken
#

thx

arctic niche
#

It is an arbitrary but useful number

rain ermine
#

Can someone help me with math halal

arctic niche
#

Uh sure?

silver bear
rain ermine
#

(3+4+2)^2 halal halal halal

silver bear
arctic niche
crystal kraken
#

81

rain ermine
#

Ok

#

Show ur work

crystal kraken
rain ermine
#

Ay

#

I want one of those calculators

crystal kraken
arctic niche
#

(7+2)^2 = 9^2 = 9*9 = 81

rain ermine
#

Are they expensive

crystal kraken
#

Meh

arctic niche
#

@rain ermine a scientific calculator does the same thing

crystal kraken
#

I don't think so

arctic niche
#

Yes

#

Like 60 bucks

crystal kraken
#

The CE is rly caro tho

arctic niche
#

Used

#

75 if New

rain ermine
#

Nah

#

I’d rather buy ram

arctic niche
#

Check Amazon

#

You don't even use them un college

crystal kraken
#

Why would you need more than 16 gb

rain ermine
#

I only have 8 my guy

arctic niche
#

You have to use just mental math

crystal kraken
#

I see

#

Still pretty good

#

unless you open a chrome tab

rain ermine
#

I’m probably going to be getting a new mobo

#

Nah

#

Wow my parents are gonna be Poor

crystal kraken
#

no u

arctic niche
#

Why

rain ermine
#

I want more pc parts and then these expensive headphones

arctic niche
#

Spoiled

rain ermine
#

Ps they’re not beats

arctic niche
#

Wow you aren't spoiled because they aren't beats

#

Proud of you

rain ermine
#

Check em out

arctic niche
#

No

rain ermine
#

Money doesn’t grow on trees

crystal kraken
#

Where do you think paper comes from

rain ermine
#

Trees