Related Entries

India PyCon 2009
Quick wallpaper changer
Load testing with Grinder
Adding namespace to XML
Opera RSS to OPML

« A stylesheet for O'Reilly authors
» Perl to Python: 20 stages

Joy of Python: Setting Goals

Another heavily commented python script to help you set your goals.

Another one of those 5 minute Python scripts. This one might come in handy during your year-end review.

"""
This is a  little script to help you write your yearly goals.
For a dart board that does the same thing, please see
http://www-106.ibm.com/developerworks/library/lol/goals/?loc=dwmain

S Babu:
joys of python: is a series of small and often silly scripts using
python that does something while explaining some nice features of
python. Absolutely newbie material.

http://vsbabu.org/mt/archives/categories/python/

All small values of joy are marked by comments starting with #joy:
"""
#joy: no more separate comment block. Triple quoted starting comment
#     is python’s documentation string. You can access it as __doc__

#let us define some verbs
verbs = [
    "impact",
    "architect",
    "generate",
    "clearly establish",
    "accurately assess",
    "effectively document",
    "display positive",
    "demonstrate",
    "recognize",
    "customize",
    "maximize",
    "improve",
    "develop",
    "utilize",
    "explore",
    ]

#joy: did you see the trailing comma on the last element? Makes
#     copy-paste of code so much more easier. Most older languages
#     don’t permit having a comma on the last element.

#let us define some nouns
nouns =  [
    "outside-the-box-thinking",
    "business process innovation",
    "communication skills",
    "goal achievement",
    "user satisfaction",
    "leadership ability",
    "customer retention",
    "collaboration",
    "exprense reduction",
    "responsibilities",
    "business paradigm",
    "reliability",
    "solutions",
    "ROI",
    "value add",
    ]

#joy: trailing comma for the last element.

#first let us import "choice" function from whrandom module.
#choice(list) will return a random element from the list.

#joy: you don’t have to import the whole module, just the required
#     function.
from whrandom import choice


#let us prepare the user!
# \n will print an EXTRA new line. print statement puts a new line
# by default. You can turn that off by adding a comma towards the end
# like print "my statement",
print "Goals for your next year!\n"

#simple loop. range(1,11) will return a list like [1, 2, ..., 10]
for i in range(1,11):
    v = choice(verbs) #pick a random verb

    n = choice(nouns) #pick a random noun
    #let us make sure we don’t use this noun again
    nouns.remove(n)
    #and our goal is verb + noun. We put a tab by using "\t"
    print "\t", i, v, n


#joy: I want to print a 80 character line using minus sign
#     Type - 80 times? Nah!
print 80*'-'

#joy: now shall we print what this script does?
#     easy!
print __doc__

Sample output

Goals for your next year!

	1 customize business paradigm
	2 customize exprense reduction
	3 develop leadership ability
	4 effectively document reliability
	5 demonstrate goal achievement
	6 customize ROI
	7 utilize value add
	8 develop outside-the-box-thinking
	9 explore collaboration
	10 clearly establish responsibilities
--------------------------------------------------------------------------------

This is a great little script to help you write your yearly goals.
For a dart board that does the same thing, please see
http://www-106.ibm.com/developerworks/library/lol/goals/?loc=dwmain

S Babu:
joys of python: is a series of small and often silly scripts using
python that does something while explaining some nice features of
python. Absolutely newbie material.

http://vsbabu.org/mt/archives/categories/python/

All small values of joy are marked by comments starting with #joy:
  1. hi again, have ever been through everything2.com, if you haven't its highly recommended. The reason i posted this comment is they have a very unique system of linking within their own site and i was wondering wether i could do the same.

    I do not have knowledge of code, but am willing to negotiate a very small [:)the time constraint being more than the intent]learning curve. IS it possible to have sucha system incorporated into a personal site??

    Posted by: Sachin nair on August 20, 2002 11:24 AM