Python

Context Managers In Python

Context managers are inherent feature of python to provide a way to obtain and release resources on demand. When a context manager is used, a definite scope is defined to safely delete or clean resources. For example a file can be read in below two ways. View the code on Gist. In this method, python interpreter has no way to estimate the need for myFile in future. Hence it holds on to the file descriptor Read more…

Travelogue

Tranquil Scottish Highlands

No two journeys are ever same. However few are bit more special, both in magnitude as well as expectations. Our first trip to Highlands certainly fell into this category. I spent weeks planning for this one, from accommodation, to list of places, to routes, to activities, even the vehicle. We started on Saturday with Inverness being our first stop. Although we missed our chance to spot dolphins, we did come across some serene places. Next Read more…

Travelogue

Eerily Beautiful Glasgow Necropolis

After being in Glasgow for about a year, a visit to Central Cathedral and Necropolis was long overdue. This was still one place where I always wanted to take Misbah along, but  never could, due to something or the other. Finally this weekend after being under the weather all night, I lost my senses and dragged her along for a stroll to Glasgow Necropolis in-spite of rains. Luckily sun god showed mercy on us when Read more…

Bonds

Day Count Convention In Bonds

Day-count convention is used to calculate accrued interest between coupon payments. This convention helps to determine the number of days between payment, thus helping with calculation of how interest is accrued over a period. This convention dictates how the period between payments is calculated, by deciding numbers of days in a month and a year for below. Coupon Value Calculation: For sub annual coupon payments, day-count convention are used to calculate fraction of year on Read more…

Python

functools Module In Python

As per python docs “The functools module is for higher-order functions: functions that act on or return other functions.“ Partial Star of functoolsis certainly partial, which provides ability to set a subset of arguments expected by a function. This partially set function can now be passed to the next consumer to provide rest of the arguments and finally invoke the function. Objects returned by partial are instances of Partial, and can further be chained if Read more…