list of methods for python shell?

后端 未结 9 1378
鱼传尺愫
鱼传尺愫 2021-02-13 21:27

You\'d have already found out by my usage of terminology that I\'m a python n00b.

straight forward question:

How can i see a list of methods for a particular obj

9条回答
  •  孤独总比滥情好
    2021-02-13 21:47

    Python supports tab completion as well. I prefer my python prompt clean (so no thanks to IPython), but with tab completion.

    Setup in .bashrc or similar:

    PYTHONSTARTUP=$HOME/.pythonrc
    

    Put this in .pythonrc:

    try:
        import readline
    except ImportError:
        print ("Module readline not available.")
    else:
        print ("Enabling tab completion")
        import rlcompleter
        readline.parse_and_bind("tab: complete")
    

    It will print "Enabling tab completion" each time the python prompt starts up, because it's better to be explicit. This won't interfere with execution of python scripts and programs.


    Example:

    >>> lst = []
    >>> lst.
    lst.__add__(           lst.__iadd__(          lst.__setattr__(
    lst.__class__(         lst.__imul__(          lst.__setitem__(
    lst.__contains__(      lst.__init__(          lst.__setslice__(
    lst.__delattr__(       lst.__iter__(          lst.__sizeof__(
    lst.__delitem__(       lst.__le__(            lst.__str__(
    lst.__delslice__(      lst.__len__(           lst.__subclasshook__(
    lst.__doc__            lst.__lt__(            lst.append(
    lst.__eq__(            lst.__mul__(           lst.count(
    lst.__format__(        lst.__ne__(            lst.extend(
    lst.__ge__(            lst.__new__(           lst.index(
    lst.__getattribute__(  lst.__reduce__(        lst.insert(
    lst.__getitem__(       lst.__reduce_ex__(     lst.pop(
    lst.__getslice__(      lst.__repr__(          lst.remove(
    lst.__gt__(            lst.__reversed__(      lst.reverse(
    lst.__hash__           lst.__rmul__(          lst.sort(
    

提交回复
热议问题