A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-December/084616.html below:

[Python-Dev] A wart which should have been repaired in 3.0?

[Python-Dev] A wart which should have been repaired in 3.0? [Python-Dev] A wart which should have been repaired in 3.0?Nick Coghlan ncoghlan at gmail.com
Sat Dec 27 21:44:00 CET 2008
Antoine Pitrou wrote:
> <skip <at> pobox.com> writes:
>> If we add commonpath or commonpathprefix or pathprefix, or whatever, then
>> find someplace to move the existing commonprefix function (maybe to the
>> string module or as a class method of string objects?) then could we make a
>> 2to3 fixer for this?
> 
> IMHO it's a bug, the py3k migration process needn't apply.

The current behaviour is exactly what one would need to implement
bash-style tab completion [1], so I don't get why anyone is calling it
"useless" or "obviously broken". It's brokenness isn't obvious at all to
me - it just doesn't do what you want it to do.

Adding a separate function called "os.path.commonpath" with the
behaviour Skip wants sounds like *exactly* the right answer to me.

Cheers,
Nick.

*

entries = os.listdir()
candidates = [e for e in entries if e.startswith(typed)]
if len(candidates) > 1:
  tab_result = os.path.commonprefix(entries)
elif candidates:
  tab_result = candidates[0]
else:
  tab_result = typed


-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4