Site Sponsors:
Passable 'RFC 2822' Localtime in Python 3 
Time ... you would think that it would be easy to express on a computer... What could be more natural than counting the number of seconds?

Yet after decades of computerization, we are still 'haggling over the proper way to express time!

Here is what we cobbled together while creating a client-side API for the new, R&D, AboutTime HTML Server:

import datetime
from email import utils

zdt = # Omits the GMT Offset
zlocal = utils.localtime(zdt) # Adds the official GMT Offset
localtime = utils.format_datetime(zlocal) # RFC 2822-ish

... and here is the output:

/usr/bin/python3.5 .../Python3/AboutTime_API/
2017-12-13 08:02:20.817119
2017-12-13 08:02:20.817119-05:00
Wed, 13 Dec 2017 08:02:20 -0500

Then, as one becomes interested in Zulu / Server Time:

zdt = datetime.datetime.utcnow() # Omits the GMT Offset
zulutime = utils.format_datetime(zdt) # RFC 2822-ish


2017-12-13 13:02:20.817251
Wed, 13 Dec 2017 13:02:20 -0000

Sharing is caring!


Google candy: GMT, UTC, Epoch time, conversion, email, RFC 822

[ add comment ]   |  permalink  |  related link
Stand-up a Basic Web Server ... in 1 Line of Code? 
There I was, starting to spin-up my AWS Server when it occurred to me: Once having resolved to use Python 3 on the back-end, why pay for the spindle-time?!

(Apache NOT Required!)

Indeed, even with a Doctor Quote front-end (written in C/C++, with a new for-discussion strawman written in Java) the basic GET / POST ops provided by Python's http.server are more than adequate for this man's B.E.S.T efforts.

Three Easy Steps

The pathway to one-line server 'nerdvanna be to:

(1) Install Python 3

(2) Create a folder to serve as the "staging area" for your web server effort, complete with a `cgi-bin` sub-directory therein. (Python uses FAST-CGI, so there are no worries there!)

(3) Open a command-line prompt, navigate to said folder, and execute the following:
python3 -m http.server 9000 --cgi --bind
(We use port 9000 for obvious reasons)

Once completed, your basic one-line server will be accepting requests at http://127.0.1:9000 on your computer. To view the same, simply open your browser & navigate to the URL.

Next Steps

The next step would be to create an index.html in the folder, refresh that browser view ... and start developing your very own 'pythonic web application.

Sharing is caring!


p.s. We should note that PHP can also do a similar:
$ cd MyWebFolder
$ php -S
You can CLICK HERE for more info.

[ add comment ] ( 56 views )   |  permalink  |  related link
Collecting Wikiquote Data Using Python 
You've 'gotta love collecting quotes - not only might they teach us, but reviewing quotations revered by others helps us better understand what motivates today's majorities.

Like many others, I also love Python 3. Not only is Python 3 finally ready for prime-time, but - from gainful employment to games - Python's community is simply the most amazing set of programing enthusiasts in our modern world. -If you want to do something, chances are extremely good that someone has a package that can help you do things ALLOT quicker.

So it was with collecting Wikiquotes!

Quotes Matter

I have been collecting quotes since my college days. Indeed, from then to prior to to-date I have amassed a collection of around 100,000.

When it came time to snoop around Wikiquote therefore, how could any 'quotie worthy of the moniker NOT try to collect 'em all, as well?

So as I sat down to "learn something" on this traditional occidental day of rest, I decided to give the wikiquotes package a try.

After pip'ing it down, here is what I came up with:

import wikiquotes

alpha = "abcdefghijklmnopqrstuvwxyz1234567890"
major = 1
minor = 1
with open("./wikiquote_2017_10_22.txt", "w") as results:
for char in alpha:
result =, "english")
zlist = list(result)
for author in zlist:
print(char, major, author)
quotes = wikiquotes.get_quotes(author, "english")
for quote in quotes:
if str(quote).find("proposed by") == 0:
if str(quote).find("(UTC)") != -1:
print("tbd", char, minor, major, author, quote, sep='|', file=results)
minor += 1
major += 1
print("error", char, minor, major, "error", "no quotes", sep='|', file=results)

Using the above, we were able to download 17,068 things to review. The fact that we have an even set of 360 'authors' (10 per) clearly indicates that I did not get 'em all the first time 'round... but I eventually got the vast majority [5,225 topics? 153,621 quotes?] of them... (*)

Quality Comments

Overall, I should note that I was disappointed with the quality of the quotations. While there were some decent citations that I did not have, allot of the jibes seem to be far too fatuous; desperate attempts to garner cheap publicity for far too many unmemorable nouns. More than a few pages have absolutely no quotations on them at-all.

Yet - as mentioned previously - as we 'quoties seek to separate the gold from the gall, over time history has an annoying tendency to insure that only the strong, will survive.

Enjoy the journey!


p.s. If you would like to get the results of today's diversion, we just uploaded them to the Mighty Maxims Project.

(*) In order to keep the server load reasonable for our Wikipedia friends, I will keep THAT bit of code on my own 'local ... still sorting thru them! :)

[ add comment ] ( 53 views )   |  permalink  |  related link

| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Next> Last>>