Pythonã®defã¯é¢æ°ãRubyã®defã¯ã¡ã½ãããå®ç¾©ãã¾ãã両è ã®éãã¯defããã¹ãããã¨ç¾ãã¾ãã Pythonã§ã¯ããã¹ãããdefã§ã¯ãã¼ã«ã«é¢æ°ãå®ç¾©ããã¾ãããã¼ã«ã«é¢æ°ã¯ãã®å ´ã§ä½¿ãããã ãã§ãå¤é¨ã«ã¯å½±é¿ã¯åã¼ãã¾ããï¼ã°ãã¼ãã«å¤æ°ã«ä»£å ¥ããããreturnã§è¿ãããããªããã°ï¼ã $ python >>> class Spam: ... def ham(self): ... def egg(): ... print('egg', end='') ... print('egg', end='') ... egg() ... >>> s = Spam() >>> s.egg() AttributeError: 'Spam' object has no attribute 'egg' >>> s.ham() ham egg >>> s.egg() AttributeE
{{#tags}}- {{label}}
{{/tags}}