æè¿ãåãã¦ã®Rubyããèªãã§ãããPythonã®ã¡ã½ããã®ç¬¬ä¸å¼æ°ã«selfãæ¸ããªãã¦ã¯ãããªãããRubyã¨å¯¾æ¯ãã¦çç±ããªãã¨ãªãåãã£ãã®ã§æ¤è¨ãã¦ã¿ãã ã¾ãPythonã§ã¯Rubyã¨åæ§ãã¤ã³ã¹ã¿ã³ã¹ã¡ã½ããã¨ãããã¬ãã«é¢æ°ã®åºå¥ããªããPythonã§ã¯ã¡ã½ããã¨é¢æ°ã¨ããå¼ã³æ¹ããããé¢æ°ããã³ã¡ã½ããã¯åãªããªãã¸ã§ã¯ãã®å±æ§ã§ãããã¤ã¾ãã¡ã½ããã¯ã¯ã©ã¹ãªãã¸ã§ã¯ãã®callableãªå±æ§ãé¢æ°ã¯ã¢ã¸ã¥ã¼ã«ãªãã¸ã§ã¯ãã®callableãªå±æ§ã§ãããPythonã§ãå ¨ã¦ããªãã¸ã§ã¯ããªã®ã§ããã®åºå¥ãããªãã¨ãããã¨ãéè¦ã¨ãªãã ããã§ã以ä¸ã®ã¯ã©ã¹å®ç¾©ãèãã¦ã¿ãã >>> class Foo: ... a = 1 ... def foo(self): ... a # ã¨ã©ã¼ (1) ... Foo.a # OK (2) ... self.a # OK (3)
{{#tags}}- {{label}}
{{/tags}}