Siv Scripts

Solving Problems Using Code

Mon 27 January 2020

Managing Python dependencies with pip-tools and requirements.txt

Posted by Aly Sivji in Quick Hits   

The paradox of choice in Python packaging tools makes dependency management more complex than it needs to be. In this Quick Hit, we will explore Python dependency management and demonstrate an easy-to-implement workflow to generate reproducible environments.

Note: this article assumes familiarity with virtual environments.


We use dependency management …


Wed 21 November 2018

Patching Import Inside Function

Posted by Aly Sivji in Quick Hits   

I started my first tech job at a large corporation. We have lots of internal tools and systems that allow us to solve large-scale data problems. It's been an interesting change from startup life where platforms weren't as mature, where systems weren't as integrated into workflows and processes.

While I'm …


Sun 21 October 2018

Testing 101: Introduction to Testing

Posted by Aly Sivji in Deep Dives   

Programming is writing code to solve problems. Software Engineering is the practice of using a structured process to solve problems. As engineers, we want to have a codebase we can change, extend, and refactor as required. Tests ensure our program works as intended and that changes to the codebase do …


Fri 05 January 2018

@ Python's Matrix Multiplication Operator

Posted by Aly Sivji in Quick Hits   

2017 will forever be etched in our memories as the year Python overtook R to become the leading language for Data Science. There are many factors that play into this: Python's simple syntax, the fantastic PyData ecosystem, and of course buy-in from Python's BDFL.

PEP 465 introduced the @ infix operator that is designated to be used for matrix multiplication. The acceptance and implementation of this proposal in Python 3.5 was a signal to the scientific community that Python is taking its role as a numerical computation language very seriously.


Mon 01 January 2018

Increasing namedtuple Readability with Type Hints

Posted by Aly Sivji in Quick Hits   

Dynamic typing refers to programs checking variable types at runtime versus compile time. By not having to define the variable type as we write code, we can work faster and take advantage of duck typing.

On the other hand, we do miss out on some benefits that types bring. Similiar to how the principles of test-driven development force us to write smaller, more testable functions, thinking about types improves software design by making us cognizant of the values our variables hold as well as the values our functions can return.


Sat 09 September 2017

Visualizing Stacks

Posted by Aly Sivji in Quick Hits   

A stack is a linear data structure that holds a collection of items. We can define operations performed in a stack from the point of view of a user:

  • .push() - add item to top
  • .pop() - remove and return item from top
  • .peek() - return top most element
  • .is_empty() - True if stack …


Wed 17 May 2017

A Gentle Introduction to Context Managers: The Pythonic Way of Managing Resources

Posted by Aly Sivji in Tutorials   


  • Explore with statements and the context manager protocol
  • Implement context manager class to query MongoDB
  • Convert try...finally block to with block and increase code readability

I recently read Steve McConnell's Code Complete to level up my software development skill-set. The book has helped me become more deliberate about programming and problem solving in general. Before I sit down to write a single line of code, I take some time to plan out the work I am going to do versus code by the seat of my pants