Python Challenge of the Day (2/17/22)

Problem scenario
You have a program as follows:

class Location:
def __init__(self, country=”US”, state=”CA”, city=”Los Angeles”):
self.country = country
self.state = state
self.city = city

def printer(self):
return [self.country, self.state, self.city]

new_loc = Location(“Mexico”, “Mexico City”, “Mexico City”, “good neighborhood”)
print(new_loc.printer())

Here are your choices of what it could print out:

a. TypeError: init() takes from 1 to 4 positional arguments but 5 were given
b.

Is It Possible for an I.T. Staffing Company to Provide Notice that Your Contract Will End?

Problem scenario
A staffing company wants you to agree to give a 15 or 30 day notice before you voluntarily leave. But they have to give you no notice. One attorney said that in that business model, this is common. Another attorney says that it is not unreasonable to ask for this clause to be reciprocal. You do not think that the company will agree to making it reciprocal.

What is a Validation Webhook?

Question
In the context of Kubernetes, what is a validation webhook?

Answer
They are an API invocation to confirm a resource was created properly. Unlike a mutating webhook, validation webhooks make no changes to resources deployed in Kubernetes. Also unlike a mutating webhook, validation webhooks happen at a different step in the admission controller process. The admission controller process starts with an API request and ends with persisting data to etcd.

Do Ordered Dictionaries in Python Consume More Memory than Regular Dictionaries?

Question
You are considered using ordered dictionaries in Python (e.g., because of the way they handle temporal data). Will your program use more memory this way compared to using a regular dictionary?

Answer
Yes. All things being equal, ordered dictionaries use more memory than normal dictionaries.

# You will see that Python 3’s ordered dictionaries consume more memory than regular dictionaries
# This was adapted from https://lerner.co.il/2019/05/12/python-dicts-and-memory-usage/

import sys
from collections import OrderedDict

x = OrderedDict()
y = {}

for i in range(1, …

Amazing Growth for I.T. Jobs in Security

In November of 2017 Continualintegration.com posted What is DevSecOps (or DevOpsSec, SecDevOps, or rugged DevOps)?. At the time, Indeed found 192 jobs with a search for “devsecops”. Today, 2/10/22, in four years and three months later, Indeed returns 19,002 jobs for a search of “devsecops.” There are roughly 100x as many jobs now that include the word “devsecops” on Indeed. The website has grown, but this is still an amazing finding.

How Do You Use gRPC to Learn More about It?

Problem scenario
You want to use gRPC as a proof of concept. What should you do?

Solution
Go here: https://chromium.googlesource.com/external/github.com/grpc/grpc/+/chromium-deps/2016-08-17/examples/python/README.md

You may want to clone this repository:
https://github.com/grpc/grpc

(Look in the directory for the language of your choice; it should have an “examples” directory.)

For using gRPC with Python you can install a certain package;