Date: Mon, 27 Mar 2006 10:28:30 -0800
From: Martin Kelly <[EMAIL PROTECTED]>
...>
I will join the python group... I didn't know it existed :).

  GOOD!

As others already commented on strategy I'm just adding some peripheral remarks.

a) You can make the 'sha-bang' line more general:
 #!/usr/bin/env python

b) When working on the file system you often want selectively control if your operation in/excludes directories (or topectories :-) and symlinks.
python comes with functions that are at your fingertips if you say:
 from os.path import isfile, isdir, islink

c) One of the many nice features of python are comments/string definitions using triple quotes, single or double. So you could say:
usage = """
Usage: To replace all of "foo" with "bar" in /home:
       rename /home foo bar
       more stuff goes here..."""
Then you don't have to escape the "quotes"; can modify more easily, or add the % string formatters, and so forth... None of that may be needed for that specific usage message -- but I encourage you to look into triple quote definitions for future apps.

d) Naming your identifiers:
Naming a fileName 'file' is generally not a good idea: 'file' is a function of the ever present "module" __builtins__ (actually more like a constructor of an I/O handle). It replaced the more procedural sounding 'open' in version 2.2, about 3 years ago (if I remember correctly).
By doing so you are overriding the builtins function.
There are about two dozen, intuitive sounding identifiers, that collide with __builtins__ , you want to stay clear off, like list, dict, map, min, max,... To see those from within the interactive interpreter just say:
 >>> dir(__builtins__)

Above doesn't hurt in your code as is, but on the long run it may bite you, and your example also indicates you appreciate clean coding style:-)
 (unintentionally(!) rebinding builtins functions simply isn't)

I hope I didn't sound too critical, those are just comments/suggestions.
Welcome to the 'python club'..................Horst

_______________________________________________
EUGLUG mailing list
[email protected]
http://www.euglug.org/mailman/listinfo/euglug

Reply via email to