krish – 起死回生 [Wake up from death & return to life.]

December 4, 2008

Document your python functions

Filed under: Programming — krish @ 12:19 am
Tags: , ,

Many people tend to ignore commenting and documenting the code they write. The small amounts of invested time can make life ease for others; especially if you are a crappy coder like me! 🙂

In python, to document your functions, give it a doc string. Doc strings are the first triple quoted string you’d want in a function.

test.py

def mySmallFunction(myParams):
      """ Does nothing. Just a time consuming run. """
      return ";)"

if __name__ == "__main__":
     myParams = {"test.py":"dummy"}
     print mySmallFunction(myParams)

In the python interpreter, doc strings can be accessed by calling attribute __doc___

>>> import test
>>> test.mySmallFunction.__doc__
' Does nothing. Just a time consuming run. '

Advertisements

December 30, 2007

ah python!

Filed under: Programming — krish @ 11:26 am
Tags: ,

I’ve been writing few newbie programs in python since yesterday. 😉
My ISP’s DNS was not looking up for python.org and I had to spend few extra minutes getting the IP and accessing the ftp docs. (thanks to friends at #python @ freenode)

Few good things for me with this snake, er.. language/interpreter
1. No delimiter ( I have a bad habit of forgetting ; in my C, C++, perl, php code )
2. No angular brackets for condition statements
3. Free form language ( first encountered this in perl )

Most of the times, I am finding myself tempted to compare python code with perl; hopefully I shall get over it with time.

Talking about time, I just remembered – its time for LUG meet and I need to hurry! 😛

Create a free website or blog at WordPress.com.

The Male Factor (TMF)

Serving the MANkind for years

Rough Draft

by Atteris Amarth and Darrek Ringo

The Kochi Post.

Read by all + Influenced by none

JumboMake

A signature of Kiran

SAAYAM CHEDDAM FOUNDATION

This blog is just for additional and extension share of it's main frames. No activity is planned from here

krish - 起死回生 [Wake up from death & return to life.]

Get a sneak peek into krish's life, work and passion.

WordPress.com

WordPress.com is the best place for your personal blog or business site.

A Tale of Two and a Half

Monika Amita Bakshi

%d bloggers like this: