タグ

関連タグで絞り込む (1)

タグの絞り込みを解除

langとpythonに関するyuguiのブックマーク (2)

  • 2008-09-23 - プログラミング日記 [一般] 〜使い

    最近『初めての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)

    2008-09-23 - プログラミング日記 [一般] 〜使い
  • Pyrex

    Brief Description Pyrex lets you write code that mixes Python and C data types any way you want, and compiles it into a C extension for Python. Documentation About Pyrex Language Overview FAQ Contributed by Users Quick Guide to Pyrex Contributed by Michael JasonSmith. If the above link doesn't work, there is a copy here. Embedding Pyrex Using Pyrex to write stand-alone programs that embed a Python

    yugui
    yugui 2008/09/18
    a Language for Writing Python Extension Modules
  • 1