Introspecting Python Functions

Functions are objects Since everything in Python is an object so are functions. They are instances of class <class 'function'> and have properties and methods attached to them. Let’s define a simple function and play with its properties: 1 2 3 4 5 6 7 8 >>> def square(x:int = 0) -> int: return x**2 ... >>> dir(square) ['__annotations__', '__builtins__', '__call__', '__class__', '__closure__', '__code__', '__defaults__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__globals__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__kwdefaults__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__'] >>> square.

Python 3 Text Encoding

Why do we need text encoding? Humans understand text, computers understand binary. Encoding is the process of converting human readable text into sequences of bytes and decoding is the reverse of that. Schemes to map characters to numbers (character codes) To store, transmit and process characters digitally, the characters are mapped to integers, called code points. ASCII is one such scheme. In ASCII, each character is represented by a number from 0 to 127.

Setting Up Hugo

Installing and using Hugo Hugo is a static site generator tool built with the Go language. I was just reading some random blog and at the bottom of their page found built with Hugo thing. After checking it I decided to give it a try, not knowing that I already have a gh pages hosted blog using Jekyll, which I never used after the first time. Here’s how to use Hugo to generate a static site and then host it on Github pages: