Coding standard: Prefixing variables to indicate datatype

Simon Burton simonb at
Thu Jan 16 10:42:42 CET 2003

On Thu, 16 Jan 2003 10:28:42 +0100, Thomas Weholt wrote:

> Hm ... I see your point. I began thinking about this when I read some old
> code where a variable changed datatype during its lifespan inside a function
> several times. I think it was passed as a string, turned into a int and
> could be returned from the function as None depending on its content. It was
> awful.

So use a different variable for each incarnation.

Just wrote this:

def capit(s):
  l = s.split("_") # could re-use s here
  l = [ s.capitalize() for s in l ]
  return string.join(l,"")

capit("some_name") returns "SomeName"

Simon Burton.

More information about the Python-list mailing list