Skip to main content

Posts about python (old posts, page 3)

#100DaysOfCode, Day 011 – Quick and Dirty Web Page Download

Watched another Corey Schafer video on how to scrape web pages.
Thought that would be handy in my image from a web page download project.
Corey’s an awesome teacher. The video was fun and it taught me lots.

Then started hacking away at my little project.
And then realised that the site has rss feeds.
I could just process them instead of scraping a page.
Went looking for a quick way to do that.
Found the Universal Feed Parser.

Got the rss feed and am now playing with it.
That is all I had time for today.
But I learnt lots.
Will probably get back to the project on Wednesday.

Office beckons for the next two days.
Hope to keep up the streak by doing something productive though.

Today was fun!
Today was also the day, I realised, I actually love coding.
I have no clue how 4 hours passed me by!


#100DaysOfCode, Day 009 – The Collections Module

I cheated and peeked again at the solution :)
After five days, I think I needed help.
But it was still a very good day.
I learned lots.

When I started this little project, I saw videos about defaultdicts and namedtuples and then kinda forgot that they would be of some use to me in my project itself.
That realisation came yesterday.
Like they say, it happened very slowly and then all at once! I wrote up a quick workflow of how the program was supposed to work on paper.
And then I had a decisison to make.
Do I peek at the answer? or not?
In the end, I did.
I wanted confirmation of my thought process, and realised that if I was going to figure out the code itself, this would take much, much longer.
Besides, writing Python will come to me if I stick with this as I have been doing, so no guilt about copying code.

The instructors did solve the problem, exactly the way I envisioned it in my head :)
And the code, to my inexperienced fingers was tricky. (I don’t know lambdas or expressions in general and the instructor uses them liberally; a dictionary expression to populate a dict and a lambda to sort a list)
However I take small comfort in the fact, that I did, write one third of the code all by myself.
Just goes to show, how little fluency I have with the language.

But still! I am happy I got my thinking straight :)
Onwards!

#100DaysOfCode, Day 008 – The Collections Module

Finally feels like something is happening.
Did two hours today.

I don’t know if what I do is cheating, but I darn near print everything to see output and then iterate on the errors.

I understood how to work with csv files and process them and why ordered dictionaries can be useful.
I used that to process my csv file and read and print select fields.

Will work on sorting them somehow and figure out frequency based on ratings tomorrow.

Pleased with myself. Today was a good day!


#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.