"Steve Nelson" <[EMAIL PROTECTED]> wrote 

> def getSize(fn):
>  """Get the size of a file in kb"""
>  fp = os.path.join(wp, fn)
>  if os.path.isfile(fp):
>    return os.stat(fp).st_size

One problem with all of these is that you only return 
a value if it is a file. If its not a file you return None
(the default return value). It would be easier to maintain 
if you make the return explicit.

Personally I would probably raise an exception 
(maybe a TypeError) if it's not a file. That puts the onus 
on the client to check that they pass something that 
you can get the size of - or use a try/except to catch 
the invalid entries..

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to