people package

Submodules

people.Human module

class people.Human.Human(name: <module 'string' from '/home/docs/.pyenv/versions/3.7.3/lib/python3.7/string.py'>, age: int)

Bases: object

class defining an human: name, age,…

initialize a human

Parameters:
  • name (str) – human name
  • age (int) – human age
change_age(age: int)

change the age of the human

Parameters:age (int) – human age
Returns:None

people.ListOfHumans module

class people.ListOfHumans.ListOfHumans(human_to_add: people.Human.Human = None, input_file: <module 'string' from '/home/docs/.pyenv/versions/3.7.3/lib/python3.7/string.py'> = None)

Bases: object

manage a list of humans

initialize the list of humans, possibly with a human given as parameter

Parameters:
  • human_to_add (Human) – human as first item to add
  • input_file (String) – json file with name:age values
add_human(human: people.Human.Human)

add a human in the list

Parameters:human (Human) – new human to be added in the list
get_average_age() → float

calculate the average of the age of all the humans

Note: empty list is not considered…

Returns:average of the age of all the humans
Return type:float
get_names_and_ages() → str

return a ist of names and ages separated with commas

Parameters:None
Returns:list of names and ages separated with self.separator_output (default is ‘,’)
Return type:str
initialize_people_from_input_file(input_file: <module 'string' from '/home/docs/.pyenv/versions/3.7.3/lib/python3.7/string.py'>)

read a Json file and fill the people container

Parameters:

input_file (string) –

Raises:
  • Quit the app if the file does not exist
  • TODO – implement exception instead quitting app

people.people_cli module

people.people_cli.add_subcommand_add_people_from_file(subparsers)
people.people_cli.add_subcommand_init_people(subparsers)
people.people_cli.initialize_people_from_fake_values(args) → people.ListOfHumans.ListOfHumans

initialize a list of humans in the people container with fake hard values

Parameters:args – command line input arguments
Returns:people with added items
Return type:ListOfHumans
people.people_cli.initialize_people_from_file(args) → people.ListOfHumans.ListOfHumans

initialize a list of humans in the people container with fake hard values in a input json file

Parameters:args – command line input arguments containing args.input_file = Json input file
Returns:people with added items
Return type:ListOfHumans
people.people_cli.main()

Module contents