Add a filename in the command line when running a Python script

OR: Run a Python script with arguments You can add arguments to the command line when running python scripts by importing the sys module from Python's standard library and using its argv function. Some examples: A simple script that displays the user name: def main(): name = 'Frodo' print(f'Hello, {name}') if __name__ == "__main__": main() … Continue reading Add a filename in the command line when running a Python script

Display nested dictionary content sorted by key in Python

Given a nested dictionary like this: dog_breeds = { 'Labrador Retriever': {'life_span': 14, 'male_weight': '36 Kg', 'female_weight': '32 Kg'}, 'Beagle': {'life_span': 15, 'male_weight': '11 Kg', 'female_weight': '10 Kg'}, 'German Shepherd': {'life_span': 13, 'male_weight': '40 Kg', 'female_weight': '32 Kg'}, 'Jack Russell Terrier': {'life_span': 16, 'male_weight': '8 Kg', 'female_weight': '8 Kg'}, 'Rottweiler': {'life_span': 10, 'male_weight': '60 Kg', … Continue reading Display nested dictionary content sorted by key in Python

Networking for Developers – part 3: Network and Physical layers

NOTE: Catch up with the previous posts in this post series:Part 1: OverviewPart 2: Application and Transport layers In the Internet, the network layer uses the Internet Protocol and it's responsible to analyse the destination address in the packets and direct them to where they should go. The job to actually move the packets around … Continue reading Networking for Developers – part 3: Network and Physical layers