[Python-ideas] reusing realpath()

Nick Coghlan ncoghlan at gmail.com
Sun Sep 26 10:17:49 CEST 2010

On Sun, Sep 26, 2010 at 9:02 AM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Antoine Pitrou wrote:
>> So what? The behaviour of fetching the canonical name can be added to
>> the behaviour of resolving symlinks.
> Finding the actual name (I wouldn't call it "canonical",
> since that term could be ambiguous) requires reading the
> contents of entire directories at each step, which could
> be noticeably less efficient than what realpath() currently
> does. Users who only want symlinks expanded might object
> to that.
> An option could be added to realpath(), but then we're
> into constant-parameter territory.

Constant parameter territory isn't *necessarily* a bad thing if the
number of parameters is sufficiently high. In particular, if you have
one basic command (say, "give me the canonical path for this
possibly-non-canonical path I already have") with a gazillion
different variants (*ahem*), then a single function with well-named
boolean parameters (to explain "this is what I really mean by
'canonical path'") is likely to be much easier for people to remember
than trying to create a concise-yet-meaningful mnemonic for each

So we shouldn't dismiss out of hand the idea of a keyword-only
"swiss-army" path normalisation function that can at least be queried
via help() if you forget the exact spelling for the various


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list