Coding standard: Prefixing variables to indicate datatype
root at silmarill.org
root at silmarill.org
Fri Jan 17 22:54:17 EST 2003
In article <tlSdnV4T_spIoLWjXTWcqg at comcast.com>, Terry Reedy wrote:
>
> "Simon Burton" <simonb at webone.com.au> wrote in message
>> And he said:
>> "Empty string, exercise your ability to join this list."
>
> These statements are misleading. The argument to .join can be *any*
> sequence of strings or iterable that produces such. Strings
> themselves, tuples (of strings),
> iterators (that yield strings), string-keyed dicts(!), etc; not just
> lists.
>
>>>> '.'.join(('1','2','3'))
> '1.2.3'
>>>> '.'.join('abc')
> 'a.b.c'
>>>> from __future__ import generators
>>>> def g():
> ... for i in range(5): yield str(i)
> ...
>>>> '.'.join(g())
> '0.1.2.3.4'
>>>> '.'.join({'a':1,'b':2})
> 'a.b'
>
>
> On the other hand, join only applies to lists of *strings* and not
> lists (or sequences) in general.
>
>> Ya, not obvious,
>
> Once you actually think about it, its obvious that attaching the join
> method to the joiner is the only sensible place to put it.
What's insensible about using string.join?
>
> "Carpenter, exercise your ability to joins these pieces of wood."
Ability to glue them with your own body multiplied!
>
> Terry J. Reedy
>
>
More information about the Python-list
mailing list