Where can I find .join() in the docs

Duncan Booth duncan at NOSPAMrcp.co.uk
Thu May 30 11:20:45 EDT 2002


"Ruediger Maehl" <ruediger.maehl_nospam at web.de> wrote in 
news:newscache$7ohxwg$ncj$1 at 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

>>> 

-- 
Duncan Booth                                             duncan at 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?



More information about the Python-list mailing list