Related Entries

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

« Reality gone nuts
» Confidential Python?

Prefixing variables with datatypes

c.l.python discusses the merits and demerits of this naming scheme.

Thomas Weholt asked in Python newsgroup:

My firm has a coding-standard where we prefix all variables with a single character to indicate datatype; strings are prefixed with s, integers with i, floats with f etc.

Are there any standards like this for Python? Or hints, tips, opinions related to this topic? I do believe it could make source more understandable and easier to debug/maintain when used in larger projects.

A pretty long thread. But very interesting. Personally, I don’t like prefixing data types or mixed casing variable names.

Plain old C style of all lower case, underscore to indicate boundaries works best for me.

Guido’s essay on Python style guide is a good read. ANAG has a document on their coding standards.

  1. The reason I don't like the idea of prefixing datatypes in Python is that the variables in python aren't bound to datatype. Therefore, regardless of the notation, the variable could be assigned to any datatype.
    ex: inum = 'crazy'

    Posted by: Zope Boy on January 20, 2003 03:21 PM
//-->