Type hinting in Eclipse with PyDev

前端 未结 5 933
醉话见心
醉话见心 2021-02-18 22:02

I\'m studying Python, after a lot of PHP experience, and it would be handy to have type-hinting in Python. Looks like Eclipse with PyDev doesn\'t support this. Any sug

5条回答
  •  走了就别回头了
    2021-02-18 22:42

    reStructuredText, epytext and python3 annotations can define expected types in Python code, and are supported by various integrated development environments such as pycharm. This is particularly handy for defining class names, as it allows autocomplete of members.

    A simple example in epytext:

    def x_intercept(m, b):
        """
        Return the x intercept of the line M{y=m*x+b}.  The X{x intercept}
        of a line is the point at which it crosses the x axis (M{y=0}).
    
        @type  m: float
        @param m: The slope of the line.
        @type  b: number
        @param b: The y intercept of the line.  The X{y intercept} of a
                  line is the point at which it crosses the y axis (M{x=0}).
        @rtype:   number
        @return:  the x intercept of the line M{y=m*x+b}.
        """
        return -b/m
    

提交回复
热议问题