[Python-Dev] Re: PEP 292 - Simpler String Substitutions (original) (raw)
Michael Chermside mcherm at mcherm.com
Mon Aug 23 19:04:55 CEST 2004
- Previous message: [Python-Dev] Re: Weekly Python Bug/Patch Summary
- Next message: [Python-Dev] Weekly Python Bug/Patch Summary
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Tim Peters writes:
The same applies to string.join(iterable), for that matter.
Clark Evans writes:
This code-snippet is littered everwhere in my applications:
string.join([str(x) for x in iterable]) Its tedious and makes code hard to read. Do we need a PEP to fix this?
I'm convinced! Of course any code like the following would break:
class Item: # ... def eq(self, other): "All Items are equal!" return isinstance(other, Item)
def process_item(item): """Processes an item, returning a string.""" # ...
def process_items(items): """This processes each Item in the list and returns a string containing the entire thing.""" while True: try: return ','.join(items) except TypeError: pos = items.index(Item()) # find first Item items[pos] = process_item( items[pos] ) continue
Seriously, I can't think of a sane use for .join() raising a TypeError, so I'd say run it by Guido and if it doesn't offend his design intuition, let's fix it!
-- Michael Chermside
- Previous message: [Python-Dev] Re: Weekly Python Bug/Patch Summary
- Next message: [Python-Dev] Weekly Python Bug/Patch Summary
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]