Skip to main content

Posts about python (old posts, page 4)

#100DaysOfCode, Days 002 & 003 – Dates & Times

Worked an hour for the past two days, exerting all of my python knowledge at the small project they gave me.
Try as I might, I could not do it.
So looked at the solution.
And realised, while it was all logical, I couldn’t for the life of me have written that code on my own.
Long way to travel.
Lots of work to do.


#100DaysOfCode, Day 001 – Dates & Times

Watched videos for the tiny projects to do over the next two days.

We begin with a date/time project.
Python has objects (primitives) to deal with dates and times.
They are part of the datetime module, which is part of the Python Standard Library.

I learnt that I could add and subtract and otherwise modify dates, easily if my date data was in this format.

Will play more with this tomorrow.

100 Days of Code, Again

Ok, the last time I tried this, life got in my way.
Second time lucky?

Last time, I crashed and burned.
So, to quote Rascal Flatts,

On your knees you look up
Decide you've had enough
You get mad, you get strong
Wipe your hands, shake it off
Then you stand.

Every time you get up
And get back in the race
One more small piece of you
Starts to fall into place.

So, 100 Days of Code, #100DaysOfCode?
Look here for the philosophy and the tactics (pretty simple, really.)
And then I’m using Talk Python’s course to actually learn Python.
33 odd little projects over a 100 days.

Here I go …


Multiple Slugs for Multiple Webpages in Nikola

Here’s a delightful little thing I discovered, using Nikola today.

As part of a little housecleaning, I wanted to have a single page have two web urls.
As in Books I’ve Read and Books in 2020.
Don’t ask why, my nerdy brain just wants it that way.

And I was thinking of Nginx redirects and other things I could try.
Until I looked up and saw the slug section in the metadata section of my post (the section that I normally turn a blind eye to).
This is what I assume, Nikola uses to generate links.
And I thought hmm, what if?
And at the same time I remembered what Roberto Alsina, the original author of Nikola had encouraged me to do, when I had just started using it to blog.
That he wrote Nikola, so that it would mostly do the logical thing; that I wouldn’t really need to use the documentation (excellent as it is)

So that is what I did then. I put in two slugs each with the unique url I wanted, and sure enough, Nikola generated two web pages from that single source file.

It’s the little things like this, that make me so happy, I use Nikola for my writing.


Learning Python

Did I need to read a fifteen hundred page book to learn Python?
At the end of fourteen hundred pages, I can safely assure you, I did not.

If you want to just solve your pressing issues or scratch your itch, or just plain get started with programming (and programming in Python specifically), I’d recommend starting with a simple, fast paced book, like Python for you and me, and then doing tons of practice.1

Mark Lutz, as he closes the book, himself laments that Python has gotten too big to hold in your head. And by doing so, has lost some of the simplicity and the joy and fun and the magic, Python held for the early adopters of the language.

And yet, having said all this, boy, am I glad, I read the book.

This is a master class from a master.

I may not have understood everything. I may have skimmed a chapter or two (Lutz assures me, it’s ok :P), but what this book has done to my mind, the furrows it has ploughed, will be with me forever.

I have been trying to get into the book, multiple times since I bought it.
It took me a long time, before, as Mortimer Adler puts it, I could come to terms with the author.
The only reason I kept coming back, was because, Mark’s earnest teaching voice shines through, and I loved it, even if I did not quite get what he was saying in the beginning.
And the reason I could get through it (and enjoy it) this time, because I decided to follow his advice and follow along on the computer.
To actually type in the code, and see what happens.

Yes, the book is big, yes, the concepts are repeated a couple of times, but as I progressed, I could feel him sweating the small stuff over and over, just so that I could understand things, so that I would not get scared away.

Time and again, the book reassured me, that what was said, was not as complicated or hard as it read on the page.
And that turned out to be true as I kept trying the examples out.

While I still have a long way to go, before I can remotely be called fluent, I know this book will have a been a big reason, I will be.2

This book was last updated, oh, some six years ago, and yet unless Python decides to change radically, I dare say, the principles in here will stand the test of time.

This was a great read and will serve as an awesome reference on my Python journey.
If you are slightly kooky like me, and you want to know, why things are the way they are as you learn to program in Python, get this book.


  1. Which is actually, what I am doing. 

  2. Besides the practice, that is. 

Generating Markdown from HTML

2019-08-21

Started with the problem,
Need to take in an md file and then generate an html file.

Hint given, use a package from PyPI.

Decided to use the Markdown package from PyPI.
Looks good to me.

Was advised to work off a branch while developing.
Thank God for friends who teach you good habits.
Looking up how to do that in git now.

Watched Git videos for about an hour.
Learnt lots about branches. Giving up for today. it’s 8 in the eve and i am tired.

2019-08-22

Captain’s Log, Stardate something, something :P
Let’s see what the day holds.

  • Figured out how to read in a file.
  • Figured out how to convert it.
  • Figured out how to write to a file safely.
  • Now gotta figure out how to write the same file name as the one i feed it.
  • 11:44:24, went on a little rabbit hunt for how to type times in here :)
  • 11:45:21, first time ever, that I’ve hit a flow state, doing Python
  • 12:18:03, got it working, yea baby!
  • 12:40:55, Kushal suggested corrections and improvements. getting to work on those later.

2018-08-23

Captain’s Log, stardate, weekend on terra begins XD

  • 09:04, beginning with Kushal’s suggestions
  • 09:38, beginning now. :) had a power cut
    End day. Nothing done.