Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Where can I find .join() in the docs

2 views
Skip to first unread message

Ruediger Maehl

unread,
May 30, 2002, 9:05:39 AM5/30/02
to
Hello Pythoneers,

could anyone please point me to the piece of documentation
where I can find a description of .join() and all the others?

Rüdiger


Emile van Sebille

unread,
May 30, 2002, 9:25:52 AM5/30/02
to
"Ruediger Maehl" <ruediger.m...@web.de> wrote in message
news:newscache$0hdxwg$4oi$1...@www-neu.dzsh.de...

> Hello Pythoneers,
>
> could anyone please point me to the piece of documentation
> where I can find a description of .join() and all the others?
>

The dot in dot join indicates that join resides in the thing being
dot'ted, in this case likely string. Look at
Python22\Doc\lib\module-string.html and
Python22\Doc\lib\string-methods.html


--

Emile van Sebille
em...@fenx.com

---------

Duncan Booth

unread,
May 30, 2002, 9:48:20 AM5/30/02
to
"Ruediger Maehl" <ruediger.m...@web.de> wrote in
news:newscache$0hdxwg$4oi$1...@www-neu.dzsh.de:

Read the Python library reference, section 2.2.6.1 'String Methods' and you
will probably find much of the rest of section 2.2 of interest as well.

or (Python 2.2), at the interactive prompt type:

>>> help(str.join)
Help on method_descriptor:

join(...)
S.join(sequence) -> string

Return a string which is the concatenation of the strings in the
sequence. The separator between elements is S.

>>>

help(str) gives you a complete list of all str methods, but includes a lot
of internal stuff you probably don't care about.

--
Duncan Booth dun...@rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?

Attila Horvath

unread,
May 30, 2002, 9:42:43 AM5/30/02
to
See:

http://diveintopython.org/odbchelper_join.html

An EXCELLENT tutorial!

On Thu, 30 May 2002, Ruediger Maehl wrote:

> Date: Thu, 30 May 2002 15:05:39 +0200
> From: Ruediger Maehl <ruediger.m...@web.de>
> To: pytho...@python.org
> Subject: Where can I find .join() in the docs

_
Mutsuura Associates, Inc. /\ \
P.O. Box 1238 / \ \
Vienna, VA 22183 / /\ \ \
/ / /\ \ \
E-MAIL: con...@mutsuura.com / /_/ \ \ \
WEB: http://www.mutsuura.com / \ \ / \ \
/ /\ \ \/ /\ \ \
MAIN:(703)281-9722 / / /\ \/ / /\ \ \
CELL:(703)863-1933 / / / \ / / \ \ \
FAX :(703)281-9744 / / / \/_/ \ \_\
SBA/SDB CERTIFIED \/_/ \/_/

Michael Chermside

unread,
May 30, 2002, 9:50:01 AM5/30/02
to
This page:
http://www.python.org/doc/current/lib/string-methods.html

Specifically, I went to the Python Library Reference (which you will
find stashed under your pillow), Chapter 2 (built-in stuff), then went
to the section on sequences (which Strings are) and the page on Strings.

-- Michael Chermside

Ruediger Maehl

unread,
May 30, 2002, 10:27:24 AM5/30/02
to
"Emile van Sebille" <em...@fenx.com> wrote

>
> The dot in dot join indicates that join resides in the thing being
> dot'ted, in this case likely string. Look at
> Python22\Doc\lib\module-string.html and
> Python22\Doc\lib\string-methods.html

That's explaining string.join() and also some methods that might also
be available for "".xxx() usage but leaves at least me guessing about
their usage.

> --
>
> Emile van Sebille
> em...@fenx.com

Thanks,

Rüdiger


Emile van Sebille

unread,
May 30, 2002, 10:30:44 AM5/30/02
to
Michael Chermside

> Specifically, I went to the Python Library Reference (which you will
> find stashed under your pillow), Chapter 2 (built-in stuff), then went
> to the section on sequences (which Strings are) and the page on
Strings.
>

...which illustrates a difficulty for a newbie... knowing it's 'built-in
stuff' then further knowing that strings are classified under
sequences...


--

Emile van Sebille
em...@fenx.com

---------

Ruediger Maehl

unread,
May 30, 2002, 10:36:04 AM5/30/02
to
"Duncan Booth" <dun...@NOSPAMrcp.co.uk> wrote

> Read the Python library reference, section 2.2.6.1 'String Methods' and
you
> will probably find much of the rest of section 2.2 of interest as well.
>
> or (Python 2.2), at the interactive prompt type:
>
> >>> help(str.join)
> Help on method_descriptor:
>
> join(...)
> S.join(sequence) -> string
>
> Return a string which is the concatenation of the strings in the
> sequence. The separator between elements is S.

That is the description I was looking for, but how do I guess "str"?
I also cannot find it in the Global Module Index. What else is hidden?
(Although I use Python for nearly two years, I sometimes still feel
like a beginner).

> help(str) gives you a complete list of all str methods, but includes a lot
> of internal stuff you probably don't care about.
>
> --
> Duncan Booth dun...@rcp.co.uk
> int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
> "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?

Thanks a lot,

Rüdiger


Duncan Booth

unread,
May 30, 2002, 11:20:45 AM5/30/02
to
"Ruediger Maehl" <ruediger.m...@web.de> wrote in
news:newscache$7ohxwg$ncj$1...@www-neu.dzsh.de:

>> >>> help(str.join)
>> Help on method_descriptor:
>>
>> join(...)
>> S.join(sequence) -> string
>>
>> Return a string which is the concatenation of the strings in the
>> sequence. The separator between elements is S.
>
> That is the description I was looking for, but how do I guess "str"?
> I also cannot find it in the Global Module Index. What else is hidden?
> (Although I use Python for nearly two years, I sometimes still feel
> like a beginner).

str is the name of the string type. You can also do help(unicode.join) for
a similar message about the join method of the unicode type.

The library reference doesn't seem to actually mention anywhere that the
types are called str and unicode: the only mention of str that I can see
hasn't been changed from the days when it was a function.

You might find this useful as it shows you what is really in builtins, not
what is documented:
>>> def showNamespace(namespace=None):
'''Summarise namespace contents'''
if namespace is None: namespace = __builtins__.__dict__
names = {}
# Build a dictionary mapping type to list of names
for k, v in namespace.items():
names.setdefault(type(v), []).append(k)
# Extract typename and name lists into a list
items = [(t.__name__, v) for t, v in names.items()]
items.sort() # Sort by typename
# Print out the variables categorised by type
for k, v in items:
print "%s:" % k, ", ".join(v)
print


>>> showNamespace()
NoneType: None

NotImplementedType: NotImplemented

builtin_function_or_method: vars, pow, globals, divmod, apply, isinstance,
zip, hex, chr, __import__, input, oct, repr, hasattr, delattr, setattr,
raw_input, iter, compile, reload, round, dir, cmp, hash, xrange, reduce,
coerce, intern, issubclass, unichr, id, locals, slice, min, execfile,
getattr, abs, map, buffer, max, len, callable, eval, ord, filter, range

class: RuntimeError, MemoryError, StopIteration, UnicodeError, LookupError,
ReferenceError, NameError, ImportError, SystemExit, Exception,
StandardError, SystemError, IOError, IndexError, RuntimeWarning,
SyntaxWarning, Warning, ArithmeticError, KeyError, EnvironmentError,
DeprecationWarning, FloatingPointError, OverflowWarning, ValueError,
EOFError, TabError, SyntaxError, OSError, IndentationError, AssertionError,
TypeError, KeyboardInterrupt, UserWarning, ZeroDivisionError,
UnboundLocalError, NotImplementedError, AttributeError, OverflowError,
WindowsError

ellipsis: Ellipsis

instance: help, credits, copyright, license

int: __debug__

str: quit, __doc__, exit, __name__

type: float, unicode, open, super, long, complex, dict, type, tuple, list,
str, property, int, file, object, classmethod, staticmethod

Simon Brunning

unread,
May 30, 2002, 12:29:46 PM5/30/02
to
> From: Ruediger Maehl [SMTP:ruediger.m...@web.de]

> could anyone please point me to the piece of documentation
> where I can find a description of .join() and all the others?
>
<http://www.brunningonline.net/simon/python/PQR2.1.html#BasicTypes>

Cheers,
Simon Brunning
TriSystems Ltd.
sbru...@trisystems.co.uk


-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.


Michael Chermside

unread,
May 30, 2002, 3:19:04 PM5/30/02
to
> Michael Chermside
> Specifically, I went to the Python Library Reference (which you will
> find stashed under your pillow), Chapter 2 (built-in stuff), then went
> to the section on sequences (which Strings are) and the page on
> Strings.


Emile van Sebille:


> ...which illustrates a difficulty for a newbie... knowing it's 'built-in
> stuff' then further knowing that strings are classified under
> sequences...

Good point. How many people feel that the Python docs would be improved
by the addition of an index? And in case the response is overwhelming,
who currently manages the docs so I could volunteer to work on an index?

-- Michael Chermside


Emile van Sebille

unread,
May 30, 2002, 7:24:12 PM5/30/02
to
> Good point. How many people feel that the Python docs would be
improved
> by the addition of an index? And in case the response is overwhelming,
> who currently manages the docs so I could volunteer to work on an
index?
>

That would be Fred Drake.

But indexing isn't the full answer. Ask a newbie to wade through

http://web.pydoc.org/2.2/search.cgi?key=join

to see what I mean, although the ActivePython Documentation index gets
closer.

Peter Hansen

unread,
May 30, 2002, 7:51:33 PM5/30/02
to

Isn't http://www.python.org/doc/current/lib/genindex.html good enough?

It lists these, which would probably have solved the OP's problem.
(These are links in the HTML document...)

join() (in module os.path)
join() (in module string)
join() (string method)
join() (Thread method)

-Peter

Delaney, Timothy

unread,
May 30, 2002, 7:36:25 PM5/30/02
to
> From: Emile van Sebille [mailto:em...@fenx.com]

>
> > Good point. How many people feel that the Python docs would be
> improved
> > by the addition of an index? And in case the response is
> overwhelming,
> > who currently manages the docs so I could volunteer to work on an
> index?
> >
>
> That would be Fred Drake.
>
> But indexing isn't the full answer. Ask a newbie to wade through
>
> http://web.pydoc.org/2.2/search.cgi?key=join
>
> to see what I mean, although the ActivePython Documentation index gets
> closer.

Thomas Heller's search page works *very* well ...

http://starship.python.net/crew/theller/pyhelp.cgi?keyword=join&version=curr
ent

Tim Delaney


Geiger Ho

unread,
May 30, 2002, 10:31:53 PM5/30/02
to
Yes, I think it's very difficult for beginners to consult the python
documentation. Not only it's hard to find specific contents, but also the
python documentation use some words and concepts that require you to be
a well-trained programmers to understand. For me, I'm an Electronic
Enginnering student with little knowledge on programming. Sometimes. it's
really hard to understand the documents.

Usually, I just in Linux, in the document root, type:
$> grep -nr "my_finding_keywords" *

to find out which documents I should read.

Now, haha, after I read this thread, I know the other ways. Thanks.

Regards,
Geiger

Geiger Ho

unread,
May 31, 2002, 12:12:54 AM5/31/02
to
Hi all,

I would like to know how could I modify the following code so that it
can be a function in a module? I've tried. But the interpreter warns me
that no __dic__ attribute in __builtins__.

Also, how can I know how many namespaces I create in an environment and
how can I modify the code so that it can show what is in a specific
namespace.

Thanks in advance.

Regards,
Geiger

Steve Holden

unread,
May 31, 2002, 6:19:36 AM5/31/02
to
"Geiger Ho" <s99...@ee.cuhk.edu.hk> wrote ...

Well, you could try typing in the code you quoted, rather than misspelling
__dict__ as __dic__. Surely the error message gave you *some* idea where to
look?

To give a meaningful answer to your second question is diffcult. Each object
has its own namespace, as does each function execution, as does each module.
I'm not sure *why* you might want to to this, unless you are simply (!)
writing a debugger, or trying to improve your command of Python.

what's-in-a-namespace-ly y'rs - steve
--
-----------------------------------------------------------------------
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/pwp/
-----------------------------------------------------------------------

Russell Blau

unread,
May 31, 2002, 9:06:44 AM5/31/02
to
"Duncan Booth" <dun...@NOSPAMrcp.co.uk> wrote in message
news:Xns921EA4D6065...@127.0.0.1...

> You might find this useful as it shows you what is really in builtins,
not
> what is documented:
> >>> def showNamespace(namespace=None):
... snip

>
> type: float, unicode, open, super, long, complex, dict, type, tuple,
list,
> str, property, int, file, object, classmethod, staticmethod
>

OK, this intrigues me. What are <type 'open'> and <type 'super'> ??
I've never seen any reference to either of these before.

--
I don't actually have a hotmail account; but I do have one on excite.com
if you really want to get in touch with me.

Duncan Booth

unread,
May 31, 2002, 9:42:12 AM5/31/02
to
"Russell Blau" <russ...@hotmail.com> wrote in news:ad7sjs$v94d3$1@ID-
76829.news.dfncis.de:

>> type: float, unicode, open, super, long, complex, dict, type, tuple,
> list,
>> str, property, int, file, object, classmethod, staticmethod
>>
>
> OK, this intrigues me. What are <type 'open'> and <type 'super'> ??
> I've never seen any reference to either of these before.

open is an alias for the file type. You can construct a file object by:

file(name[, mode[, buffering]]) -> file object
is the same as:
open(name[, mode[, buffering]]) -> file object

>>> print open is file
1

super is used in new style classes to call methods higher in the
inheritance search order (even if they aren't directly in base classes):

Try this example:

class A(object):
def save(self):
print "Save state of A"

class B(A):
def save(self):
print "Save state of B"
super(B, self).save()

class C(A):
def save(self):
print "Save state of C"
super(C, self).save()

class D(B, C):
def save(self):
print "Save state of D"
super(D, self).save()

b1 = B()
print "b1.save()"
b1.save()

d1 = D()
print "d1.save()"
d1.save()

The output of running this is:
b1.save()
Save state of B
Save state of A
d1.save()
Save state of D
Save state of B
Save state of C
Save state of A

Notice that calling the save method on a B object calls the save method in
its base A object, but calling the B save method when the object is really
a D the call is instead directed across to the C class.

super is quite clever really. At first sight you might think that
super(B,d1) would simply return C, but it actually returns a super object
that delays the base class search until you try to call a method on it.
This means that if C didn't have a save method the C class could be
bypassed and super(B,d1).save() would call A.save() instead.

Kragen Sitaker

unread,
Jun 1, 2002, 3:23:24 PM6/1/02
to
"Emile van Sebille" <em...@fenx.com> writes:
> Michael Chermside
> > Specifically, I went to the Python Library Reference (which you will
> > find stashed under your pillow), Chapter 2 (built-in stuff), then went
> > to the section on sequences (which Strings are) and the page on
> Strings.
>
> ...which illustrates a difficulty for a newbie... knowing it's 'built-in
> stuff' then further knowing that strings are classified under
> sequences...

Yeah, what I did is I read straight through the Language Reference the
first time (didn't understand much, but kind of got the lay of the
land) and eventually learned that the index of the Library Reference
was the place to look for such things. It took me a while to stop
looking in the Language Reference for things like methods of lists.

Thomas Heller

unread,
Jun 3, 2002, 4:01:42 AM6/3/02
to
> But indexing isn't the full answer. Ask a newbie to wade through
>
> http://web.pydoc.org/2.2/search.cgi?key=join
>
But then there's the Python Manual Index search:
http://starship.python.net/crew/theller/pyhelp.cgi?keyword=join

Thomas


0 new messages