21
loading...
This website collects cookies to deliver better user experience
*values
part of the picture.*args
) and how to use it to eliminate boredom and reduce tension in our Python functions and methods.dispatch_foe
function that accepts a list of names of people and then reduce pollution by doing what is necessary.from GenghisKhan.actions import kill
def dispatch_foe(name: str) -> bool:
success: bool = kill(name) # ends the life
return success
for name in list_of_names:
dispatch_foe(name)
from typing import List
from GenghisKhan.actions import kill
def dispatch_foe(names: List) -> bool:
success: bool = True
for name in names:
success = success and kill(name) # tells us if and only if everyone died
return success
dispatch_foe
like so:# people who we both share mutual hate
enemies = ["Erons", "Victor Aiyeola", "Davidemi"]
# test to confirm that they were successfully dispatched
assert True is dispatch_foe(enemies)
*args
does. That means you'll wallow in complete ignorance till the end of your life span.*args
, our refusal to reject Isaac's answer will spell the end of that person who may be a key soul to solving world hunger and therefore lead to millions and billions of deaths. This is why we always have to reject Isaac's first solution to solving any problem.*args
is a beautiful and pythonic way to do that.from typing import Sequence
from GenghisKhan.actions import kill
def dispatch_foe(*names: Sequence[str]) -> bool:
success: bool = True
for name in names:
success = success and kill(name) # tells us if and only if everyone died
return success
# 'do' Erons alone
assert True is dispatch_foe("Erons")
# 'do' Erons and someone else
assert True is dispatch_foe("Erons", "Someone else")
# 'do' people who hate me
assert True is dispatch_foe("Erons", "Davidemi", "Victor Aiyeola")
and
```**kwargs```
(we'll learn this later) can make debugging quite evil. So you'd want to watch your back whilst using them.
## Disclaimer
There is no `GenghisKhan` module implemented anywhere in the Python standard library or Pypi index or anywhere. No murders were committed in the course of this code and my *enemies* are excellent engineers with happy jobs (I don't have one, so I don't like them at all).
Also, there is no proof that Genghis Khan actually asked Isaac to write this function. I must have written this article while dreaming.
## The actual end
May the force of the snaky language dwell richly in your soul and may you find what is that good, pleasing and perfect will of The One Above All.