self地獄
2008/04/11
pythonは、self地獄とか聞いたけど、this地獄でもいいのか。(Python 2.5.1で下のが動いた)
#! /usr/bin/python # -*- coding: cp932 -*- class Tag: def __init__(this): this.data = 100 def __str__(this): return 'this data is ' + str(this.data) def printData(this): print 'printData method prints ' + str(this.data) tag = Tag() print tag tag.printData() # vim: set ts=4 sw=4 sts=4 expandtab :