Join strings - very simple Q.

John Machin sjmachin at lexicon.net
Sat Mar 24 17:48:16 EDT 2007


On Mar 25, 12:32 am, Paulo da Silva <psdasil... at esotericaX.ptX> wrote:
> John Machin escreveu:
> ..
>
>
>
> > Python 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on
> > win32
> > Type "help", "copyright", "credits" or "license" for more information.
> > | >>> help("".join)
> > Help on built-in function join:
>
> > join(...)
> >     S.join(sequence) -> string
>
> >     Return a string which is the concatenation of the strings in the
> >     sequence.  The separator between elements is S.
>
> > | >>>
>
> > OK, I'll bite: This was "new" in late 2000 when Python 2.0 was
> > released. Where have you been in the last ~6.5 years?
>
> In a response to one of my posts I was told 'string' is
> obsolet. 'string' was enough for me, but if it is obsolet
> then there should be a *new* way, isn't it? The *new*
> way I was told to use is "str methods".
> I tried that *new* way to do *old* 'string' job.

So much was obvious from your post.

> Voila
> the reason of my so pertinent question.

What was not obvious was (1) if you have been using Python for a
while, how you managed to be unaware of str methods (2) if you are a
newbie, how you managed to find out about the string module but not
find out about str methods [e.g. it's easy to miss the one line in the
"official" Python tutorial that refers to them] (3) why you were not
using obvious(?) methods to find out for yourself -- much faster than
posing a question on the newsgroup, and you don't have to face the
possibility of an impertinent response :-)

> I am deeply sorry to have disturbed you in your python's heaven.

I wasn't disturbed at all (you would have to try much harder), only
mildly curious.

>
> Next time I'll read all books available, all texts including
> the python formal description before
> posting,

A rather strange way of finding an answer to a simple question. A
focussed search (or an index!) is more appropriate. Why would you
expect the python formal description to have details on the syntax of
individual class methods? Do you always do a serial scan of all tables
for any database query? In addition to approaches I mentioned earlier,
you could try:

(1) going to the docs page on the Python website (http://
www.python.org/doc/), click on the "Search" link about one-third down
the page, and search for "join". You would get 6 results, one of which
is "join() (string method)"

(2) If you are using Windows, use the index tab in the Python-supplied
docs gadget: type in "join" and get the same 6 results. I believe this
facility is available (through a 3rd party) on Linux. [Having the docs
on your PC or USB storage device is very useful if you are working in
an environment where access to the Internet is restricted].

(3) Use Google groups, go to comp.lang.python, type "join string" into
the search box, and click on "Search this group". First result is the
current thread; most (or maybe all) of the next six or so will give
you the syntax your were looking for.

(4) Using Google or any other reasonable web searcher, search for the
3 words: Python join string. Any one of the first few hits gives the
answer you were seeking.

HTH,
John




More information about the Python-list mailing list