I want to learn Python

This is one of the most common questions I get asked by people who are just starting out with Python. If you have no prior programming experience, how Do you start? Valid question. Let’s take it step by step. Most guides start with understanding the syntax of Python, the basic data types, control structures etc. Which is all well and good but I think the first thing you should do is to install Python on your system. ...

January 11, 2025 · 1 min · Abhiram R

import re

I was writing some tests for work today and I accidentally ended up using the re.match() function instead of re.search() function and I thought I’d write that as today’s mini-TIL. In a nutshell, re.match() checks for a match only at the beginning of the string, whereas re.search() checks for a match anywhere in the string. Here’s a quick example to illustrate the difference: import re string = "Was it a car or a cat I saw?" string2 = "Severus was impressed at Harry's Occlumency skills but he did not show it." # re.match() will return None print(re.match("cat", string)) # re.search() will return a match object print(re.search("cat", string)) # re.match() will return a match object print(re.match("Severus", string2)) # re.search() will return a match object print(re.search("Severus", string2)) Output - ...

January 11, 2025 · 2 min · Abhiram R

FrozenLists

I happened to see this package - FrozenList - get installed when i was installing a set of requirements for an environment for work. I’ve not yet dived deep into which package frozenlist was a dependency for. But I still wanted to see what it was and Googled it. Turns out it’s a package created to create a new data structure which is, well, a list that can be frozen. ...

January 7, 2025 · 2 min · Abhiram R

I want to run LLM Models locally. What do I do?

One of the most sought after things to learn right now is about how to set up your own local LLM server and how to use LLM models locally. With the arrival of some things like Ollama and LM Studio etc, it has become very easy. Ollama is an orchestrator that lets you serve up models locally, models like Llama 3.1, Qwen-2.5, Phi, whatever models you have on HuggingFace. These are available to be served up and many more. ...

January 3, 2025 · 3 min · Abhiram R

The Apache Airflow piece

Yesterday I learnt how to get Google News articles using Python - [[Read GoogleNews using Python]] The next piece I need for my planned workflow is running Airflow - locally - at first. Airflow is a platform for scheduling and executing workflows. To give an example, suppose I run a restaurant. If it’s not doing very well, you don’t really need a workflow, so one way to reduce work is to be unsuccessful 😀👀 But if I run it successfully and get a lot of orders on a daily basis, I would like to have a mechanism to process everything. Let’s say I have the following steps to be done - ...

November 23, 2024 · 2 min · Abhiram R

GoogleNews using Python

This article is part of something I’m building up to I wanted to find a way in which I can get news off of Google News programatically and something that doesn’t need to me be authenticated for it. I wondered if I should build a scraper for it, but thankfully, there’s a Python package already that does it - GoogleNews on Pypi I installed it in a new uv virtual environment using pip install googlenews and it was pretty easy to use . ...

November 22, 2024 · 2 min · Abhiram R

List comprehension tuples and obj equals

2 Quick TILs today - You cannot use a tuple in a list comprehension without params - The correct syntax is [(i,j) for i in a for j in b The usage of obj= within a formatted string during printing results in both the object’s name as well its value separated by an “=” being printed - In the imge below, a is a list as used earlier. Therefore - ...

November 21, 2024 · 1 min · Abhiram R

Timeline charts

I’m not feeling all too well but I didn’t want to break my streak of writing. So today I’m writing about a non-Python related topic - Timeline Charts. I was doing a profiling activity for work and I was scratching my head for a way to represent the info so as to explain it easily. Then I got to thinking, how does Google build all those charts to track page loads and API runtimes in Developer tools? ...

November 20, 2024 · 2 min · Abhiram R

Dataclasses

19th Nov 2024 I was trying to write an article on Dataclasses1 and I looked up an example on the official website2 Easy enough on the face of it, but it led me into quite a rabbit hole. A dataclass allows for the creation of “special methods” for a class when the annotation @dataclass is sighted. So if I have a class “Superhero” with the annotation : @dataclass class Superhero: """ A class of superheroes and properties about their appearance in Marvel movies """ name: str superpower: str appearances: int = 0 def beckon(self): print(f"{self.name} with the super power - {self.superpower} has appeared in Marvel movies {self.appearances} times") superhero = Superhero("Aquaman","Underwater breathing",2) superhero.beckon() It effectively means that : ...

November 19, 2024 · 3 min · Abhiram R

Class Methods

I was today years old when I learnt about how to use the classmethod decorator in Python. I’ve always thought of a class method as a method in a class - just intuitively. But there’s actually a decorator called “@classmethod”. Imagine you have a class C. A class method in this class would be defined as - class C: @classmethod def cl_method(cls): print(f"I'm in the class method {cls=}") The distinctive marks of a class method are : ...

November 17, 2024 · 3 min · Abhiram R