-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Se desarrollan funciones lamnda y se da solución al reto. #5
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments
@@ -112,7 +112,7 @@ venv/ | |||
ENV/ | |||
env.bak/ | |||
venv.bak/ | |||
|
|||
reto07/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unas el nombre convencional de ENV para tu entorno, como vez está arriba ignorado.
challenge.py
Outdated
''' | ||
def homeless(values): | ||
if values['organization'] == '': | ||
values['Homeless'] = True | ||
else: | ||
values['Homeless'] = False | ||
return values | ||
|
||
workers = list(map(homeless, DATA)) | ||
''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Es mejor hacer un commit para guardar esto. Trata de dejar limpio tu código
challenge.py
Outdated
|
||
''' | ||
def homeless(values): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aquí pasan por referencia así que modificas directamente DATA.
challenge.py
Outdated
|
||
''' | ||
def homeless(values): | ||
if values['organization'] == '': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esto ya es un booleano
all_python_devs = filter(lambda x : x['language'] == 'python', DATA) | ||
all_Platzi_workers = filter(lambda x : x['organization'] == 'Platzi', DATA) | ||
adults = filter(lambda x : x['age'] > 18, DATA) | ||
workers = list(map(lambda x: dict(x, **{'Homeless':True}) if x['organization'] == '' else dict(x, **{'Homeless':False}), DATA)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prioriza que tu código sea entendible sobre que sera corto. DRY! dict(x, **{'Homeless':True}) esto está dos veces, una mejora sería:
list(map( lambda x: dict(x, **{'homeless': True if x['organization'] == '' else False }), DATA))
Pero no requieres el if, por que x['organization'] == ''
ya es booleano.
list(map( lambda x: dict(x, **{'homeless': x['organization'] == '' }), DATA))
all_Platzi_workers = filter(lambda x : x['organization'] == 'Platzi', DATA) | ||
adults = filter(lambda x : x['age'] > 18, DATA) | ||
workers = list(map(lambda x: dict(x, **{'Homeless':True}) if x['organization'] == '' else dict(x, **{'Homeless':False}), DATA)) | ||
old_people = list(map(lambda x: dict(x, **{'old':True}) if x['age'] > 30 else dict(x, **{'Old':False}), DATA)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list(map(lambda x: dict(x, **{'old': x['age'] > 30 }), DATA))
all_python_devs = filter(lambda x : x['language'] == 'python', DATA) | ||
all_Platzi_workers = filter(lambda x : x['organization'] == 'Platzi', DATA) | ||
adults = filter(lambda x : x['age'] > 18, DATA) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bien!
No description provided.