Random thoughts about random subjects… From science to literature and between manga and watercolours, passing by data science and rugby; including film, physics and fiction, programming, pictures and puns.
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:
now = pendulum.now('Europe/Paris')
# Changing timezone
# Default support for common datetime formats
Duration can be used as a replacement for the standard timedelta class:
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 = pendulum.now()
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.
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:
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!).
Click on the Office button on the upper left-hand corner and select “Options”
In the “Options” dialogue box, select “Trust Center” (on the left)
Click on “Trust Center Settings” (on the right)
Select “Protected View”
Disable any of all the protected view options by unticking the check boxes.
Click OK when done.
Another alternative is to re-save your legacy document. In order to do that do the following:
Open the problematic legacy document
Click File and select Save As
In the dialogue box, on the lower left-hand corner there is a drop-down menu called “Tools”, select “General Options”
Make sure that the “Read-Only recommended” check box is unticked.
Continuing with the brief introduction to LaTeX that I posted recently, in this video I discuss the use of LaTeX to produce a document that has a structure similar to that of a book for example. The idea is to build a master file that controls the flow of the document and separates each “Chapter” in separate files. This provides the author with a lot of flexibility in terms of organising content and makes large documents far more manageable than when using a single LaTeX file.
Enjoy and any feedback, comments or suggestions are more than welcome.