self地獄

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 :

コメントする

メールアドレスが公開されることはありません。 が付いている欄は必須項目です


The reCAPTCHA verification period has expired. Please reload the page.

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください