List -> Tuple

Skip Montanaro skip at pobox.com
Wed Oct 31 11:58:24 EST 2001


    Joseph> Ah, thank you much, exactly what I was looking for! Wasn't quite
    Joseph> sure if that function really was sitting around.

You can always import the __builtin__ module and pass it to dir to see what
objects are available from the get go:

    >>> import __builtin__
    >>> dir(__builtin__)
    ['ArithmeticError', 'AssertionError', 'AttributeError',
    'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError',
    'Exception', 'FloatingPointError', 'IOError', 'ImportError',
    'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt',
    'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented',
    'NotImplementedError', 'OSError', 'OverflowError', 'OverflowWarning',
    'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError',
    'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError',
    'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError',
    'UnicodeError', 'UserWarning', 'ValueError', 'Warning',
    'ZeroDivisionError', '__debug__', '__doc__', '__import__', '__name__',
    'abs', 'apply', 'buffer', 'callable', 'chr', 'classmethod', 'cmp',
    'coerce', 'compile', 'complex', 'copyright', 'credits', 'delattr',
    'dictionary', 'dir', 'divmod', 'eval', 'execfile', 'exit', 'file',
    'filter', 'float', 'getattr', 'globals', 'hasattr', 'hash', 'help',
    'hex', 'id', 'input', 'int', 'intern', 'isinstance', 'issubclass',
    'iter', 'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min',
    'object', 'oct', 'open', 'ord', 'pow', 'property', 'quit', 'range',
    'raw_input', 'reduce', 'reload', 'repr', 'round', 'setattr', 'slice',
    'staticmethod', 'str', 'super', 'tuple', 'type', 'unichr', 'unicode',
    'vars', 'xrange', 'zip'] 

If you are using a recent version of Python there is a help function builtin
as well (if not, try importing pydoc and using its help function), so you
can get online docs for just about anything:

    >>> help(tuple)
    Help on class tuple in module __builtin__:

    class tuple(object)
     |  tuple() -> an empty tuple
     |  tuple(sequence) -> tuple initialized from sequence's items
     |  
     |  If the argument is a tuple, the return value is the same object.
     |  
     |  Methods defined here:
     ...

-- 
Skip Montanaro (skip at pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/




More information about the Python-list mailing list