yuval.guide — Guides and hands-on courses on DevOps, cloud, Linux, Python, Kubernetes, networking and AI.
In this example, we create a decorator that will multiply a value returned by a 2 parameters func by a value. What we want to achieve Suppose you have a decorator and a function like the following: 1@mult(5) 2def add_nums(a,b): 3 return a+b The idea is that instead of having add_nums(3,4) return 7, it will return 35. …
Read MoreAbout bytes The python bytes type represents abinary sequence of bytes. I use the term "binary" because it is sometimes displayed as a sequence of characters, but it it not text, not it it a string! bytes is immutable, whereas bytearray is a mutable version of it. representation A bytes object looks like a string, with …
Read MoreThe tasks project Flask is a micro web framework. You can use it to create web sites, but also to create web services, which are programs that communicate over the http protocol. We'll use it here to create a simple web service and api. In our api, we'll send and receive JSON strings to represent tasks Installation …
Read MoreFunction decorators are used in many python packages and libraries. Often, you see the @ sign in code before you learn what it is, so you get back to read about decorators. We'll use a simple example to demonstrate the use of decorators. What do we try to achieve Suppose you have a simple, 2 params function like the …
Read MoreOpen Function Basics The open function documentation contains a lot of parameters The only positional parameter (file) specifies the path of the file to be read.
Read MoreInteractive courses Python Foundations — Python from nothing, in the browser: names and numbers, strings, loops, lists, dictionaries and sets, functions, files and JSON, exceptions, and classes as far as inheritance. Every example runs in the page and every exercise is checked; nothing to install. Python Asyncio — …
Read MoreAbout bash functions Also called Shell Functions Once a function is defined, it is used like a "regular" command Shell functions are executed in the current shell context; no new process is created to interpret them. Function Syntax Functions are declared using this syntax: 1fname () compound-command [ redirections ] 2 …
Read MoreThe basic Truth of Python values and vars All of the values in Python are really objects. You can think of objects as bags that contain the value itself, with some more operations that you can use with the value (these are called methods). We'll talk about object in more details in later posts. Each object (i.e value) …
Read MoreParameters and Arguments Here's a demo of a function definitions and call. (comments tell you where parameters are used, and where arguments are used) 1def twice(num): # num is a parameter 2 print(2 * num) 3 4twice(5) # 5 is an argument 5x = 3 6twice(x) # x is an argument Positional and Keyword Arguments This is a …
Read MoreParameter Store Parameter Store is a feature of the AWS Systems Manager service. It is a centralized store to manage your configuration data, whether plain-text data such as database strings or secrets such as passwords. This allows you to separate your secrets and configuration data from your code. Parameters can be …
Read More