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 :

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.