Listing builtin functions and methods (Python)
Question: I have came up with this:

    
    
    [a for a in dir(__builtins__) if str(type(getattr(__builtins__,a))) == "<type 'builtin_function_or_method'>"]
    

I know its ugly. Can you show me a better/more pythonic way of doing this?


Answer: There is the [`inspect` module](http://docs.python.org/library/inspect.html):

    
    
    import inspect
    
    filter(inspect.isbuiltin, (member for name, member in inspect.getmembers(__builtins__)))
    

Edit: reading the documentation a little more closely, I came up with this
variant that doesn't use `__getattr__`

    
    
    import inspect
    
    members = (member for name, member in inspect.getmembers(__builtins__))
    filter(inspect.isbuiltin, members)
    

