Software engineering facts, information, and skills categorized as Programming Languages

Python 3 - Django: ImportError: No module named 'django.core.urlresolvers'

Varghese Chacko 1 year ago

Python 3 - Django 2.x: ImportError: No module named 'django.core.urlresolvers' is a common error we get when we migrate from python 2.x to python 3.x and use latest Django > 2.0. the common error message looks like 

What is @permalink and get_absolute_url in Django?

Varghese Chacko 1 year, 1 month ago

What is @permalink and get_absolute_url in Django? When and why to use it?

Get the previous months name

Varghese Chacko 1 year, 1 month ago

Often we need to get previous months name in python, especially, when we have to save report from previous month's name. In python its is pretty simple. 

Get month name from month number

Varghese Chacko 1 year, 1 month ago

How can we get the month name from the month number? For instance, if I have 3, I want to return march? Most simple method is to define a function that checks for the number and return name.

Basics of object orientation and inheritance in perl

Varghese Chacko 1 year, 1 month ago

Perl is an object oriented language. Perl has packages(class) that could be instanciated and used. At first, we need to decide the file namefor the package ans the perl class name carries the file name. For example, a package Student should be in the file If it shouldbe called Bright::Student, it should be saved asBright/, ie in a directory named Bright. There is no formal relationship between directory name and modules. That is just grouping for convenience.

Obtaining statistics for Net::FTP transfers

Varghese Chacko 1 year, 1 month ago

With Net:FTP for uplink and downlink file transfers, we may have problems with obtaining the same statistics that are provided by ftp when you perform a manual transfer, i.e file size, transfer duration and transfer speed in KBs. The easiest solution is to print the $ftp->message;  It contain some message. For example,

The New (computer) Testament

Varghese Chacko 1 year, 1 month ago

In 2007, I have translated apoetry about computers and posted on perl monks for fun. Just copy pasting it here, just for fun. 

Python sort list of dict by calculated value

Varghese Chacko 1 year, 1 month ago

We often needto sort a list of dictionaries by calculated value. Python's sorted is very powerful so that it can do literally anything with custom key function Assume that we have a list of 20 students with their name and marks. Wedont have the total of their marksin the list. We want to sort them by rank, ie descending order of total marks.

Search and replace unicode zero width characters <U+200B>

Varghese Chacko 1 year, 1 month ago

When we copy-paste text from applications like MS-Word or similar to our HTML or text files, we end-up having unicode characters in the file, ultimately leading to different issues. Inlinus, itseasy to replace it from all files in current directory. A typical example is the zero width space <U+200B>