Python – Pendulum

Working with dates and times in programming can be a painful test at times. In Python, there are some excellent libraries that help with all the pain, and recently I became aware of Pendulum. It is effectively are replacement for the standard datetime class and it has a number of improvements. Check out the documentation for further information.

Installation of the packages is straightforward with pip:

$ pip install pendulum

For example, some simple manipulations involving time zones:

import pendulum

now ='Europe/Paris')

# Changing timezone

# Default support for common datetime formats

# Shifting

Duration can be used as a replacement for the standard timedelta class:

dur = pendulum.duration(days=15)

# More properties

# Handy methods
'2 weeks 1 day'

It also supports the definition of a period, i.e. a duration that is aware of the DateTime instances that created it. For example:

dt1 =
dt2 = dt1.add(days=3)

# A period is the difference between 2 instances
period = dt2 - dt1


# A period is iterable
for dt in period:

Give it a go, and let me know what you think of it. 

Microsoft Office 2010 – issue with opening files as “Read-Only”

Office 2010 logo

This happened to me the other day when trying to open an older(-ish) Excel file created with Office 2003 in the new 2010 version of the software: I double clicked on the file and a message appeared telling me that the file will be opened in read-only mode and that whenever it becomes free then I will be able to edit it. The strange thing is that no one else had the file opened.If you have the same issue with your files, read on.

There seems to be a new feature in the 2010 edition of MS Office called Protected View created to “enhance protection against mail attachments, files originated from the internet and located in unsafe locations”. This sounds great, but the problem is that Protected View will remove support for legacy document formats, and causes these documents to be opened in read-only mode. A solution posted my Microsoft is:

  1. Run the Office 2010 application with the problem. Notice that this procedure has to be done individually with each of the applications in MS Office suite (great!).
  2. Click on the Office button on the upper left-hand corner and select “Options”
  3. In the “Options” dialogue box, select “Trust Center” (on the left)
  4. Click on “Trust Center Settings” (on the right)
  5. Select “Protected View”
  6. Disable any of all the protected view options by unticking the check boxes.
  7. Click OK when done.

Another alternative is to re-save your legacy document. In order to do that do the following:

  1. Open the problematic legacy document
  2. Click File and select Save As
  3. In the dialogue box, on the lower left-hand corner there is a drop-down menu called “Tools”, select “General Options”
  4.  Make sure that the “Read-Only recommended” check box is unticked.
  5. Save the file and hope for the best…

I hope this is useful to you.