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

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

Varghese Chacko 1 year, 2 months 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, 2 months 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, 3 months 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, 3 months 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, 3 months 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 Student.pm. If it shouldbe called Bright::Student, it should be saved asBright/Student.pm, ie Student.pm 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, 3 months 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, 3 months 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, 3 months 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.

Python sort arrays with sorted method

Varghese Chacko 1 year, 3 months ago

Python provides a method sorted which returns the sorted array and will not change the original array, where as list.sort() with change the array in place.