yuval.guide
In this basic post we'll explain the basics of iterators. A Python Iterator If a python object contains some collection of objects, we need a way to get these object, one at a time. Note that: A specific order is optional, but we must make sure that: ..we get each object ONCE, and.. ..eventually we get ALL objects. …
Read MoreWe have covered default values for parameters during our discussion of function parameters . We now want to explain some more details about that. Python IS dynamic If you are coming from static programming languages (C, C++, Java, C#, Rust, Golang etc..) then you should remind yourself that in python EVERYTHING happens …
Read MoreIn 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 MorePython Basics Creating Python virtual environments with Python venv Values and Vars Python builtin Types bytes Python Functions function parameters function parameters default values function decorators basics function decorators with parameters Python Object Oriented Iterators Generators 1 Python I/O open function …
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 More