Simple steps…but so much fun.

Worked on the application I am building for my day job a little more today. I am finding that I have a lot to learn about basics of python. Particularly working with parsing string data.  So far this project has been a lot of fun because I am learning a lot about strip, split and join string operations. It’s actually pretty mind blowing that I can take a word document and with a few lines of code build a data structure, in this case a dictionary which will likely end up a Json object.  I’m having a great time working with data in this manner and I’m actually considering going through a data science course to pick up some more concepts.

Also, just the prospect of saving myself time in my day job is giving me a lot more ambition.

I am also seeing that I’ve got to adopt more DRY principles in my code, but I’m currently just trying to hack this thing together. I feel like I can refactor the code once I have a working prototype.


Today while working on the flask casts site, I decided it would be a good idea to generate a url slug. This is extremely important for search engine optimization. I thought about writing my own class to do this, then thought it might get ugly…so I searched for a package. I found Slugify:

Pretty simple to use. When creating the Post object I just modified my __init__ to the following:

    def __init__(self, title, content, author, created=None):
        self.title = title
        self.slug = slugify(title)
        self.content = content = author
        self.created = datetime.datetime.utcnow().strftime('%A %x @ %H:%M:%S') \
            if created is None else created

Now I can pass the slug to a url like:

def post(slug):
    post = Post.get_post(slug)
    author = User.get_user(post['author'])
    return render_template('home/post.html', post=post, author=author['fullname'])

Thanks for reading!