A Bit of Sense

Here I talk about my expericne with computers, software and computer programming. Let me warn you that some of this stuff will be technical. I'll aim to give you fair notice for technical posts.

My Photo
Name:
Location: Massachusetts, United States

Thursday, January 26, 2006

Quicker Tag Generation

Quicker Tag Generation

When I was creating the last post I was thinking writing out a long list of tags is a pain in the neck. For one or two tags this is easy especially when I can copy and paste from my previous post. However, when adding more tags then this the process starts to get awkward. I've come up with a quick and dirty solution to this problem. I've used the python programming language to create a very quick 'script' to get the job done.

Here it is:



tags = raw_input("Enter a list of tags separated by commas:"
).split(',')
html = [
'<a href="http://technorati.com/tag/%s" rel="tag">%s</a>'
% (t.strip(), t.strip()) for t in tags]
open('tags.txt', 'w').write(
"<b>Tags:</b> " + ", ".join(html
))


Given a line of text like such as "security,windows,install,software" the script takes this list of tags and adds the HTML tag code around the list. It then saves the list to a file called tags.txt.

Tags: ,

4 Comments:

Blogger Bar L. said...

Sweet. I still need to try this. You know what my problem is? I never know what to tags to use!

February 01, 2006 12:18 AM  
Blogger Bar L. said...

I am lame. I am totally lame. I tried this ten times but it showed up with a bunch of the codes not just the tags. What am I doing wrong? :(

February 07, 2006 9:21 PM  
Blogger Bar L. said...

IT WORKED - you were right about what I was doing wrong.

Anyone who reads this - James is a genius when it comes to explaining technology to people who are not familiar with it.

February 08, 2006 3:59 PM  
Anonymous PayPal online casino said...

This comment has been removed by a blog administrator.

March 28, 2011 9:10 PM  

Post a Comment

<< Home